2013-04-28 20:08:25 +00:00
using System ;
2011-11-24 07:35:37 +00:00
using System.Linq ;
2011-06-02 21:06:46 +00:00
using FluentAssertions ;
2012-02-05 06:34:36 +00:00
using Moq ;
2011-06-02 21:06:46 +00:00
using NUnit.Framework ;
2012-02-05 06:34:36 +00:00
using NzbDrone.Common.Contract ;
2013-04-07 22:40:13 +00:00
using NzbDrone.Core.Indexers ;
2013-04-15 01:41:39 +00:00
using NzbDrone.Core.Parser ;
2011-05-19 03:55:35 +00:00
using NzbDrone.Core.Test.Framework ;
2011-11-24 07:35:37 +00:00
using NzbDrone.Test.Common ;
2013-04-28 20:08:25 +00:00
using NzbDrone.Common.Expansive ;
2010-10-24 07:46:58 +00:00
2013-01-01 03:45:57 +00:00
namespace NzbDrone.Core.Test.ParserTests
2010-10-24 07:46:58 +00:00
{
2013-04-07 19:01:24 +00:00
2012-11-26 07:13:55 +00:00
[TestFixture]
2013-02-17 05:44:06 +00:00
public class ParserFixture : CoreTest
2010-10-24 07:46:58 +00:00
{
2011-04-05 06:33:24 +00:00
/ * Fucked - up hall of shame ,
* WWE . Wrestlemania . 27. PPV . HDTV . XviD - KYR
2011-04-22 22:23:29 +00:00
* Unreported . World . Chinas . Lost . Sons . WS . PDTV . XviD - FTP
2011-09-07 06:43:10 +00:00
* [ TestCase ( "Big Time Rush 1x01 to 10 480i DD2 0 Sianto" , "Big Time Rush" , 1 , new [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } , 10 ) ]
2013-01-01 03:45:57 +00:00
* [ TestCase ( "Desparate Housewives - S07E22 - 7x23 - And Lots of Security.. [HDTV-720p].mkv" , "Desparate Housewives" , 7 , new [ ] { 22 , 23 } , 2 ) ]
* [ TestCase ( "S07E22 - 7x23 - And Lots of Security.. [HDTV-720p].mkv" , "" , 7 , new [ ] { 22 , 23 } , 2 ) ]
2011-04-05 06:33:24 +00:00
* /
2011-06-02 21:06:46 +00:00
[TestCase("Sonny.With.a.Chance.S02E15", "Sonny.With.a.Chance", 2, 15)]
[TestCase("Two.and.a.Half.Me.103.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 1, 3)]
[TestCase("Two.and.a.Half.Me.113.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 1, 13)]
[TestCase("Two.and.a.Half.Me.1013.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 10, 13)]
[TestCase("Chuck.4x05.HDTV.XviD-LOL", "Chuck", 4, 5)]
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", "The.Girls.Next.Door", 3, 6)]
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", "Degrassi", 10, 27)]
[TestCase("Parenthood.2010.S02E14.HDTV.XviD-LOL", "Parenthood 2010", 2, 14)]
[TestCase("Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1, 19)]
[TestCase("The Event S01E14 A Message Back 720p WEB DL DD5 1 H264 SURFER", "The Event", 1, 14)]
[TestCase("Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", "Adam Hills In Gordon St Tonight", 1, 7)]
[TestCase("Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", "Adam Hills In Gordon St Tonight", 1, 7)]
[TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", "Adventure.Inc", 3, 19)]
[TestCase("S03E09 WS PDTV XviD FUtV", "", 3, 9)]
[TestCase("5x10 WS PDTV XviD FUtV", "", 5, 10)]
[TestCase("Castle.2009.S01E14.HDTV.XviD-LOL", "Castle 2009", 1, 14)]
[TestCase("Pride.and.Prejudice.1995.S03E20.HDTV.XviD-LOL", "Pride and Prejudice 1995", 3, 20)]
[TestCase("The.Office.S03E115.DVDRip.XviD-OSiTV", "The.Office", 3, 115)]
[TestCase(@"Parks and Recreation - S02E21 - 94 Meetings - 720p TV.mkv", "Parks and Recreation", 2, 21)]
[TestCase(@"24-7 Penguins-Capitals- Road to the NHL Winter Classic - S01E03 - Episode 3.mkv", "24-7 Penguins-Capitals- Road to the NHL Winter Classic", 1, 3)]
2011-06-18 03:11:04 +00:00
[TestCase("Adventure.Inc.S03E19.DVDRip.\"XviD\"-OSiTV", "Adventure.Inc", 3, 19)]
2011-06-25 01:20:52 +00:00
[TestCase("Hawaii Five-0 (2010) - 1x05 - Nalowale (Forgotten/Missing)", "Hawaii Five-0 (2010)", 1, 5)]
[TestCase("Hawaii Five-0 (2010) - 1x05 - Title", "Hawaii Five-0 (2010)", 1, 5)]
2011-08-02 05:10:05 +00:00
[TestCase("House - S06E13 - 5 to 9 [DVD] ", " House ", 6, 13)]
2011-09-07 06:43:10 +00:00
[TestCase("The Mentalist - S02E21 - 18-5-4", "The Mentalist", 2, 21)]
[TestCase("Breaking.In.S01E07.21.0.Jump.Street.720p.WEB-DL.DD5.1.h.264-KiNGS", "Breaking In", 1, 7)]
2011-09-18 19:59:23 +00:00
[TestCase("CSI525", "CSI", 5, 25)]
2011-10-25 06:14:55 +00:00
[TestCase("King of the Hill - 10x12 - 24 Hour Propane People [SDTV] ", " King of the Hill ", 10, 12)]
2012-02-05 06:34:36 +00:00
[TestCase("Brew Masters S01E06 3 Beers For Batali DVDRip XviD SPRiNTER", "Brew Masters", 1, 6)]
2011-12-17 01:58:19 +00:00
[TestCase("24 7 Flyers Rangers Road to the NHL Winter Classic Part01 720p HDTV x264 ORENJI", "24 7 Flyers Rangers Road to the NHL Winter Classic", 1, 1)]
[TestCase("24 7 Flyers Rangers Road to the NHL Winter Classic Part 02 720p HDTV x264 ORENJI", "24 7 Flyers Rangers Road to the NHL Winter Classic", 1, 2)]
2011-12-17 04:10:15 +00:00
[TestCase("24-7 Flyers-Rangers- Road to the NHL Winter Classic - S01E01 - Part 1", "24 7 Flyers Rangers Road to the NHL Winter Classic", 1, 1)]
2011-12-17 01:58:19 +00:00
[TestCase("The.Kennedys.Part.2.DSR.XviD-SYS", "The Kennedys", 1, 2)]
[TestCase("the-pacific-e07-720p", "The Pacific", 1, 7)]
2012-01-17 03:18:19 +00:00
[TestCase("S6E02-Unwrapped-(Playing With Food) - [DarkData] ", " ", 6, 2)]
[TestCase("S06E03-Unwrapped-(Number Ones Unwrapped) - [DarkData] ", " ", 6, 3)]
2012-01-31 19:47:13 +00:00
[TestCase("The Mentalist S02E21 18 5 4 720p WEB DL DD5 1 h 264 EbP", "The Mentalist", 2, 21)]
2012-02-15 20:17:10 +00:00
[TestCase("01x04 - Halloween, Part 1 - 720p WEB-DL", "", 1, 4)]
2012-02-22 07:08:08 +00:00
[TestCase("extras.s03.e05.ws.dvdrip.xvid-m00tv", "Extras", 3, 5)]
2012-02-22 16:23:25 +00:00
[TestCase("castle.2009.416.hdtv-lol", "Castle 2009", 4, 16)]
[TestCase("hawaii.five-0.2010.217.hdtv-lol", "Hawaii Five-0 (2010)", 2, 17)]
2012-03-17 02:17:36 +00:00
[TestCase("Looney Tunes - S1936E18 - I Love to Singa", "Looney Tunes", 1936, 18)]
2012-04-25 22:43:30 +00:00
[TestCase("American_Dad!_-_7x6_-_The_Scarlett_Getter_[SDTV] ", " American Dad ! ", 7, 6)]
2013-01-01 03:45:57 +00:00
[TestCase("Falling_Skies_-_1x1_-_Live_and_Learn_[HDTV-720p] ", " Falling Skies ", 1, 1)]
2012-05-14 23:21:31 +00:00
[TestCase("Top Gear - 07x03 - 2005.11.70", "Top Gear", 7, 3)]
2012-05-30 15:10:43 +00:00
[TestCase("Hatfields and McCoys 2012 Part 1 REPACK 720p HDTV x264 2HD", "Hatfields and McCoys 2012", 1, 1)]
2012-12-13 16:43:25 +00:00
[TestCase("Glee.S04E09.Swan.Song.1080p.WEB-DL.DD5.1.H.264-ECI", "Glee", 4, 9)]
2012-12-21 01:38:54 +00:00
[TestCase("S08E20 50-50 Carla [DVD] ", " ", 8, 20)]
[TestCase("Cheers S08E20 50-50 Carla [DVD] ", " Cheers ", 8, 20)]
[TestCase("S02E10 6-50 to SLC [SDTV] ", " ", 2, 10)]
[TestCase("Franklin & Bash S02E10 6-50 to SLC [SDTV] ", " Franklin & Bash ", 2, 10)]
2013-01-06 21:13:46 +00:00
[TestCase("The_Big_Bang_Theory_-_6x12_-_The_Egg_Salad_Equivalency_[HDTV-720p] ", " The Big Bang Theory ", 6, 12)]
2013-03-04 00:09:43 +00:00
[TestCase("Top_Gear.19x06.720p_HDTV_x264-FoV", "Top Gear", 19, 6)]
2013-03-05 06:50:42 +00:00
[TestCase("Portlandia.S03E10.Alexandra.720p.WEB-DL.AAC2.0.H.264-CROM.mkv", "Portlandia", 3, 10)]
2011-06-29 23:31:16 +00:00
public void ParseTitle_single ( string postTitle , string title , int seasonNumber , int episodeNumber )
2011-04-22 22:23:29 +00:00
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2012-01-31 19:47:13 +00:00
result . Should ( ) . NotBeNull ( ) ;
2011-11-24 07:35:37 +00:00
result . EpisodeNumbers . Should ( ) . HaveCount ( 1 ) ;
2011-06-29 23:31:16 +00:00
result . SeasonNumber . Should ( ) . Be ( seasonNumber ) ;
2011-11-24 07:35:37 +00:00
result . EpisodeNumbers . First ( ) . Should ( ) . Be ( episodeNumber ) ;
2013-04-15 01:41:39 +00:00
result . SeriesTitle . Should ( ) . Be ( Parser . Parser . NormalizeTitle ( title ) ) ;
2011-04-22 22:23:29 +00:00
}
2011-06-02 21:06:46 +00:00
[TestCase(@"z:\tv shows\battlestar galactica (2003)\Season 3\S03E05 - Collaborators.mkv", 3, 5)]
[TestCase(@"z:\tv shows\modern marvels\Season 16\S16E03 - The Potato.mkv", 16, 3)]
[TestCase(@"z:\tv shows\robot chicken\Specials\S00E16 - Dear Consumer - SD TV.avi", 0, 16)]
[TestCase(@"D:\shares\TV Shows\Parks And Recreation\Season 2\S02E21 - 94 Meetings - 720p TV.mkv", 2, 21)]
[TestCase(@"D:\shares\TV Shows\Battlestar Galactica (2003)\Season 2\S02E21.avi", 2, 21)]
2011-07-06 07:36:49 +00:00
[TestCase("C:/Test/TV/Chuck.4x05.HDTV.XviD-LOL", 4, 5)]
2011-08-28 17:43:01 +00:00
[TestCase(@"P:\TV Shows\House\Season 6\S06E13 - 5 to 9 - 720p BluRay.mkv", 6, 13)]
2011-10-20 21:30:45 +00:00
[TestCase(@"S:\TV Drop\House - 10x11 - Title [SDTV] \ 1011 - Title . avi ", 10, 11)]
2011-10-25 06:14:55 +00:00
[TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV] \ 1012 - 24 Hour Propane People . avi ", 10, 12)]
2011-11-24 07:35:37 +00:00
[TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV] \ Hour Propane People . avi ", 10, 12)]
2011-06-29 23:31:16 +00:00
public void PathParse_tests ( string path , int season , int episode )
2010-10-24 07:46:58 +00:00
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParsePath ( path ) ;
2011-06-02 21:06:46 +00:00
result . EpisodeNumbers . Should ( ) . HaveCount ( 1 ) ;
2011-06-29 23:31:16 +00:00
result . SeasonNumber . Should ( ) . Be ( season ) ;
result . EpisodeNumbers [ 0 ] . Should ( ) . Be ( episode ) ;
2011-11-24 07:35:37 +00:00
ExceptionVerification . IgnoreWarns ( ) ;
2010-10-24 07:46:58 +00:00
}
2012-01-20 07:08:05 +00:00
[Test]
2012-02-05 06:34:36 +00:00
public void unparsable_path_should_report_the_path ( )
2012-01-20 07:08:05 +00:00
{
2013-04-15 01:41:39 +00:00
Parser . Parser . ParsePath ( "C:\\" ) . Should ( ) . BeNull ( ) ;
2013-04-07 19:01:24 +00:00
2012-02-05 06:34:36 +00:00
MockedRestProvider . Verify ( c = > c . PostData ( It . IsAny < string > ( ) , It . IsAny < ParseErrorReport > ( ) ) , Times . Exactly ( 2 ) ) ;
2012-01-20 07:08:05 +00:00
ExceptionVerification . IgnoreWarns ( ) ;
}
[Test]
2012-02-05 06:34:36 +00:00
public void unparsable_title_should_report_title ( )
2012-01-20 07:08:05 +00:00
{
2012-02-05 06:34:36 +00:00
const string TITLE = "SOMETHING" ;
2013-04-15 01:41:39 +00:00
Parser . Parser . ParseTitle ( TITLE ) . Should ( ) . BeNull ( ) ;
2012-02-05 06:34:36 +00:00
MockedRestProvider . Verify ( c = > c . PostData ( It . IsAny < string > ( ) , It . Is < ParseErrorReport > ( r = > r . Title = = TITLE ) ) , Times . Once ( ) ) ;
2012-01-20 07:08:05 +00:00
ExceptionVerification . IgnoreWarns ( ) ;
}
2012-02-28 06:53:31 +00:00
//[Timeout(1000)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1 , 2 , 3 , 4 , 5 , 6 } ) ]
[TestCase("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Men", 1, new[] { 3 , 4 } ) ]
[TestCase("Weeds.S03E01.S03E02.720p.HDTV.X264-DIMENSION", "Weeds", 3, new[] { 1 , 2 } ) ]
[TestCase("The Borgias S01e01 e02 ShoHD On Demand 1080i DD5 1 ALANiS", "The Borgias", 1, new[] { 1 , 2 } ) ]
[TestCase("White.Collar.2x04.2x05.720p.BluRay-FUTV", "White.Collar", 2, new[] { 4 , 5 } ) ]
[TestCase("Desperate.Housewives.S07E22E23.720p.HDTV.X264-DIMENSION", "Desperate.Housewives", 7, new[] { 22 , 23 } ) ]
2013-01-01 03:45:57 +00:00
[TestCase("Desparate Housewives - S07E22 - S07E23 - And Lots of Security.. [HDTV-720p] . mkv ", " Desparate Housewives ", 7, new[] { 22, 23 })]
2012-02-28 07:31:40 +00:00
[TestCase("S03E01.S03E02.720p.HDTV.X264-DIMENSION", "", 3, new[] { 1 , 2 } ) ]
2013-01-01 03:45:57 +00:00
[TestCase("Desparate Housewives - S07E22 - 7x23 - And Lots of Security.. [HDTV-720p] . mkv ", " Desparate Housewives ", 7, new[] { 22, 23 })]
[TestCase("S07E22 - 7x23 - And Lots of Security.. [HDTV-720p] . mkv ", " ", 7, new[] { 22, 23 })]
2012-02-28 06:53:31 +00:00
[TestCase("2x04x05.720p.BluRay-FUTV", "", 2, new[] { 4 , 5 } ) ]
[TestCase("S02E04E05.720p.BluRay-FUTV", "", 2, new[] { 4 , 5 } ) ]
2013-04-07 19:01:24 +00:00
[TestCase("S02E03-04-05.720p.BluRay-FUTV", "", 2, new[] { 3 , 4 , 5 } ) ]
2012-05-02 15:08:09 +00:00
[TestCase("Breakout.Kings.S02E09-E10.HDTV.x264-ASAP", "Breakout Kings", 2, new[] { 9 , 10 } ) ]
[TestCase("Breakout Kings - 2x9-2x10 - Served Cold [SDTV] ", " Breakout Kings ", 2, new[] { 9, 10 })]
[TestCase("Breakout Kings - 2x09-2x10 - Served Cold [SDTV] ", " Breakout Kings ", 2, new[] { 9, 10 })]
2012-10-10 21:13:33 +00:00
[TestCase("Hell on Wheels S02E09 E10 HDTV x264 EVOLVE", "Hell on Wheels", 2, new[] { 9 , 10 } ) ]
[TestCase("Hell.on.Wheels.S02E09-E10.720p.HDTV.x264-EVOLVE", "Hell on Wheels", 2, new[] { 9 , 10 } ) ]
2012-02-28 06:53:31 +00:00
public void TitleParse_multi ( string postTitle , string title , int season , int [ ] episodes )
2011-04-05 06:33:24 +00:00
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2011-06-29 23:31:16 +00:00
result . SeasonNumber . Should ( ) . Be ( season ) ;
2012-02-28 06:53:31 +00:00
result . EpisodeNumbers . Should ( ) . BeEquivalentTo ( episodes ) ;
2013-04-15 01:41:39 +00:00
result . SeriesTitle . Should ( ) . Be ( Parser . Parser . NormalizeTitle ( title ) ) ;
2011-04-05 06:33:24 +00:00
}
2011-07-06 07:36:49 +00:00
2011-06-02 21:06:46 +00:00
[TestCase("Conan 2011 04 18 Emma Roberts HDTV XviD BFF", "Conan", 2011, 04, 18)]
[TestCase("The Tonight Show With Jay Leno 2011 04 15 1080i HDTV DD5 1 MPEG2 TrollHD", "The Tonight Show With Jay Leno", 2011, 04, 15)]
[TestCase("The.Daily.Show.2010.10.11.Johnny.Knoxville.iTouch-MW", "The.Daily.Show", 2010, 10, 11)]
[TestCase("The Daily Show - 2011-04-12 - Gov. Deval Patrick", "The.Daily.Show", 2011, 04, 12)]
[TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)]
[TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)]
2011-06-18 06:22:54 +00:00
[TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 6, 16)]
2013-04-07 19:01:24 +00:00
[TestCase("2020.NZ.2012.16.02.PDTV.XviD-C4TV", "2020nz", 2012, 2, 16)]
[TestCase("2020.NZ.2012.13.02.PDTV.XviD-C4TV", "2020nz", 2012, 2, 13)]
[TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV", "2020nz", 2011, 12, 2)]
2011-11-24 08:12:24 +00:00
public void parse_daily_episodes ( string postTitle , string title , int year , int month , int day )
2011-04-20 02:59:28 +00:00
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2011-04-20 02:59:28 +00:00
var airDate = new DateTime ( year , month , day ) ;
2012-02-24 07:31:15 +00:00
result . Should ( ) . NotBeNull ( ) ;
2013-04-15 01:41:39 +00:00
result . SeriesTitle . Should ( ) . Be ( Parser . Parser . NormalizeTitle ( title ) ) ;
2011-06-29 23:31:16 +00:00
result . AirDate . Should ( ) . Be ( airDate ) ;
2012-01-20 06:35:10 +00:00
result . EpisodeNumbers . Should ( ) . BeNull ( ) ;
2011-04-20 02:59:28 +00:00
}
2011-04-05 06:33:24 +00:00
2013-04-28 20:08:25 +00:00
[TestCase("Conan {year} {day} {month} Emma Roberts HDTV XviD BFF")]
[TestCase("The Tonight Show With Jay Leno {year} {day} {month} 1080i HDTV DD5 1 MPEG2 TrollHD")]
[TestCase("The.Daily.Show.{year}.{day}.{month}.Johnny.Knoxville.iTouch-MW")]
[TestCase("The Daily Show - {year}-{day}-{month} - Gov. Deval Patrick")]
[TestCase("{year}.{day}.{month} - Denis Leary - HD TV.mkv")]
[TestCase("The Tonight Show with Jay Leno - {year}-{day}-{month} - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo")]
[TestCase("2020.NZ.{year}.{day}.{month}.PDTV.XviD-C4TV")]
public void should_not_accept_ancient_daily_series ( string title )
{
var yearTooLow = title . Expand ( new { year = 1950 , month = 10 , day = 14 } ) ;
Parser . Parser . ParseTitle ( yearTooLow ) . Should ( ) . BeNull ( ) ;
}
[TestCase("Conan {year} {day} {month} Emma Roberts HDTV XviD BFF")]
[TestCase("The Tonight Show With Jay Leno {year} {day} {month} 1080i HDTV DD5 1 MPEG2 TrollHD")]
[TestCase("The.Daily.Show.{year}.{day}.{month}.Johnny.Knoxville.iTouch-MW")]
[TestCase("The Daily Show - {year}-{day}-{month} - Gov. Deval Patrick")]
[TestCase("{year}.{day}.{month} - Denis Leary - HD TV.mkv")]
[TestCase("The Tonight Show with Jay Leno - {year}-{day}-{month} - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo")]
[TestCase("2020.NZ.{year}.{day}.{month}.PDTV.XviD-C4TV")]
public void should_not_accept_future_dates ( string title )
{
var twoDaysFromNow = DateTime . Now . AddDays ( 2 ) ;
var validDate = title . Expand ( new { year = twoDaysFromNow . Year , month = twoDaysFromNow . Month , day = twoDaysFromNow . Day } ) ;
Parser . Parser . ParseTitle ( validDate ) . Should ( ) . BeNull ( ) ;
}
2011-11-24 08:12:24 +00:00
[Test]
public void parse_daily_should_fail_if_episode_is_far_in_future ( )
{
2011-11-30 08:29:31 +00:00
var title = string . Format ( "{0:yyyy.MM.dd} - Denis Leary - HD TV.mkv" , DateTime . Now . AddDays ( 2 ) ) ;
2011-11-24 08:12:24 +00:00
2013-04-15 01:41:39 +00:00
Parser . Parser . ParseTitle ( title ) . Should ( ) . BeNull ( ) ;
2011-11-24 08:12:24 +00:00
}
2011-07-06 07:36:49 +00:00
2011-06-02 21:06:46 +00:00
[TestCase("30.Rock.Season.04.HDTV.XviD-DIMENSION", "30.Rock", 4)]
[TestCase("Parks.and.Recreation.S02.720p.x264-DIMENSION", "Parks.and.Recreation", 2)]
[TestCase("The.Office.US.S03.720p.x264-DIMENSION", "The.Office.US", 3)]
2011-12-09 06:45:49 +00:00
[TestCase(@"Sons.of.Anarchy.S03.720p.BluRay-CLUE\REWARD", "Sons.of.Anarchy", 3)]
2012-11-26 07:13:55 +00:00
[TestCase("Adventure Time S02 720p HDTV x264 CRON", "Adventure Time", 2)]
2011-04-26 15:26:41 +00:00
public void full_season_release_parse ( string postTitle , string title , int season )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2011-06-29 23:31:16 +00:00
result . SeasonNumber . Should ( ) . Be ( season ) ;
2013-04-15 01:41:39 +00:00
result . SeriesTitle . Should ( ) . Be ( Parser . Parser . NormalizeTitle ( title ) ) ;
2013-04-28 19:46:13 +00:00
result . EpisodeNumbers . Length . Should ( ) . Be ( 0 ) ;
2011-12-09 06:45:49 +00:00
result . FullSeason . Should ( ) . BeTrue ( ) ;
2011-04-26 15:26:41 +00:00
}
2011-07-06 07:36:49 +00:00
2011-06-02 21:06:46 +00:00
[TestCase("Conan", "conan")]
[TestCase("The Tonight Show With Jay Leno", "tonightshowwithjayleno")]
[TestCase("The.Daily.Show", "dailyshow")]
[TestCase("Castle (2009)", "castle2009")]
[TestCase("Parenthood.2010", "parenthood2010")]
2011-04-23 08:04:30 +00:00
public void series_name_normalize ( string parsedSeriesName , string seriesName )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . NormalizeTitle ( parsedSeriesName ) ;
2011-06-29 23:31:16 +00:00
result . Should ( ) . Be ( seriesName ) ;
2011-04-23 08:04:30 +00:00
}
2011-06-02 21:06:46 +00:00
[TestCase("CaPitAl", "capital")]
[TestCase("peri.od", "period")]
[TestCase("this.^&%^**$%@#$!That", "thisthat")]
2011-06-25 01:20:52 +00:00
[TestCase("test/test", "testtest")]
2011-08-02 05:10:05 +00:00
[TestCase("90210", "90210")]
[TestCase("24", "24")]
2011-04-22 22:23:29 +00:00
public void Normalize_Title ( string dirty , string clean )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . NormalizeTitle ( dirty ) ;
2011-06-29 23:31:16 +00:00
result . Should ( ) . Be ( clean ) ;
2011-04-22 22:23:29 +00:00
}
2011-06-02 21:06:46 +00:00
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]
[TestCase("a")]
[TestCase("an")]
[TestCase("of")]
2011-04-22 22:23:29 +00:00
public void Normalize_removed_common_words ( string word )
{
var dirtyFormat = new [ ]
{
"word.{0}.word" ,
"word {0} word" ,
"word-{0}-word" ,
"{0}.word.word" ,
"{0}-word-word" ,
"{0} word word" ,
"word.word.{0}" ,
"word-word-{0}" ,
"word-word {0}" ,
} ;
foreach ( var s in dirtyFormat )
{
var dirty = String . Format ( s , word ) ;
2013-04-15 01:41:39 +00:00
Parser . Parser . NormalizeTitle ( dirty ) . Should ( ) . Be ( "wordword" ) ;
2011-04-22 22:23:29 +00:00
}
}
2011-06-02 21:06:46 +00:00
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]
[TestCase("a")]
[TestCase("an")]
[TestCase("of")]
2011-04-22 22:23:29 +00:00
public void Normalize_not_removed_common_words_in_the_middle ( string word )
{
var dirtyFormat = new [ ]
{
"word.{0}word" ,
"word {0}word" ,
"word-{0}word" ,
"word{0}.word" ,
"word{0}-word" ,
"word{0}-word" ,
} ;
foreach ( var s in dirtyFormat )
{
var dirty = String . Format ( s , word ) ;
2013-04-15 01:41:39 +00:00
Parser . Parser . NormalizeTitle ( dirty ) . Should ( ) . Be ( ( "word" + word . ToLower ( ) + "word" ) ) ;
2011-04-22 22:23:29 +00:00
}
}
2011-06-23 00:19:19 +00:00
[TestCase("Chuck - 4x05 - Title", "Chuck")]
[TestCase("Law & Order - 4x05 - Title", "laworder")]
2011-12-10 18:54:16 +00:00
[TestCase("Bad Format", "badformat")]
2011-11-18 08:10:30 +00:00
[TestCase("Mad Men - Season 1 [Bluray720p] ", " madmen ")]
[TestCase("Mad Men - Season 1 [Bluray1080p] ", " madmen ")]
2011-12-10 18:54:16 +00:00
[TestCase("The Daily Show With Jon Stewart -", "dailyshowwithjonstewart")]
2012-01-12 16:41:58 +00:00
[TestCase("The Venture Bros. (2004)", "venturebros2004")]
[TestCase("Castle (2011)", "castle2011")]
2012-11-26 07:13:55 +00:00
[TestCase("Adventure Time S02 720p HDTV x264 CRON", "adventuretime")]
2011-06-23 00:19:19 +00:00
public void parse_series_name ( string postTitle , string title )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseSeriesName ( postTitle ) ;
result . Should ( ) . Be ( Parser . Parser . NormalizeTitle ( title ) ) ;
2011-06-23 00:19:19 +00:00
}
2013-04-15 01:41:39 +00:00
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", Language.English)]
[TestCase("Castle.2009.S01E14.French.HDTV.XviD-LOL", Language.French)]
[TestCase("Castle.2009.S01E14.Spanish.HDTV.XviD-LOL", Language.Spanish)]
[TestCase("Castle.2009.S01E14.German.HDTV.XviD-LOL", Language.German)]
[TestCase("Castle.2009.S01E14.Germany.HDTV.XviD-LOL", Language.English)]
[TestCase("Castle.2009.S01E14.Italian.HDTV.XviD-LOL", Language.Italian)]
[TestCase("Castle.2009.S01E14.Danish.HDTV.XviD-LOL", Language.Danish)]
[TestCase("Castle.2009.S01E14.Dutch.HDTV.XviD-LOL", Language.Dutch)]
[TestCase("Castle.2009.S01E14.Japanese.HDTV.XviD-LOL", Language.Japanese)]
[TestCase("Castle.2009.S01E14.Cantonese.HDTV.XviD-LOL", Language.Cantonese)]
[TestCase("Castle.2009.S01E14.Mandarin.HDTV.XviD-LOL", Language.Mandarin)]
[TestCase("Castle.2009.S01E14.Korean.HDTV.XviD-LOL", Language.Korean)]
[TestCase("Castle.2009.S01E14.Russian.HDTV.XviD-LOL", Language.Russian)]
[TestCase("Castle.2009.S01E14.Polish.HDTV.XviD-LOL", Language.Polish)]
[TestCase("Castle.2009.S01E14.Vietnamese.HDTV.XviD-LOL", Language.Vietnamese)]
[TestCase("Castle.2009.S01E14.Swedish.HDTV.XviD-LOL", Language.Swedish)]
[TestCase("Castle.2009.S01E14.Norwegian.HDTV.XviD-LOL", Language.Norwegian)]
[TestCase("Castle.2009.S01E14.Finnish.HDTV.XviD-LOL", Language.Finnish)]
[TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", Language.Turkish)]
[TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", Language.Portuguese)]
[TestCase("Castle.2009.S01E14.HDTV.XviD-LOL", Language.English)]
[TestCase("person.of.interest.1x19.ita.720p.bdmux.x264-novarip", Language.Italian)]
[TestCase("Salamander.S01E01.FLEMISH.HDTV.x264-BRiGAND", Language.Flemish)]
[TestCase("H.Polukatoikia.S03E13.Greek.PDTV.XviD-Ouzo", Language.Greek)]
[TestCase("Burn.Notice.S04E15.Brotherly.Love.GERMAN.DUBBED.WS.WEBRiP.XviD.REPACK-TVP", Language.German)]
public void parse_language ( string postTitle , Language language )
2011-06-23 00:19:19 +00:00
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2013-04-07 22:40:13 +00:00
result . Language . Should ( ) . Be ( language ) ;
2011-06-23 00:19:19 +00:00
}
2011-08-27 05:37:20 +00:00
[TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)]
[TestCase("30 Rock S03 WS PDTV XviD FUtV", "30 Rock", 3)]
[TestCase("The Office Season 4 WS PDTV XviD FUtV", "The Office", 4)]
[TestCase("Eureka Season 1 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)]
[TestCase("The Office Season4 WS PDTV XviD FUtV", "The Office", 4)]
[TestCase("Eureka S 01 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)]
2011-09-20 04:29:04 +00:00
[TestCase("Doctor Who Confidential Season 3", "Doctor Who Confidential", 3)]
2011-06-23 00:19:19 +00:00
public void parse_season_info ( string postTitle , string seriesName , int seasonNumber )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2011-06-23 00:19:19 +00:00
2013-04-15 01:41:39 +00:00
result . SeriesTitle . Should ( ) . Be ( Parser . Parser . NormalizeTitle ( seriesName ) ) ;
2011-06-29 23:31:16 +00:00
result . SeasonNumber . Should ( ) . Be ( seasonNumber ) ;
2011-08-27 05:37:20 +00:00
result . FullSeason . Should ( ) . BeTrue ( ) ;
2011-06-23 01:17:42 +00:00
}
2011-09-14 02:25:33 +00:00
2011-09-20 00:13:19 +00:00
[TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER")]
[TestCase("Punky Brewster S01 EXTRAS DVDRip XviD RUNNER")]
[TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV")]
public void parse_season_extras ( string postTitle )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2011-09-20 00:13:19 +00:00
result . Should ( ) . BeNull ( ) ;
}
2011-09-26 01:00:21 +00:00
[TestCase("Lie.to.Me.S03.SUBPACK.DVDRip.XviD-REWARD")]
[TestCase("The.Middle.S02.SUBPACK.DVDRip.XviD-REWARD")]
[TestCase("CSI.S11.SUBPACK.DVDRip.XviD-REWARD")]
public void parse_season_subpack ( string postTitle )
{
2013-04-15 01:41:39 +00:00
var result = Parser . Parser . ParseTitle ( postTitle ) ;
2011-09-26 01:00:21 +00:00
result . Should ( ) . BeNull ( ) ;
}
2011-11-24 08:12:24 +00:00
2012-02-01 01:17:42 +00:00
[TestCase("Fussball Bundesliga 10e2011e30 Spieltag FC Bayern Muenchen vs Bayer 04 Leverkusen German WS dTV XviD WoGS")]
2011-11-24 08:12:24 +00:00
public void unparsable_should_log_error_but_not_throw ( string title )
{
2013-04-15 01:41:39 +00:00
Parser . Parser . ParseTitle ( title ) ;
2011-11-24 08:12:24 +00:00
ExceptionVerification . IgnoreWarns ( ) ;
2011-12-20 00:58:26 +00:00
ExceptionVerification . ExpectedErrors ( 1 ) ;
2011-11-24 08:12:24 +00:00
}
2012-08-03 07:01:34 +00:00
2012-10-15 02:21:12 +00:00
[TestCase("[112461] - [ FULL ] - [ # a . b . teevee @EFNet ] - [ 666. Park . Avenue . S01E03 . 720 p . HDTV . X264 - DIMENSION ] - [ 02 / 31 ] - \ "the.devils.address.103.720p-dimension.par2\" yEnc" , "666.Park.Avenue.S01E03.720p.HDTV.X264-DIMENSION" ) ]
[TestCase("[112438] - [ FULL ] - [ # a . b . teevee @EFNet ] - [ Downton_Abbey . 3 x05 . HDTV_x264 - FoV ] - [ 01 / 26 ] - \ "downton_abbey.3x05.hdtv_x264-fov.nfo\" yEnc" , "Downton_Abbey.3x05.HDTV_x264-FoV" ) ]
2013-01-09 08:15:06 +00:00
[TestCase("[ 21154 ] - [ TrollHD ] - [ 00 / 73 ] - \ "MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb\" yEnc" , "MythBusters S03E20 Escape Slide Parachute 1080i HDTV-UPSCALE DD5.1 MPEG2-TrollHD.nzb" ) ]
2012-10-15 02:21:12 +00:00
public void parse_header ( string title , string expected )
{
2013-04-07 22:40:13 +00:00
BasicRssParser . ParseHeader ( title ) . Should ( ) . Be ( expected ) ;
2012-10-15 02:21:12 +00:00
}
2012-12-20 23:29:14 +00:00
[TestCase("password - \"bdc435cb-93c4-4902-97ea-ca00568c3887.337\" yEnc")]
public void should_not_parse_encypted_posts ( string title )
{
2013-04-15 01:41:39 +00:00
Parser . Parser . ParseTitle ( title ) . Should ( ) . BeNull ( ) ;
2012-12-20 23:29:14 +00:00
ExceptionVerification . IgnoreWarns ( ) ;
}
2013-04-28 20:08:25 +00:00
[TestCase("76El6LcgLzqb426WoVFg1vVVVGx4uCYopQkfjmLe")]
[TestCase("Vrq6e1Aba3U amCjuEgV5R2QvdsLEGYF3YQAQkw8")]
[TestCase("TDAsqTea7k4o6iofVx3MQGuDK116FSjPobMuh8oB")]
[TestCase("yp4nFodAAzoeoRc467HRh1mzuT17qeekmuJ3zFnL")]
[TestCase("oxXo8S2272KE1 lfppvxo3iwEJBrBmhlQVK1gqGc")]
[TestCase("dPBAtu681Ycy3A4NpJDH6kNVQooLxqtnsW1Umfiv")]
public void should_not_parse_crap ( string title )
{
Parser . Parser . ParseTitle ( title ) . Should ( ) . BeNull ( ) ;
ExceptionVerification . IgnoreWarns ( ) ;
}
2010-10-24 07:46:58 +00:00
}
2011-10-25 06:22:34 +00:00
}