@ -12,6 +12,7 @@ namespace NzbDrone.Core.Parser
{
public interface IParsingService
{
ParsedEpisodeInfo ParseSpecialEpisodeTitle ( string title , int tvRageId , SearchCriteriaBase searchCriteria = null ) ;
ParsedEpisodeInfo ParseSpecialEpisodeTitle ( string title , Series series ) ;
LocalEpisode GetEpisodes ( string filename , Series series , bool sceneSource ) ;
Series GetSeries ( string title ) ;
@ -40,27 +41,47 @@ namespace NzbDrone.Core.Parser
_logger = logger ;
}
public ParsedEpisodeInfo ParseSpecialEpisodeTitle ( string title , Series series )
public ParsedEpisodeInfo ParseSpecialEpisodeTitle ( string title , int tvRageId , SearchCriteriaBase searchCriteria = null )
{
try
if ( searchCriteria ! = null )
{
if ( series = = null )
var tvdbId = _sceneMappingService . GetTvDbId ( title ) ;
if ( tvdbId . HasValue )
{
if ( searchCriteria . Series . TvdbId = = tvdbId )
{
return ParseSpecialEpisodeTitle ( title , searchCriteria . Series ) ;
}
}
if ( tvRageId = = searchCriteria . Series . TvRageId )
{
return ParseSpecialEpisodeTitle ( title , searchCriteria . Series ) ;
}
}
var series = _seriesService . FindByTitleInexact ( title ) ;
if ( series = = null & & tvRageId > 0 )
{
// find series if we dont have it already
// we use an inexact match here since the series name is often mangled with the episode title
series = _seriesService . FindByTitleInexact ( title ) ;
series = _seriesService . FindByTvRageId ( tvRageId ) ;
}
if ( series = = null )
{
// no series matched
_logger . Trace ( "No matching series {0}" , title ) ;
return null ;
}
return ParseSpecialEpisodeTitle ( title , series ) ;
}
public ParsedEpisodeInfo ParseSpecialEpisodeTitle ( string title , Series series )
{
// find special episode in series season 0
Episode episode = _episodeService . FindEpisodeByName ( series . Id , 0 , title ) ;
var episode = _episodeService . FindEpisodeByName ( series . Id , 0 , title ) ;
if ( episode ! = null )
{
// created parsed info from tv episode that we found
// create parsed info from tv episode
var info = new ParsedEpisodeInfo ( ) ;
info . SeriesTitle = series . Title ;
info . SeriesTitleInfo = new SeriesTitleInfo ( ) ;
@ -74,17 +95,11 @@ namespace NzbDrone.Core.Parser
_logger . Info ( "Found special episode {0} for title '{1}'" , info , title ) ;
return info ;
}
}
catch ( Exception e )
{
_logger . ErrorException ( "An error has occurred while trying to parse special episode " + title , e ) ;
}
return null ;
}
public LocalEpisode GetEpisodes ( string filename , Series series , bool sceneSource )
{
var parsedEpisodeInfo = Parser . ParsePath ( filename ) ;