2020-05-02 19:11:00 +00:00
using System.Linq ;
2018-03-14 20:41:36 +00:00
using FluentAssertions ;
2020-04-01 20:47:51 +00:00
using FluentAssertions.Execution ;
2011-06-02 21:06:46 +00:00
using NUnit.Framework ;
2020-05-02 19:11:00 +00:00
using NzbDrone.Core.Languages ;
2013-04-15 01:41:39 +00:00
using NzbDrone.Core.Parser ;
2020-04-01 20:47:51 +00:00
using NzbDrone.Core.Parser.Model ;
2011-05-19 03:55:35 +00:00
using NzbDrone.Core.Test.Framework ;
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
{
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 ) ]
2013-06-19 15:44:41 +00:00
* ( Game of Thrones s03 e - "Game of Thrones Season 3 Episode 10"
2013-11-01 06:15:15 +00:00
* The . Man . of . Steel . 1994 - 05.33 . hybrid . DreamGirl - Novus - HD
* Superman . - . The . Man . of . Steel . 1994 - 06.34 . hybrid . DreamGirl - Novus - HD
* Superman . - . The . Man . of . Steel . 1994 - 05.33 . hybrid . DreamGirl - Novus - HD
2014-11-03 15:26:27 +00:00
* Constantine S1 - E1 - WEB - DL - 1080 p - NZBgeek
2011-04-05 06:33:24 +00:00
* /
2014-08-11 14:19:02 +00:00
[Test]
public void should_remove_accents_from_title ( )
{
2015-11-10 22:24:41 +00:00
const string title = "Carniv\u00E0le" ;
2014-10-21 21:51:38 +00:00
2018-08-05 14:28:05 +00:00
title . CleanSeriesTitle ( ) . Should ( ) . Be ( "carnivale" ) ;
2014-08-12 05:11:06 +00:00
}
2017-02-10 18:00:16 +00:00
2017-06-17 13:02:58 +00:00
//Note: This assumes extended language parser is activated
2019-12-22 21:24:10 +00:00
[TestCase("The.Man.from.U.N.C.L.E.2015.1080p.BluRay.x264-SPARKS", "The Man from U.N.C.L.E.")]
[TestCase("1941.1979.EXTENDED.720p.BluRay.X264-AMIABLE", "1941")]
[TestCase("MY MOVIE (2016) [R] [ Action , Horror ] [ 720 p . WEB - DL . AVC . 8 Bit . 6 ch . AC3 ] . mkv ", " MY MOVIE ")]
[TestCase("R.I.P.D.2013.720p.BluRay.x264-SPARKS", "R.I.P.D.")]
[TestCase("V.H.S.2.2013.LIMITED.720p.BluRay.x264-GECKOS", "V.H.S. 2")]
[TestCase("This Is A Movie (1999) [IMDB #] < Genre , Genre , Genre > { ACTORS } ! DIRECTOR + MORE_SILLY_STUFF_NO_ONE_NEEDS ? ", " This Is A Movie ")]
[TestCase("We Are the Best!.2013.720p.H264.mkv", "We Are the Best!")]
[TestCase("(500).Days.Of.Summer.(2009).DTS.1080p.BluRay.x264.NLsubs", "(500) Days Of Summer")]
[TestCase("To.Live.and.Die.in.L.A.1985.1080p.BluRay", "To Live and Die in L.A.")]
[TestCase("A.I.Artificial.Intelligence.(2001)", "A.I. Artificial Intelligence")]
[TestCase("A.Movie.Name.(1998)", "A Movie Name")]
2018-12-07 10:22:06 +00:00
[TestCase("www.Torrenting.com - Revenge.2008.720p.X264-DIMENSION", "Revenge")]
[TestCase("Thor: The Dark World 2013", "Thor The Dark World")]
2017-05-02 20:15:03 +00:00
[TestCase("Resident.Evil.The.Final.Chapter.2016", "Resident Evil The Final Chapter")]
2017-06-17 13:02:58 +00:00
[TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", "Der Soldat James")]
[TestCase("Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO", "Passengers")]
[TestCase("Valana la Legende FRENCH BluRay 720p 2016 kjhlj", "Valana la Legende")]
[TestCase("Valana la Legende TRUEFRENCH BluRay 720p 2016 kjhlj", "Valana la Legende")]
[TestCase("Mission Impossible: Rogue Nation (2015)<29> [XviD - Ita Ac3 - SoftSub Ita] azione , spionaggio , thriller * Prima Visione * Team mulnic Tom Cruise ", " Mission Impossible Rogue Nation ")]
2019-12-22 21:24:10 +00:00
[TestCase("Scary.Movie.2000.FRENCH..BluRay.-AiRLiNE", "Scary Movie")]
[TestCase("My Movie 1999 German Bluray", "My Movie")]
2018-12-30 12:55:45 +00:00
[TestCase("Leaving Jeruselem by Railway (1897) [DVD] . mp4 ", " Leaving Jeruselem by Railway ")]
2019-02-24 17:03:42 +00:00
[TestCase("Climax.2018.1080p.AMZN.WEB-DL.DD5.1.H.264-NTG", "Climax")]
[TestCase("Movie.Title.Imax.2018.1080p.AMZN.WEB-DL.DD5.1.H.264-NTG", "Movie Title")]
2020-04-01 20:47:51 +00:00
[TestCase("World.War.Z.EXTENDED.2013.German.DL.1080p.BluRay.AVC-XANOR", "World War Z")]
[TestCase("World.War.Z.2.EXTENDED.2013.German.DL.1080p.BluRay.AVC-XANOR", "World War Z 2")]
[TestCase("G.I.Joe.Retaliation.2013.THEATRiCAL.COMPLETE.BLURAY-GLiMMER", "G.I. Joe Retaliation")]
2020-05-19 21:01:21 +00:00
[TestCase("www.Torrenting.org - Revenge.2008.720p.X264-DIMENSION", "Revenge")]
2019-02-24 17:03:42 +00:00
public void should_parse_movie_title ( string postTitle , string title )
2019-12-22 21:24:10 +00:00
{
Parser . Parser . ParseMovieTitle ( postTitle , true ) . MovieTitle . Should ( ) . Be ( title ) ;
2017-08-18 22:24:41 +00:00
}
2020-04-01 20:47:51 +00:00
[TestCase("Avatar.Aufbruch.nach.Pandora.Extended.2009.German.DTS.720p.BluRay.x264-SoW", "Avatar Aufbruch nach Pandora", "Extended", 2009)]
[TestCase("Drop.Zone.1994.German.AC3D.DL.720p.BluRay.x264-KLASSiGERHD", "Drop Zone", "", 1994)]
[TestCase("Kick.Ass.2.2013.German.DTS.DL.720p.BluRay.x264-Pate", "Kick Ass 2", "", 2013)]
[TestCase("Paradise.Hills.2019.German.DL.AC3.Dubbed.1080p.BluRay.x264-muhHD", "Paradise Hills", "", 2019)]
[TestCase("96.Hours.Taken.3.EXTENDED.2014.German.DL.1080p.BluRay.x264-ENCOUNTERS", "96 Hours Taken 3", "EXTENDED", 2014)]
[TestCase("World.War.Z.EXTENDED.CUT.2013.German.DL.1080p.BluRay.x264-HQX", "World War Z", "EXTENDED CUT", 2013)]
[TestCase("Sin.City.2005.RECUT.EXTENDED.German.DL.1080p.BluRay.x264-DETAiLS", "Sin City", "RECUT EXTENDED", 2005)]
[TestCase("Die.Klasse.von.1999.1990.German.720p.HDTV.x264-NORETAiL", "Die Klasse von 1999", "", 1990)] //year in the title
[TestCase("2.Tage.in.L.A.1996.GERMAN.DL.720p.WEB.H264-SOV", "2 Tage in L.A.", "", 1996)]
[TestCase("8.2019.GERMAN.720p.BluRay.x264-UNiVERSUM", "8", "", 2019)]
[TestCase("Life.Partners.2014.German.DL.PAL.DVDR-ETM", "Life Partners", "", 2014)]
[TestCase("Joe.Dreck.2.EXTENDED.EDITION.2015.German.DL.PAL.DVDR-ETM", "Joe Dreck 2", "EXTENDED EDITION", 2015)]
[TestCase("Rango.EXTENDED.2011.HDRip.AC3.German.XviD-POE", "Rango", "EXTENDED", 2011)]
[TestCase("Suicide.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc", "Suicide Squad", "EXTENDED", 2016)] //edition after year
public void should_parse_german_movie ( string postTitle , string title , string edition , int year )
{
ParsedMovieInfo movie = Parser . Parser . ParseMovieTitle ( postTitle , false ) ;
using ( new AssertionScope ( ) )
{
movie . MovieTitle . Should ( ) . Be ( title ) ;
movie . Edition . Should ( ) . Be ( edition ) ;
movie . Year . Should ( ) . Be ( year ) ;
}
}
2020-04-02 21:40:53 +00:00
[TestCase("Avatar.Aufbruch.nach.Pandora.Extended.2009.German.DTS.720p.BluRay.x264-SoW", "Avatar Aufbruch nach Pandora", "Extended", 2009)]
[TestCase("Drop.Zone.1994.German.AC3D.DL.720p.BluRay.x264-KLASSiGERHD", "Drop Zone", "", 1994)]
[TestCase("Kick.Ass.2.2013.German.DTS.DL.720p.BluRay.x264-Pate", "Kick Ass 2", "", 2013)]
[TestCase("Paradise.Hills.2019.German.DL.AC3.Dubbed.1080p.BluRay.x264-muhHD", "Paradise Hills", "", 2019)]
[TestCase("96.Hours.Taken.3.EXTENDED.2014.German.DL.1080p.BluRay.x264-ENCOUNTERS", "96 Hours Taken 3", "EXTENDED", 2014)]
[TestCase("World.War.Z.EXTENDED.CUT.2013.German.DL.1080p.BluRay.x264-HQX", "World War Z", "EXTENDED CUT", 2013)]
[TestCase("Sin.City.2005.RECUT.EXTENDED.German.DL.1080p.BluRay.x264-DETAiLS", "Sin City", "RECUT EXTENDED", 2005)]
[TestCase("Die.Klasse.von.1999.1990.German.720p.HDTV.x264-NORETAiL", "Die Klasse von 1999", "", 1990)] //year in the title
[TestCase("2.Tage.in.L.A.1996.GERMAN.DL.720p.WEB.H264-SOV", "2 Tage in L.A.", "", 1996)]
[TestCase("8.2019.GERMAN.720p.BluRay.x264-UNiVERSUM", "8", "", 2019)]
[TestCase("Life.Partners.2014.German.DL.PAL.DVDR-ETM", "Life Partners", "", 2014)]
[TestCase("Joe.Dreck.2.EXTENDED.EDITION.2015.German.DL.PAL.DVDR-ETM", "Joe Dreck 2", "EXTENDED EDITION", 2015)]
[TestCase("Rango.EXTENDED.2011.HDRip.AC3.German.XviD-POE", "Rango", "EXTENDED", 2011)]
[TestCase("Suicide.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc", "Suicide Squad", "EXTENDED", 2016)] //edition after year
2020-04-01 20:47:51 +00:00
[TestCase("Der.Hobbit.Eine.Unerwartete.Reise.Extended.German.720p.BluRay.x264-EXQUiSiTE", "Der Hobbit Eine Unerwartete Reise", "Extended", 0)] //no year
[TestCase("Die.Unfassbaren.Now.You.See.Me.EXTENDED.German.DTS.720p.BluRay.x264-RHD", "Die Unfassbaren Now You See Me", "EXTENDED", 0)] //no year
[TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", "Der Soldat James", "", 1998)]
[TestCase("Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO", "Passengers", "", 0)] //no year
[TestCase("Das.A.Team.Der.Film.Extended.Cut.German.720p.BluRay.x264-ANCIENT", "Das A Team Der Film", "Extended Cut", 0)] //no year
[TestCase("Cars.2.German.DL.720p.BluRay.x264-EmpireHD", "Cars 2", "", 0)] //no year
[TestCase("Der.Film.deines.Lebens.German.2011.PAL.DVDR-ETM", "Der Film deines Lebens", "", 2011)] //year at wrong position
public void should_parse_german_movie_lenient ( string postTitle , string title , string edition , int year )
{
ParsedMovieInfo movie = Parser . Parser . ParseMovieTitle ( postTitle , true ) ;
using ( new AssertionScope ( ) )
{
movie . MovieTitle . Should ( ) . Be ( title ) ;
movie . Edition . Should ( ) . Be ( edition ) ;
movie . Year . Should ( ) . Be ( year ) ;
}
}
2017-08-18 22:24:41 +00:00
[TestCase("(1995) Ghost in the Shell", "Ghost in the Shell")]
public void should_parse_movie_folder_name ( string postTitle , string title )
{
Parser . Parser . ParseMovieTitle ( postTitle , true , true ) . MovieTitle . Should ( ) . Be ( title ) ;
}
2017-02-10 18:00:16 +00:00
2017-08-18 22:24:41 +00:00
[TestCase("1941.1979.EXTENDED.720p.BluRay.X264-AMIABLE", 1979)]
2017-06-17 13:02:58 +00:00
[TestCase("Valana la Legende FRENCH BluRay 720p 2016 kjhlj", 2016)]
[TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", 1998)]
2018-12-30 12:55:45 +00:00
[TestCase("Leaving Jeruselem by Railway (1897) [DVD] . mp4 ", 1897)]
2017-03-07 23:29:02 +00:00
public void should_parse_movie_year ( string postTitle , int year )
2019-12-22 21:24:10 +00:00
{
Parser . Parser . ParseMovieTitle ( postTitle , false ) . Year . Should ( ) . Be ( year ) ;
}
2017-02-22 12:40:06 +00:00
2017-04-19 19:02:01 +00:00
[TestCase("Prometheus 2012 Directors Cut", "Directors Cut")]
[TestCase("Star Wars Episode IV - A New Hope 1999 (Despecialized).mkv", "Despecialized")]
[TestCase("Prometheus.2012.(Special.Edition.Remastered).[Bluray-1080p] . mkv ", " Special Edition Remastered ")]
[TestCase("Prometheus 2012 Extended", "Extended")]
[TestCase("Prometheus 2012 Extended Directors Cut Fan Edit", "Extended Directors Cut Fan Edit")]
[TestCase("Prometheus 2012 Director's Cut", "Director's Cut")]
[TestCase("Prometheus 2012 Directors Cut", "Directors Cut")]
[TestCase("Prometheus.2012.(Extended.Theatrical.Version.IMAX).BluRay.1080p.2012.asdf", "Extended Theatrical Version IMAX")]
[TestCase("2001 A Space Odyssey (1968) Director's Cut .mkv", "Director's Cut")]
[TestCase("2001: A Space Odyssey 1968 (Extended Directors Cut FanEdit)", "Extended Directors Cut FanEdit")]
[TestCase("A Fake Movie 2035 2012 Directors.mkv", "Directors")]
[TestCase("Blade Runner 2049 Director's Cut.mkv", "Director's Cut")]
[TestCase("Prometheus 2012 50th Anniversary Edition.mkv", "50th Anniversary Edition")]
[TestCase("Movie 2012 2in1.mkv", "2in1")]
[TestCase("Movie 2012 IMAX.mkv", "IMAX")]
[TestCase("Movie 2012 Restored.mkv", "Restored")]
[TestCase("Prometheus.Special.Edition.Fan Edit.2012..BRRip.x264.AAC-m2g", "Special Edition Fan Edit")]
[TestCase("Star Wars Episode IV - A New Hope (Despecialized) 1999.mkv", "Despecialized")]
[TestCase("Prometheus.(Special.Edition.Remastered).2012.[Bluray-1080p] . mkv ", " Special Edition Remastered ")]
[TestCase("Prometheus Extended 2012", "Extended")]
[TestCase("Prometheus Extended Directors Cut Fan Edit 2012", "Extended Directors Cut Fan Edit")]
[TestCase("Prometheus Director's Cut 2012", "Director's Cut")]
[TestCase("Prometheus Directors Cut 2012", "Directors Cut")]
2017-06-17 13:02:58 +00:00
[TestCase("Prometheus.(Extended.Theatrical.Version.IMAX).2012.BluRay.1080p.asdf", "Extended Theatrical Version IMAX")]
2017-04-19 19:02:01 +00:00
[TestCase("2001 A Space Odyssey Director's Cut (1968).mkv", "Director's Cut")]
2017-06-17 13:02:58 +00:00
[TestCase("2001: A Space Odyssey (Extended Directors Cut FanEdit) 1968 Bluray 1080p", "Extended Directors Cut FanEdit")]
2017-04-19 19:02:01 +00:00
[TestCase("A Fake Movie 2035 Directors 2012.mkv", "Directors")]
[TestCase("Blade Runner Director's Cut 2049.mkv", "Director's Cut")]
[TestCase("Prometheus 50th Anniversary Edition 2012.mkv", "50th Anniversary Edition")]
[TestCase("Movie 2in1 2012.mkv", "2in1")]
[TestCase("Movie IMAX 2012.mkv", "IMAX")]
2017-05-02 20:15:03 +00:00
[TestCase("Fake Movie Final Cut 2016", "Final Cut")]
[TestCase("Fake Movie 2016 Final Cut ", "Final Cut")]
2017-06-18 21:12:14 +00:00
[TestCase("My Movie GERMAN Extended Cut 2016", "Extended Cut")]
[TestCase("My.Movie.GERMAN.Extended.Cut.2016", "Extended Cut")]
[TestCase("My.Movie.GERMAN.Extended.Cut", "Extended Cut")]
[TestCase("Mission Impossible: Rogue Nation 2012 Bluray", "")]
2019-10-31 03:46:40 +00:00
[TestCase("Loving.Pablo.2018.TS.FRENCH.MD.x264-DROGUERiE", "")]
2017-04-19 19:02:01 +00:00
public void should_parse_edition ( string postTitle , string edition )
{
2018-08-05 14:28:05 +00:00
var parsed = Parser . Parser . ParseMovieTitle ( postTitle , true ) ;
parsed . Edition . Should ( ) . Be ( edition ) ;
2017-06-18 21:12:14 +00:00
}
2020-05-02 19:11:00 +00:00
[TestCase("The.Italian.Job.2008.720p.BluRay.X264-AMIABLE")]
public void should_not_parse_wrong_language_in_title ( string postTitle )
{
var parsed = Parser . Parser . ParseMovieTitle ( postTitle , true ) ;
parsed . Languages . Count ( ) . Should ( ) . Be ( 1 ) ;
parsed . Languages . First ( ) . Should ( ) . Be ( Language . English ) ;
}
2020-06-01 02:19:18 +00:00
[TestCase("The Italian Job 2008 [tt1234567] 720 p BluRay X264 ", " tt1234567 ")]
[TestCase("The Italian Job 2008 [tt12345678] 720 p BluRay X264 ", " tt12345678 ")]
public void should_parse_imdb_in_title ( string postTitle , string imdb )
{
var parsed = Parser . Parser . ParseMovieTitle ( postTitle , true ) ;
parsed . ImdbId . Should ( ) . Be ( imdb ) ;
}
2018-09-11 21:47:00 +00:00
[TestCase("123", "tt0000123")]
[TestCase("1234567", "tt1234567")]
[TestCase("tt1234567", "tt1234567")]
[TestCase("tt12345678", "tt12345678")]
[TestCase("12345678", "tt12345678")]
public void should_normalize_imdbid ( string imdbid , string normalized )
{
Parser . Parser . NormalizeImdbId ( imdbid ) . Should ( ) . BeEquivalentTo ( normalized ) ;
}
2010-10-24 07:46:58 +00:00
}
2011-10-25 06:22:34 +00:00
}