Ejemplo n.º 1
0
oFile::Scrape(ScraperPtr& scraper, const CStdString& strURL /* = "" */)
{
  if (scraper->Type() != m_type)
  {
    return 1;
  }
  if (!scraper->Load())
    return 0;

  // init and clear cache
  scraper->ClearCache();

  vector<CStdString> extras;
  CScraperUrl url;
  CFileCurl http;
  if (strURL.IsEmpty())
  {
    if (!DoScrape(scraper))
      return 2;
    if (m_strImDbUrl.size() > 0)
      return 0;
    else
      return 1;
  }
  else // we check to identify the episodeguide url
  {
    extras.push_back(strURL);
    vector<CStdString> result = scraper->Run("EpisodeGuideUrl",url,http,&extras);
    if (result.empty() || result[0].IsEmpty())
      return 1;
    return 0;
  }
}
Ejemplo n.º 2
0
// return value: 0 - success; 1 - no result; skip; 2 - error
int CNfoFile::Scrape(ScraperPtr& scraper)
{
  if (scraper->IsNoop())
  {
    m_scurl = CScraperUrl();
    return 0;
  }
  if (scraper->Type() != m_type)
    return 1;
  scraper->ClearCache();

  try
  {
    m_scurl = scraper->NfoUrl(m_doc);
  }
  catch (const CScraperError &sce)
  {
    CVideoInfoDownloader::ShowErrorDialog(sce);
    if (!sce.FAborted())
      return 2;
  }

  if (!m_scurl.m_url.empty())
    SetScraperInfo(scraper);
  return m_scurl.m_url.empty() ? 1 : 0;
}
Ejemplo n.º 3
0
int CNfoFile::Scrape(ScraperPtr& scraper, const CStdString& strURL /* = "" */)
{
  if (scraper->Type() != m_type)
  {
    return 1;
  }
  if (!scraper->Load())
    return 0;

  // init and clear cache
  scraper->ClearCache();

  vector<CStdString> extras;
  CScraperUrl url;
  CFileCurl http;
  if (strURL.IsEmpty())
  {
    extras.push_back(m_doc);
    vector<CStdString> result;
    if (scraper->GetParser().HasFunction("NfoScrape"))
      result = scraper->Run("NfoScrape",url,http,&extras);
    if (!result.empty())
    {
      TiXmlDocument doc;
      doc.Parse(m_strImDbUrl.c_str());
      if (doc.RootElement() && doc.RootElement()->FirstChildElement())
      {
        CVideoInfoTag details;
        if (GetDetails(details,m_strImDbUrl.c_str()))
        {
          Close();
          m_size = m_strImDbUrl.size();
          m_doc = new char[m_size+1];
          m_headofdoc = m_doc;
          strcpy(m_doc,m_strImDbUrl.c_str());
          return 0;
        }
      }
    }
    if (!DoScrape(scraper))
      return 2;
    if (m_strImDbUrl.size() > 0)
      return 0;
    else
      return 1;
  }
  else // we check to identify the episodeguide url
  {
    extras.push_back(strURL);
    vector<CStdString> result = scraper->Run("EpisodeGuideUrl",url,http,&extras);
    if (result.empty() || result[0].IsEmpty())
      return 1;
    return 0;
  }
}