CNfoFile::NFOResult CNfoFile::Create(const std::string& strPath, const ScraperPtr& info, int episode) { m_info = info; // assume we can use these settings m_type = ScraperTypeFromContent(info->Content()); if (Load(strPath) != 0) return NO_NFO; CFileItemList items; bool bNfo=false; AddonPtr addon; ScraperPtr defaultScraper; if (CAddonMgr::Get().GetDefault(m_type, addon)) defaultScraper = boost::dynamic_pointer_cast<CScraper>(addon); if (m_type == ADDON_SCRAPER_ALBUMS) { CAlbum album; bNfo = GetDetails(album); } else if (m_type == ADDON_SCRAPER_ARTISTS) { CArtist artist; bNfo = GetDetails(artist); } else if (m_type == ADDON_SCRAPER_TVSHOWS || m_type == ADDON_SCRAPER_MOVIES || m_type == ADDON_SCRAPER_MUSICVIDEOS) { // first check if it's an XML file with the info we need CVideoInfoTag details; bNfo = GetDetails(details); if (episode > -1 && bNfo && m_type == ADDON_SCRAPER_TVSHOWS) { int infos=0; m_headPos = m_doc.find("<episodedetails", m_headPos); bNfo = GetDetails(details); while (m_headPos!=std::string::npos && details.m_iEpisode != episode) { m_headPos = m_doc.find("<episodedetails", m_headPos + 1); bNfo = GetDetails(details); infos++; } if (details.m_iEpisode != episode) { bNfo = false; details.Reset(); m_headPos = 0; if (infos == 1) // still allow differing nfo/file numbers for single ep nfo's bNfo = GetDetails(details); } } } vector<ScraperPtr> vecScrapers; // add selected scraper - first proirity if (m_info) vecScrapers.push_back(m_info); // Add all scrapers except selected and default VECADDONS addons; CAddonMgr::Get().GetAddons(m_type,addons); for (unsigned i = 0; i < addons.size(); ++i) { ScraperPtr scraper = boost::dynamic_pointer_cast<CScraper>(addons[i]); // skip if scraper requires settings and there's nothing set yet if (scraper->RequiresSettings() && !scraper->HasUserSettings()) continue; if( (!m_info || m_info->ID() != scraper->ID()) && (!defaultScraper || defaultScraper->ID() != scraper->ID()) ) vecScrapers.push_back(scraper); } // add default scraper - not user selectable so it's last priority if( defaultScraper && (!m_info || m_info->ID() != defaultScraper->ID()) && ( !defaultScraper->RequiresSettings() || defaultScraper->HasUserSettings() ) ) vecScrapers.push_back(defaultScraper); // search .. int res = -1; for (unsigned int i=0;i<vecScrapers.size();++i) if ((res = Scrape(vecScrapers[i])) == 0 || res == 2) break; if (res == 2) return ERROR_NFO; if (bNfo) return m_scurl.m_url.empty() ? FULL_NFO : COMBINED_NFO; return m_scurl.m_url.empty() ? NO_NFO : URL_NFO; }
CNfoFile::NFOResult CNfoFile::Create(const CStdString& strPath, const ScraperPtr& info, int episode, const CStdString& strPath2) { m_info = info; // assume we can use these settings m_type = ScraperTypeFromContent(info->Content()); if (FAILED(Load(strPath))) return NO_NFO; CFileItemList items; bool bNfo=false; AddonPtr addon; ScraperPtr defaultScraper; if (CAddonMgr::Get().GetDefault(m_type, addon)) defaultScraper = boost::dynamic_pointer_cast<CScraper>(addon); if (m_type == ADDON_SCRAPER_ALBUMS) { CAlbum album; bNfo = GetDetails(album); } else if (m_type == ADDON_SCRAPER_ARTISTS) { CArtist artist; bNfo = GetDetails(artist); } else if (m_type == ADDON_SCRAPER_TVSHOWS || m_type == ADDON_SCRAPER_MOVIES || m_type == ADDON_SCRAPER_MUSICVIDEOS) { // first check if it's an XML file with the info we need CVideoInfoTag details; bNfo = GetDetails(details); if (episode > -1 && bNfo && m_type == ADDON_SCRAPER_TVSHOWS) { int infos=0; while (m_headofdoc && details.m_iEpisode != episode) { m_headofdoc = strstr(m_headofdoc+1,"<episodedetails"); bNfo = GetDetails(details); infos++; } if (details.m_iEpisode != episode) { bNfo = false; details.Reset(); m_headofdoc = m_doc; if (infos == 1) // still allow differing nfo/file numbers for single ep nfo's bNfo = GetDetails(details); } } } vector<ScraperPtr> vecScrapers; // add selected scraper if (m_info) vecScrapers.push_back(m_info); VECADDONS addons; CAddonMgr::Get().GetAddons(m_type,addons); // first pass - add language based scrapers if (m_info && g_guiSettings.GetBool("scrapers.langfallback")) AddScrapers(addons,vecScrapers); // add default scraper if (defaultScraper && m_info && m_info->ID() != defaultScraper->ID()) vecScrapers.push_back(defaultScraper); // search .. int res = -1; for (unsigned int i=0;i<vecScrapers.size();++i) if ((res = Scrape(vecScrapers[i])) == 0 || res == 2) break; if (res == 2) return ERROR_NFO; if (bNfo) return m_scurl.m_url.empty() ? FULL_NFO : COMBINED_NFO; return m_scurl.m_url.empty() ? NO_NFO : URL_NFO; }