Permalink
Browse files

Add support for scanning subepisodes into the video library

This enables us to detect/enumerate tv eps named like Show.s01e01a.*,
Show.1x1.2, etc (mostly kiddie shows I'd think). It still uses the
per-season aired order number after the initial enumeration, so no db
changes were necessary.
  • Loading branch information...
1 parent 5e4b59d commit 636a79981da591fc7929396c2661da807346d875 @t-nelson t-nelson committed Sep 26, 2012
View
@@ -810,10 +810,14 @@ EPISODELIST CScraper::GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl
{
EPISODE ep;
TiXmlElement *pxeLink = pxeMovie->FirstChildElement("url");
- if (pxeLink && XMLUtils::GetInt(pxeMovie, "season", ep.key.first) &&
- XMLUtils::GetInt(pxeMovie, "epnum", ep.key.second))
+ CStdString strEpNum;
+ if (pxeLink && XMLUtils::GetInt(pxeMovie, "season", ep.iSeason) &&
+ XMLUtils::GetString(pxeMovie, "epnum", strEpNum))
{
CScraperUrl &scurlEp(ep.cScraperUrl);
+ int dot = strEpNum.Find(".");
+ ep.iEpisode = atoi(strEpNum.c_str());
+ ep.iSubepisode = (dot > -1) ? atoi(strEpNum.Mid(dot + 1).c_str()) : 0;
if (!XMLUtils::GetString(pxeMovie, "title", scurlEp.strTitle))
scurlEp.strTitle = g_localizeStrings.Get(416);
XMLUtils::GetString(pxeMovie, "id", scurlEp.strId);
@@ -160,21 +160,21 @@ void CAdvancedSettings::Initialize()
//m_videoStackRegExps.push_back("(.*?)([ ._-]*[0-9])(.*?)(\\.[^.]+)$");
// foo.s01.e01, foo.s01_e01, S01E02 foo, S01 - E02
- m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+)([^\\\\/]*)$"));
+ m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+(?:[a-i]|\\.[1-9](?![0-9]))?)([^\\\\/]*)$"));
// foo.ep01, foo.EP_01
- m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\._ -]()[Ee][Pp]_?([0-9]+)([^\\\\/]*)$"));
+ m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\._ -]()[Ee][Pp]_?([0-9]+(?:[a-i]|\\.[1-9](?![0-9]))?)([^\\\\/]*)$"));
// foo.yyyy.mm.dd.* (byDate=true)
m_tvshowEnumRegExps.push_back(TVShowRegexp(true,"([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})"));
// foo.mm.dd.yyyy.* (byDate=true)
m_tvshowEnumRegExps.push_back(TVShowRegexp(true,"([0-9]{2})[\\.-]([0-9]{2})[\\.-]([0-9]{4})"));
// foo.1x09* or just /1x09*
- m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+)([^\\\\/]*)$"));
+ m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+(?:[a-i]|\\.[1-9](?![0-9]))?)([^\\\\/]*)$"));
// foo.103*, 103 foo
- m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\\\/\\._ -]([0-9]+)([0-9][0-9])([\\._ -][^\\\\/]*)$"));
+ m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\\\/\\._ -]([0-9]+)([0-9][0-9](?:[a-i]|\\.[1-9](?![0-9]))?)([\\._ -][^\\\\/]*)$"));
// Part I, Pt.VI
m_tvshowEnumRegExps.push_back(TVShowRegexp(false,"[\\/._ -]p(?:ar)?t[_. -]()([ivx]+)([._ -][^\\/]*)$"));
- m_tvshowMultiPartEnumRegExp = "^[-_EeXx]+([0-9]+)";
+ m_tvshowMultiPartEnumRegExp = "^[-_EeXx]+([0-9]+(?:[a-i]|\\.[1-9](?![0-9]))?)";
m_remoteDelay = 3;
m_controllerDeadzone = 0.2f;
View
@@ -4,9 +4,23 @@
// single episode information
struct EPISODE
{
- std::pair<int,int> key;
+ int iSeason;
+ int iEpisode;
+ int iSubepisode;
CDateTime cDate;
CScraperUrl cScraperUrl;
+ EPISODE(int Season = -1, int Episode = -1, int Subepisode = 0)
+ {
+ iSeason = Season;
+ iEpisode = Episode;
+ iSubepisode = Subepisode;
+ }
+ bool operator==(const struct EPISODE& rhs)
+ {
+ return (iSeason == rhs.iSeason &&
+ iEpisode == rhs.iEpisode &&
+ iSubepisode == rhs.iSubepisode);
+ }
};
typedef std::vector<EPISODE> EPISODELIST;
@@ -958,11 +958,12 @@ namespace VIDEO
if (season && episode)
{
+ char* endptr = NULL;
if (strlen(season) == 0 && strlen(episode) > 0)
{ // no season specified -> assume defaultSeason
episodeInfo.iSeason = defaultSeason;
if ((episodeInfo.iEpisode = CUtil::TranslateRomanNumeral(episode)) == -1)
- episodeInfo.iEpisode = atoi(episode);
+ episodeInfo.iEpisode = strtol(episode, &endptr, 10);
}
else if (strlen(season) > 0 && strlen(episode) == 0)
{ // no episode specification -> assume defaultSeason
@@ -973,7 +974,14 @@ namespace VIDEO
else
{ // season and episode specified
episodeInfo.iSeason = atoi(season);
- episodeInfo.iEpisode = atoi(episode);
+ episodeInfo.iEpisode = strtol(episode, &endptr, 10);
+ }
+ if (endptr)
+ {
+ if (isalpha(*endptr))
+ episodeInfo.iSubepisode = *endptr - (islower(*endptr) ? 'a' : 'A') + 1;
+ else if (*endptr == '.')
+ episodeInfo.iSubepisode = atoi(endptr+1);
}
}
free(season);
@@ -1282,16 +1290,14 @@ namespace VIDEO
continue;
}
- std::pair<int,int> key;
- key.first = file->iSeason;
- key.second = file->iEpisode;
+ struct EPISODE key(file->iSeason, file->iEpisode, file->iSubepisode);
bool bFound = false;
EPISODELIST::iterator guide = episodes.begin();;
EPISODELIST matches;
for (; guide != episodes.end(); ++guide )
{
- if ((file->iEpisode!=-1) && (file->iSeason!=-1) && (key==guide->key))
+ if ((file->iEpisode!=-1) && (file->iSeason!=-1) && (key==*guide))
{
bFound = true;
break;
@@ -1360,17 +1366,17 @@ namespace VIDEO
// Only set season/epnum from filename when it is not already set by a scraper
if (item.GetVideoInfoTag()->m_iSeason == -1)
- item.GetVideoInfoTag()->m_iSeason = guide->key.first;
+ item.GetVideoInfoTag()->m_iSeason = guide->iSeason;
if (item.GetVideoInfoTag()->m_iEpisode == -1)
- item.GetVideoInfoTag()->m_iEpisode = guide->key.second;
+ item.GetVideoInfoTag()->m_iEpisode = guide->iEpisode;
if (AddVideo(&item, CONTENT_TVSHOWS, file->isFolder, useLocal, idShow) < 0)
return INFO_ERROR;
}
else
{
- CLog::Log(LOGDEBUG,"%s - no match for show: '%s', season: %d, episode: %d, airdate: '%s', title: '%s'",
- __FUNCTION__, strShowTitle.c_str(), file->iSeason, file->iEpisode,
+ CLog::Log(LOGDEBUG,"%s - no match for show: '%s', season: %d, episode: %d.%d, airdate: '%s', title: '%s'",
+ __FUNCTION__, strShowTitle.c_str(), file->iSeason, file->iEpisode, file->iSubepisode,
file->cDate.GetAsLocalizedDate().c_str(), file->strTitle.c_str());
}
}
@@ -44,6 +44,7 @@ namespace VIDEO
CStdString strTitle;
int iSeason;
int iEpisode;
+ int iSubepisode;
bool isFolder;
CDateTime cDate;
} SEpisode;

0 comments on commit 636a799

Please sign in to comment.