@ -252,83 +252,72 @@ namespace NzbDrone.Core.Indexers.Definitions
foreach ( var torrent in group . Torrents )
foreach ( var torrent in group . Torrents )
{
{
const string defaultReleaseInfo = "S01" ;
var releaseInfo = _settings . EnableSonarrCompatibility ? "S01" : "" ;
var releaseInfo = defaultReleaseInfo ;
int? episode = null ;
string episode = null ;
int? season = null ;
int? season = null ;
var editionTitle = torrent . EditionData . EditionTitle ;
var editionTitle = torrent . EditionData . EditionTitle ;
if ( ! string . IsNullOrWhiteSpace ( editionTitle ) )
if ( ! string . IsNullOrWhiteSpace ( editionTitle ) )
{
{
releaseInfo = WebUtility . HtmlDecode ( editionTitle ) ;
releaseInfo = WebUtility . HtmlDecode ( editionTitle ) ;
var simpleSeasonRegEx = new Regex ( @"Season (\d+)" , RegexOptions . Compiled ) ;
if ( _settings . EnableSonarrCompatibility )
var simpleSeasonRegExMatch = simpleSeasonRegEx . Match ( releaseInfo ) ;
if ( simpleSeasonRegExMatch . Success )
{
{
season = ParseUtil . CoerceInt ( simpleSeasonRegExMatch . Groups [ 1 ] . Value ) ;
var simpleSeasonRegEx = new Regex ( @"Season (\d+)" , RegexOptions . Compiled ) ;
var simpleSeasonRegExMatch = simpleSeasonRegEx . Match ( releaseInfo ) ;
if ( simpleSeasonRegExMatch . Success )
{
season = ParseUtil . CoerceInt ( simpleSeasonRegExMatch . Groups [ 1 ] . Value ) ;
}
}
}
var episodeRegEx = new Regex ( @"Episode (\d+)" , RegexOptions . Compiled ) ;
var episodeRegEx = new Regex ( @"Episode (\d+)" , RegexOptions . Compiled ) ;
var episodeRegExMatch = episodeRegEx . Match ( releaseInfo ) ;
var episodeRegExMatch = episodeRegEx . Match ( releaseInfo ) ;
if ( episodeRegExMatch . Success )
if ( episodeRegExMatch . Success )
{
{
episode = episodeRegExMatch. Groups [ 1 ] . Value ;
episode = ParseUtil. CoerceInt ( episodeRegExMatch. Groups [ 1 ] . Value ) ;
}
}
}
}
var advancedSeasonRegEx = new Regex ( @"(\d+)(st|nd|rd|th) Season" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
if ( _settings . EnableSonarrCompatibility )
var advancedSeasonRegExMatch = advancedSeasonRegEx . Match ( mainTitle ) ;
if ( advancedSeasonRegExMatch . Success )
{
{
season = ParseUtil . CoerceInt ( advancedSeasonRegExMatch . Groups [ 1 ] . Value ) ;
var advancedSeasonRegEx = new Regex ( @"(\d+)(st|nd|rd|th) Season" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
}
var advancedSeasonRegExMatch = advancedSeasonRegEx . Match ( mainTitle ) ;
if ( advancedSeasonRegExMatch . Success )
{
season = ParseUtil . CoerceInt ( advancedSeasonRegExMatch . Groups [ 1 ] . Value ) ;
}
var seasonCharactersRegEx = new Regex ( @"(I{2,})$" , RegexOptions . Compiled ) ;
var seasonCharactersRegEx = new Regex ( @"(I{2,})$" , RegexOptions . Compiled ) ;
var seasonCharactersRegExMatch = seasonCharactersRegEx . Match ( mainTitle ) ;
var seasonCharactersRegExMatch = seasonCharactersRegEx . Match ( mainTitle ) ;
if ( seasonCharactersRegExMatch . Success )
if ( seasonCharactersRegExMatch . Success )
{
{
season = seasonCharactersRegExMatch . Groups [ 1 ] . Value . Length ;
season = seasonCharactersRegExMatch . Groups [ 1 ] . Value . Length ;
}
}
var seasonNumberRegEx = new Regex ( @"([2-9])$" , RegexOptions . Compiled ) ;
var seasonNumberRegEx = new Regex ( @"([2-9])$" , RegexOptions . Compiled ) ;
var seasonNumberRegExMatch = seasonNumberRegEx . Match ( mainTitle ) ;
var seasonNumberRegExMatch = seasonNumberRegEx . Match ( mainTitle ) ;
if ( seasonNumberRegExMatch . Success )
if ( seasonNumberRegExMatch . Success )
{
{
season = ParseUtil . CoerceInt ( seasonNumberRegExMatch . Groups [ 1 ] . Value ) ;
season = ParseUtil . CoerceInt ( seasonNumberRegExMatch . Groups [ 1 ] . Value ) ;
}
}
}
var foundSeason = false ;
if ( episode ! = null )
if ( season ! = null )
{
{
releaseInfo = $"Season {season}" ;
releaseInfo = episode is > 0 and < 10
? "0" + episode
foundSeason = true ;
: episode . ToString ( ) ;
}
}
else
if ( episode ! = null )
{
{
var epString = $"Episode {episode}" ;
if ( season ! = null & & _settings . EnableSonarrCompatibility )
if ( foundSeason )
{
releaseInfo + = $" {epString}" ;
}
else
{
{
releaseInfo = epString ;
releaseInfo = $"S{season}" ;
}
}
}
}
releaseInfo = releaseInfo . Replace ( "Episode " , string . Empty ) ;
releaseInfo = releaseInfo . Replace ( "Season " , "S" ) ;
releaseInfo = releaseInfo . Trim ( ) ;
releaseInfo = releaseInfo . Trim ( ) ;
if ( int . TryParse ( releaseInfo , out _ ) & & releaseInfo . Length = = 1 )
{
releaseInfo = "0" + releaseInfo ;
}
var torrentId = torrent . Id ;
var torrentId = torrent . Id ;
var property = torrent . Property . Replace ( " | Freeleech" , string . Empty ) ;
var property = torrent . Property . Replace ( " | Freeleech" , string . Empty ) ;
var link = torrent . Link ;
var link = torrent . Link ;
@ -503,6 +492,7 @@ namespace NzbDrone.Core.Indexers.Definitions
{
{
Passkey = "" ;
Passkey = "" ;
Username = "" ;
Username = "" ;
EnableSonarrCompatibility = true ;
}
}
[FieldDefinition(1, Label = "Base Url", Type = FieldType.Select, SelectOptionsProviderAction = "getUrls", HelpText = "Select which baseurl Prowlarr will use for requests to the site")]
[FieldDefinition(1, Label = "Base Url", Type = FieldType.Select, SelectOptionsProviderAction = "getUrls", HelpText = "Select which baseurl Prowlarr will use for requests to the site")]
@ -514,7 +504,10 @@ namespace NzbDrone.Core.Indexers.Definitions
[FieldDefinition(3, Label = "Username", HelpText = "Site Username", Privacy = PrivacyLevel.UserName)]
[FieldDefinition(3, Label = "Username", HelpText = "Site Username", Privacy = PrivacyLevel.UserName)]
public string Username { get ; set ; }
public string Username { get ; set ; }
[FieldDefinition(4)]
[FieldDefinition(4, Label = "Enable Sonarr Compatibility", Type = FieldType.Checkbox, HelpText = "Makes Prowlarr try to add Season information into Release names, without this Sonarr can't match any Seasons, but it has a lot of false positives as well")]
public bool EnableSonarrCompatibility { get ; set ; }
[FieldDefinition(5)]
public IndexerBaseSettings BaseSettings { get ; set ; } = new IndexerBaseSettings ( ) ;
public IndexerBaseSettings BaseSettings { get ; set ; } = new IndexerBaseSettings ( ) ;
public NzbDroneValidationResult Validate ( )
public NzbDroneValidationResult Validate ( )