Permalink
Browse files

Merge pull request #1551 from t-nelson/remove_struct_sepisode

Remove struct sepisode
  • Loading branch information...
2 parents 8028093 + 75b5759 commit 2661fb4c84a77403b977262cf87ad8e2ba008d67 Arne Morten Kvarving committed Oct 7, 2012
View
@@ -46,6 +46,7 @@
using namespace std;
using namespace XFILE;
using namespace MUSIC_GRABBER;
+using namespace VIDEO;
namespace ADDON
{
View
@@ -126,7 +126,7 @@ class CScraper : public CAddon
const CStdString &sAlbum, const CStdString &sArtist = "");
std::vector<MUSIC_GRABBER::CMusicArtistInfo> FindArtist(
XFILE::CCurlFile &fcurl, const CStdString &sArtist);
- EPISODELIST GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl);
+ VIDEO::EPISODELIST GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl);
bool GetVideoDetails(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl,
bool fMovie/*else episode*/, CVideoInfoTag &video);
View
@@ -1,27 +1,35 @@
#pragma once
#include "utils/ScraperUrl.h"
+#include "XBDateTime.h"
// single episode information
-struct EPISODE
+namespace VIDEO
{
- int iSeason;
- int iEpisode;
- int iSubepisode;
- CDateTime cDate;
- CScraperUrl cScraperUrl;
- EPISODE(int Season = -1, int Episode = -1, int Subepisode = 0)
+ struct EPISODE
{
- iSeason = Season;
- iEpisode = Episode;
- iSubepisode = Subepisode;
- }
- bool operator==(const struct EPISODE& rhs)
- {
- return (iSeason == rhs.iSeason &&
- iEpisode == rhs.iEpisode &&
- iSubepisode == rhs.iSubepisode);
- }
-};
+ bool isFolder;
+ int iSeason;
+ int iEpisode;
+ int iSubepisode;
+ std::string strPath;
+ std::string strTitle;
+ CDateTime cDate;
+ CScraperUrl cScraperUrl;
+ EPISODE(int Season = -1, int Episode = -1, int Subepisode = 0, bool Folder = false)
+ {
+ iSeason = Season;
+ iEpisode = Episode;
+ iSubepisode = Subepisode;
+ isFolder = Folder;
+ }
+ bool operator==(const struct EPISODE& rhs)
+ {
+ return (iSeason == rhs.iSeason &&
+ iEpisode == rhs.iEpisode &&
+ iSubepisode == rhs.iSubepisode);
+ }
+ };
-typedef std::vector<EPISODE> EPISODELIST;
+ typedef std::vector<EPISODE> EPISODELIST;
+}
@@ -31,6 +31,7 @@
#include "utils/URIUtils.h"
using namespace std;
+using namespace VIDEO;
#ifndef __GNUC__
#pragma warning (disable:4018)
@@ -55,7 +55,7 @@ class CVideoInfoDownloader : public CThread
int FindMovie(const CStdString& strMovie, MOVIELIST& movielist, CGUIDialogProgress *pProgress = NULL);
bool GetDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
bool GetEpisodeDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
- bool GetEpisodeList(const CScraperUrl& url, EPISODELIST& details, CGUIDialogProgress *pProgress = NULL);
+ bool GetEpisodeList(const CScraperUrl& url, VIDEO::EPISODELIST& details, CGUIDialogProgress *pProgress = NULL);
static void ShowErrorDialog(const ADDON::CScraperError &sce);
@@ -66,15 +66,15 @@ class CVideoInfoDownloader : public CThread
GET_EPISODE_LIST = 3,
GET_EPISODE_DETAILS = 4 };
- XFILE::CCurlFile* m_http;
- CStdString m_strMovie;
- MOVIELIST m_movieList;
- CVideoInfoTag m_movieDetails;
- CScraperUrl m_url;
- EPISODELIST m_episode;
- LOOKUP_STATE m_state;
- int m_found;
- ADDON::ScraperPtr m_info;
+ XFILE::CCurlFile* m_http;
+ CStdString m_strMovie;
+ MOVIELIST m_movieList;
+ CVideoInfoTag m_movieDetails;
+ CScraperUrl m_url;
+ VIDEO::EPISODELIST m_episode;
+ LOOKUP_STATE m_state;
+ int m_found;
+ ADDON::ScraperPtr m_info;
// threaded stuff
void Process();
@@ -611,7 +611,7 @@ namespace VIDEO
INFO_RET CVideoInfoScanner::RetrieveInfoForEpisodes(CFileItemPtr item, long showID, const ADDON::ScraperPtr &scraper, bool useLocal, CGUIDialogProgress *progress)
{
// enumerate episodes
- EPISODES files;
+ EPISODELIST files;
EnumerateSeriesFolder(item.get(), files);
if (files.size() == 0) // no update or no files
return INFO_NOT_NEEDED;
@@ -626,7 +626,7 @@ namespace VIDEO
return OnProcessSeriesFolder(files, scraper, useLocal, showID, showTitle, progress);
}
- void CVideoInfoScanner::EnumerateSeriesFolder(CFileItem* item, EPISODES& episodeList)
+ void CVideoInfoScanner::EnumerateSeriesFolder(CFileItem* item, EPISODELIST& episodeList)
{
CFileItemList items;
@@ -744,7 +744,7 @@ namespace VIDEO
}
}
- bool CVideoInfoScanner::ProcessItemByVideoInfoTag(const CFileItemPtr item, EPISODES &episodeList)
+ bool CVideoInfoScanner::ProcessItemByVideoInfoTag(const CFileItemPtr item, EPISODELIST &episodeList)
{
if (!item->HasVideoInfoTag())
return false;
@@ -756,7 +756,7 @@ namespace VIDEO
*/
if (tag->m_iSeason > -1 && tag->m_iEpisode > 0)
{
- SEpisode episode = {};
+ EPISODE episode;
episode.strPath = item->GetPath();
episode.iSeason = tag->m_iSeason;
episode.iEpisode = tag->m_iEpisode;
@@ -773,7 +773,7 @@ namespace VIDEO
*/
if (tag->m_firstAired.IsValid())
{
- SEpisode episode = {};
+ EPISODE episode;
episode.strPath = item->GetPath();
episode.strTitle = tag->m_strTitle;
episode.isFolder = false;
@@ -799,7 +799,7 @@ namespace VIDEO
*/
if (!tag->m_strTitle.IsEmpty())
{
- SEpisode episode = {};
+ EPISODE episode;
episode.strPath = item->GetPath();
episode.strTitle = tag->m_strTitle;
episode.isFolder = false;
@@ -829,7 +829,7 @@ namespace VIDEO
return false;
}
- bool CVideoInfoScanner::EnumerateEpisodeItem(const CFileItemPtr item, EPISODES& episodeList)
+ bool CVideoInfoScanner::EnumerateEpisodeItem(const CFileItemPtr item, EPISODELIST& episodeList)
{
SETTINGS_TVSHOWLIST expression = g_advancedSettings.m_tvshowEnumRegExps;
@@ -849,7 +849,7 @@ namespace VIDEO
if ((regexppos = reg.RegFind(strLabel.c_str())) < 0)
continue;
- SEpisode episode = {};
+ EPISODE episode;
episode.strPath = item->GetPath();
episode.iSeason = -1;
episode.iEpisode = -1;
@@ -891,7 +891,7 @@ namespace VIDEO
if (reg.RegFind(strBasePath.c_str()) > -1)
{
- SEpisode parent = {};
+ EPISODE parent;
if (byDate)
{
GetAirDateFromRegExp(reg, parent);
@@ -951,7 +951,7 @@ namespace VIDEO
return false;
}
- bool CVideoInfoScanner::GetEpisodeAndSeasonFromRegExp(CRegExp &reg, SEpisode &episodeInfo, int defaultSeason)
+ bool CVideoInfoScanner::GetEpisodeAndSeasonFromRegExp(CRegExp &reg, EPISODE &episodeInfo, int defaultSeason)
{
char* season = reg.GetReplaceString("\\1");
char* episode = reg.GetReplaceString("\\2");
@@ -989,7 +989,7 @@ namespace VIDEO
return (season && episode);
}
- bool CVideoInfoScanner::GetAirDateFromRegExp(CRegExp &reg, SEpisode &episodeInfo)
+ bool CVideoInfoScanner::GetAirDateFromRegExp(CRegExp &reg, EPISODE &episodeInfo)
{
char* param1 = reg.GetReplaceString("\\1");
char* param2 = reg.GetReplaceString("\\2");
@@ -1199,7 +1199,7 @@ namespace VIDEO
ApplyThumbToFolder(parentDir, thumb);
}
- INFO_RET CVideoInfoScanner::OnProcessSeriesFolder(EPISODES& files, const ADDON::ScraperPtr &scraper, bool useLocal, int idShow, const CStdString& strShowTitle, CGUIDialogProgress* pDlgProgress /* = NULL */)
+ INFO_RET CVideoInfoScanner::OnProcessSeriesFolder(EPISODELIST& files, const ADDON::ScraperPtr &scraper, bool useLocal, int idShow, const CStdString& strShowTitle, CGUIDialogProgress* pDlgProgress /* = NULL */)
{
if (pDlgProgress)
{
@@ -1215,7 +1215,7 @@ namespace VIDEO
int iMax = files.size();
int iCurr = 1;
- for (EPISODES::iterator file = files.begin(); file != files.end(); ++file)
+ for (EPISODELIST::iterator file = files.begin(); file != files.end(); ++file)
{
m_nfoReader.Close();
if (pDlgProgress)
@@ -1290,7 +1290,7 @@ namespace VIDEO
continue;
}
- struct EPISODE key(file->iSeason, file->iEpisode, file->iSubepisode);
+ EPISODE key(file->iSeason, file->iEpisode, file->iSubepisode);
bool bFound = false;
EPISODELIST::iterator guide = episodes.begin();;
EPISODELIST matches;
@@ -1307,7 +1307,7 @@ namespace VIDEO
matches.push_back(*guide);
continue;
}
- if (!guide->cScraperUrl.strTitle.IsEmpty() && guide->cScraperUrl.strTitle.CompareNoCase(file->strTitle) == 0)
+ if (!guide->cScraperUrl.strTitle.IsEmpty() && guide->cScraperUrl.strTitle.CompareNoCase(file->strTitle.c_str()) == 0)
{
bFound = true;
break;
@@ -1322,12 +1322,12 @@ namespace VIDEO
*
* Otherwise, use the title to further refine the best match.
*/
- if (matches.size() == 1 || (file->strTitle.IsEmpty() && matches.size() > 1))
+ if (matches.size() == 1 || (file->strTitle.empty() && matches.size() > 1))
{
guide = matches.begin();
bFound = true;
}
- else if (!file->strTitle.IsEmpty())
+ else if (!file->strTitle.empty())
{
double minscore = 0; // Default minimum score is 0 to find whatever is the best match.
@@ -1345,7 +1345,9 @@ namespace VIDEO
titles.push_back(guide->cScraperUrl.strTitle.ToLower());
double matchscore;
- int index = StringUtils::FindBestMatch(file->strTitle.ToLower(), titles, matchscore);
+ std::string loweredTitle(file->strTitle);
+ StringUtils::ToLower(loweredTitle);
+ int index = StringUtils::FindBestMatch(loweredTitle, titles, matchscore);
if (matchscore >= minscore)
{
guide = candidates->begin() + index;
@@ -22,7 +22,6 @@
#include "VideoDatabase.h"
#include "addons/Scraper.h"
#include "NfoFile.h"
-#include "XBDateTime.h"
class CRegExp;
@@ -38,19 +37,6 @@ namespace VIDEO
bool exclude; /* exclude this path from scraping */
} SScanSettings;
- typedef struct SEpisode
- {
- CStdString strPath;
- CStdString strTitle;
- int iSeason;
- int iEpisode;
- int iSubepisode;
- bool isFolder;
- CDateTime cDate;
- } SEpisode;
-
- typedef std::vector<SEpisode> EPISODES;
-
enum SCAN_STATE { PREPARING = 0, REMOVING_OLD, CLEANING_UP_DATABASE, FETCHING_MOVIE_INFO, FETCHING_MUSICVIDEO_INFO, FETCHING_TVSHOW_INFO, COMPRESSING_DATABASE, WRITING_CHANGES };
class IVideoInfoScannerObserver
@@ -177,14 +163,14 @@ namespace VIDEO
\param defaultSeason Season to use if not found in reg.
\return true on success (2 matches), false on failure (fewer than 2 matches)
*/
- bool GetEpisodeAndSeasonFromRegExp(CRegExp &reg, SEpisode &episodeInfo, int defaultSeason);
+ bool GetEpisodeAndSeasonFromRegExp(CRegExp &reg, EPISODE &episodeInfo, int defaultSeason);
/*! \brief Extract episode air-date from a processed regexp
\param reg Regular expression object with at least 3 matches
\param episodeInfo Episode information to fill in.
\return true on success (3 matches), false on failure (fewer than 3 matches)
*/
- bool GetAirDateFromRegExp(CRegExp &reg, SEpisode &episodeInfo);
+ bool GetAirDateFromRegExp(CRegExp &reg, EPISODE &episodeInfo);
/*! \brief Fetch thumbs for actors
Updates each actor with their thumb (local or online)
@@ -225,11 +211,11 @@ namespace VIDEO
\return INFO_ERROR on failure, INFO_CANCELLED on cancellation,
INFO_NOT_FOUND if an episode isn't found, or INFO_ADDED if all episodes are added.
*/
- INFO_RET OnProcessSeriesFolder(EPISODES& files, const ADDON::ScraperPtr &scraper, bool useLocal, int idShow, const CStdString& strShowTitle, CGUIDialogProgress* pDlgProgress = NULL);
+ INFO_RET OnProcessSeriesFolder(EPISODELIST& files, const ADDON::ScraperPtr &scraper, bool useLocal, int idShow, const CStdString& strShowTitle, CGUIDialogProgress* pDlgProgress = NULL);
- void EnumerateSeriesFolder(CFileItem* item, EPISODES& episodeList);
- bool EnumerateEpisodeItem(const CFileItemPtr item, EPISODES& episodeList);
- bool ProcessItemByVideoInfoTag(const CFileItemPtr item, EPISODES &episodeList);
+ void EnumerateSeriesFolder(CFileItem* item, EPISODELIST& episodeList);
+ bool EnumerateEpisodeItem(const CFileItemPtr item, EPISODELIST& episodeList);
+ bool ProcessItemByVideoInfoTag(const CFileItemPtr item, EPISODELIST &episodeList);
CStdString GetnfoFile(CFileItem *item, bool bGrabAny=false) const;

0 comments on commit 2661fb4

Please sign in to comment.