├── go.mod ├── testdata ├── golden_file_029.json ├── golden_file_057.json ├── golden_file_060.json ├── golden_file_015.json ├── golden_file_028.json ├── golden_file_069.json ├── golden_file_051.json ├── golden_file_009.json ├── golden_file_019.json ├── golden_file_044.json ├── golden_file_080.json ├── golden_file_033.json ├── golden_file_049.json ├── golden_file_074.json ├── golden_file_001.json ├── golden_file_007.json ├── golden_file_050.json ├── golden_file_063.json ├── golden_file_004.json ├── golden_file_018.json ├── golden_file_002.json ├── golden_file_031.json ├── golden_file_042.json ├── golden_file_053.json ├── golden_file_067.json ├── golden_file_072.json ├── golden_file_073.json ├── golden_file_076.json ├── golden_file_008.json ├── golden_file_020.json ├── golden_file_022.json ├── golden_file_045.json ├── golden_file_046.json ├── golden_file_054.json ├── golden_file_077.json ├── golden_file_006.json ├── golden_file_024.json ├── golden_file_043.json ├── golden_file_003.json ├── golden_file_082.json ├── golden_file_017.json ├── golden_file_023.json ├── golden_file_025.json ├── golden_file_026.json ├── golden_file_027.json ├── golden_file_034.json ├── golden_file_039.json ├── golden_file_066.json ├── golden_file_075.json ├── golden_file_010.json ├── golden_file_014.json ├── golden_file_037.json ├── golden_file_048.json ├── golden_file_030.json ├── golden_file_041.json ├── golden_file_056.json ├── golden_file_059.json ├── golden_file_021.json ├── golden_file_032.json ├── golden_file_040.json ├── golden_file_000.json ├── golden_file_012.json ├── golden_file_038.json ├── golden_file_070.json ├── golden_file_078.json ├── golden_file_081.json ├── golden_file_068.json ├── golden_file_011.json ├── golden_file_013.json ├── golden_file_035.json ├── golden_file_036.json ├── golden_file_058.json ├── golden_file_071.json ├── golden_file_079.json ├── golden_file_005.json ├── golden_file_047.json ├── golden_file_016.json ├── golden_file_061.json ├── golden_file_062.json ├── golden_file_065.json ├── golden_file_064.json ├── golden_file_055.json └── golden_file_052.json ├── .gitignore ├── .travis.yml ├── LICENSE ├── patterns.go ├── parser.go ├── README.md └── parser_test.go /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/middelink/go-parse-torrent-name 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /testdata/golden_file_029.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Teenage Mutant Ninja Turtles", 3 | "year": 2014 4 | } -------------------------------------------------------------------------------- /testdata/golden_file_057.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Sons of Anarchy", 3 | "season": 1, 4 | "episode": 3 5 | } -------------------------------------------------------------------------------- /testdata/golden_file_060.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Game of Thrones", 3 | "season": 4, 4 | "episode": 4 5 | } -------------------------------------------------------------------------------- /testdata/golden_file_015.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Guardians of the Galaxy", 3 | "year": 2014, 4 | "quality": "CamRip" 5 | } -------------------------------------------------------------------------------- /testdata/golden_file_028.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Teenage Mutant Ninja Turtles", 3 | "year": 2014, 4 | "quality": "HdRip" 5 | } -------------------------------------------------------------------------------- /testdata/golden_file_069.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "War Dogs", 3 | "year": 2016, 4 | "quality": "HDTS", 5 | "size": "600MB" 6 | } -------------------------------------------------------------------------------- /testdata/golden_file_051.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Shaukeens", 3 | "year": 2014, 4 | "quality": "DvDScr", 5 | "codec": "x264" 6 | } -------------------------------------------------------------------------------- /testdata/golden_file_009.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "UFC 179", 3 | "quality": "PPV.HDTV", 4 | "codec": "x264", 5 | "group": "Ebi[rartv]" 6 | } -------------------------------------------------------------------------------- /testdata/golden_file_019.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "These Final Hours", 3 | "year": 2013, 4 | "quality": "WBBRip", 5 | "codec": "XViD" 6 | } -------------------------------------------------------------------------------- /testdata/golden_file_044.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "WWE Hell in a Cell", 3 | "year": 2014, 4 | "quality": "HDTV", 5 | "codec": "x264" 6 | } -------------------------------------------------------------------------------- /testdata/golden_file_080.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "2012", 3 | "year": 2009, 4 | "resolution": "1080p", 5 | "audio": "Dual Audio" 6 | } 7 | -------------------------------------------------------------------------------- /testdata/golden_file_033.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Dinosaur 13", 3 | "year": 2014, 4 | "quality": "WEBrip", 5 | "codec": "XviD", 6 | "audio": "AC3" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_049.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "One Shot [", 3 | "year": 2014, 4 | "quality": "DVDRip", 5 | "codec": "XViD", 6 | "group": "ViCKY" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_074.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Ben Hur", 3 | "year": 2016, 4 | "quality": "TELESYNC", 5 | "codec": "x264", 6 | "audio": "AC3" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_001.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Hercules", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "BrRip", 6 | "codec": "H264" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_007.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Hercules", 3 | "year": 2014, 4 | "quality": "WEBDL DVDRip", 5 | "codec": "XviD", 6 | "group": "MAX" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_050.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Shaukeens", 3 | "year": 2014, 4 | "quality": "DvDScr", 5 | "codec": "x264", 6 | "audio": "AAC" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_063.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Community", 3 | "season": 2, 4 | "episode": 20, 5 | "resolution": "720p", 6 | "language": "rus.eng" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_004.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "22 Jump Street", 3 | "year": 2014, 4 | "resolution": "720p", 5 | "quality": "BrRip", 6 | "codec": "x264" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_018.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Lets Be Cops", 3 | "year": 2014, 4 | "quality": "BRRip", 5 | "codec": "XViD", 6 | "group": "juggs[ETRG]" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_002.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Dawn of the Planet of the Apes", 3 | "year": 2014, 4 | "quality": "HDRip", 5 | "codec": "XViD", 6 | "group": "EVO" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_031.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "2047 - Sights of Death", 3 | "year": 2014, 4 | "resolution": "720p", 5 | "quality": "BrRip", 6 | "codec": "x264" 7 | } 8 | -------------------------------------------------------------------------------- /testdata/golden_file_042.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "WWE Monday Night Raw 3rd Nov", 3 | "year": 2014, 4 | "quality": "HDTV", 5 | "codec": "x264", 6 | "group": "Sir Paul" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_053.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Interstellar", 3 | "year": 2014, 4 | "quality": "CAM", 5 | "codec": "x264", 6 | "audio": "AAC", 7 | "group": "CPG" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_067.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Red Sonja Queen Of Plagues", 3 | "year": 2016, 4 | "quality": "BDRip", 5 | "codec": "x264", 6 | "group": "W4F[PRiME]" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_072.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Return To Snowy River", 3 | "year": 1988, 4 | "quality": "DVDRip", 5 | "codec": "x264", 6 | "group": "W4F[PRiME]" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_073.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Akira", 3 | "episode": 720, 4 | "year": 2016, 5 | "resolution": "720p", 6 | "codec": "x264", 7 | "audio": "AC3" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_076.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Clockwork Planet", 3 | "episode": 10, 4 | "resolution": "480p", 5 | "container": "mkv", 6 | "website": "HorribleSubs" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_008.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "WWE Hell in a Cell", 3 | "year": 2014, 4 | "quality": "PPV WEB-DL", 5 | "codec": "x264", 6 | "group": "WD -={SPARROW}=-" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_020.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Downton Abbey", 3 | "season": 5, 4 | "episode": 6, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "FoV [eztv]" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_022.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Lucy", 3 | "year": 2014, 4 | "quality": "HDRip", 5 | "codec": "XViD", 6 | "group": "juggs[ETRG]", 7 | "hardcoded": true 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_045.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Dracula Untold", 3 | "year": 2014, 4 | "quality": "TS", 5 | "codec": "XViD", 6 | "audio": "AC3", 7 | "group": "SiMPLE" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_046.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Missing", 3 | "season": 1, 4 | "episode": 1, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "FoV [eztv]" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_054.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Guardians of the Galaxy", 3 | "year": 2014, 4 | "quality": "DVDRip", 5 | "audio": "Dual Audio", 6 | "container": "AVI" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_077.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Detective Conan", 3 | "episode": 862, 4 | "resolution": "1080p", 5 | "container": "mkv", 6 | "website": "HorribleSubs" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_006.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Hercules", 3 | "year": 2014, 4 | "quality": "HDRip", 5 | "codec": "XViD", 6 | "group": "juggs[ETRG]", 7 | "extended": true 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_024.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "South Park", 3 | "season": 18, 4 | "episode": 5, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "KILLERS [eztv]" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_043.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Jack And The Cuckoo", 3 | "year": 2013, 4 | "quality": "BRRip", 5 | "codec": "XViD", 6 | "group": "Clock.Heart.2013.BRRip XViD" 7 | } -------------------------------------------------------------------------------- /testdata/golden_file_003.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Big Bang Theory", 3 | "season": 8, 4 | "episode": 6, 5 | "quality": "HDTV", 6 | "codec": "XviD", 7 | "group": "LOL [eztv]" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_082.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "2012", 3 | "year": 2009, 4 | "resolution": "720p", 5 | "quality": "BluRay", 6 | "codec": "x264", 7 | "audio": "Dual Audio" 8 | } 9 | -------------------------------------------------------------------------------- /testdata/golden_file_017.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Brave", 3 | "year": 2012, 4 | "quality": "DVDRip", 5 | "codec": "XViD", 6 | "audio": "LiNE", 7 | "group": "UNiQUE", 8 | "region": "5" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_023.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Flash", 3 | "season": 1, 4 | "episode": 4, 5 | "year": 2014, 6 | "quality": "HDTV", 7 | "codec": "x264", 8 | "group": "FUM[ettv]" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_025.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Flash", 3 | "season": 1, 4 | "episode": 3, 5 | "year": 2014, 6 | "quality": "HDTV", 7 | "codec": "x264", 8 | "group": "LOL[ettv]" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_026.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Flash", 3 | "season": 1, 4 | "episode": 1, 5 | "year": 2014, 6 | "quality": "HDTV", 7 | "codec": "x264", 8 | "group": "LOL[ettv]" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_027.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Lucy", 3 | "year": 2014, 4 | "quality": "WEBRip", 5 | "audio": "Dual-Audio", 6 | "group": "Audio WEBRip 1400Mb", 7 | "size": "1400Mb" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_034.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Teenage Mutant Ninja Turtles", 3 | "year": 2014, 4 | "quality": "HDRip", 5 | "codec": "XviD", 6 | "audio": "MP3", 7 | "group": "RARBG" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_039.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Lucy", 3 | "year": 2014, 4 | "resolution": "720p", 5 | "quality": "WEBRip", 6 | "audio": "Dual-Audio", 7 | "group": "Audio 720p WEBRip" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_066.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Ice Age Collision Course", 3 | "year": 2016, 4 | "resolution": "720p", 5 | "quality": "HDRIP", 6 | "codec": "X264", 7 | "audio": "AC3" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_075.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Secret Life of Pets", 3 | "year": 2016, 4 | "quality": "HDRiP", 5 | "codec": "x264", 6 | "audio": "AAC-LC", 7 | "group": "LEGi0N" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_010.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Marvels Agents of S H I E L D", 3 | "season": 2, 4 | "episode": 5, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "KILLERS [eztv]" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_014.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Marvels Agents of S.H.I.E.L.D.", 3 | "season": 2, 4 | "episode": 6, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "KILLERS[ettv]" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_037.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Gotham", 3 | "season": 1, 4 | "episode": 5, 5 | "quality": "WEB-DL", 6 | "codec": "x264", 7 | "audio": "AAC", 8 | "group": "DL.x264.AAC" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_048.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Gotham", 3 | "season": 1, 4 | "episode": 7, 5 | "quality": "WEB-DL", 6 | "codec": "x264", 7 | "audio": "AAC", 8 | "group": "DL.x264.AAC" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_030.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Simpsons", 3 | "season": 26, 4 | "episode": 5, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "LOL [eztv]", 8 | "proper": true 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_041.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Sin City A Dame to Kill For", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "BluRay", 6 | "codec": "x264", 7 | "group": "SPARKS" 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_056.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "WWE Monday Night Raw", 3 | "year": 2014, 4 | "quality": "PDTV", 5 | "codec": "x264", 6 | "group": "RKOFAN1990 -={SPARR", 7 | "widescreen": true 8 | } -------------------------------------------------------------------------------- /testdata/golden_file_059.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "breaking bad", 3 | "season": 1, 4 | "episode": 1, 5 | "resolution": "720p", 6 | "quality": "bluray", 7 | "codec": "x264", 8 | "group": "reward" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_021.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Annabelle", 3 | "year": 2014, 4 | "quality": "HDRip", 5 | "codec": "XViD", 6 | "audio": "AC3", 7 | "group": "juggs[ETRG]", 8 | "hardcoded": true 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_032.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Two and a Half Men", 3 | "season": 12, 4 | "episode": 1, 5 | "quality": "HDTV", 6 | "codec": "x264", 7 | "group": "LOL [eztv]", 8 | "repack": true 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_040.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Into The Storm", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "BRRip", 6 | "codec": "x264", 7 | "audio": "DTS", 8 | "group": "JYK" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_000.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Walking Dead", 3 | "season": 5, 4 | "episode": 3, 5 | "resolution": "720p", 6 | "quality": "HDTV", 7 | "codec": "x264", 8 | "group": "ASAP[ettv]" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_012.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Guardians Of The Galaxy", 3 | "year": 2014, 4 | "resolution": "720p", 5 | "quality": "HDCAM", 6 | "codec": "x264", 7 | "group": "JYK", 8 | "region": "6" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_038.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Into The Storm", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "WEB-DL", 6 | "codec": "H264", 7 | "audio": "AAC2.0", 8 | "group": "RARBG" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_070.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Hateful Eight", 3 | "episode": 999, 4 | "year": 2015, 5 | "resolution": "720p", 6 | "quality": "BluRay", 7 | "codec": "x265", 8 | "size": "999MB" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_078.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "thomas and friends", 3 | "season": 19, 4 | "episode": 9, 5 | "quality": "hdtv", 6 | "codec": "x264", 7 | "group": "w4f[eztv].mkv", 8 | "container": "mkv" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_081.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "2012", 3 | "episode": 1, 4 | "year": 2009, 5 | "resolution": "1080p", 6 | "quality": "BrRip", 7 | "codec": "x264", 8 | "size": "1.7GB" 9 | } 10 | -------------------------------------------------------------------------------- /testdata/golden_file_068.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Purge: Election Year", 3 | "episode": 720, 4 | "year": 2016, 5 | "resolution": "720p", 6 | "quality": "HDRiP", 7 | "hardcoded": true, 8 | "size": "900MB" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_011.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "X-Men Days of Future Past", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "WEB-DL", 6 | "codec": "H264", 7 | "audio": "DD5.1", 8 | "group": "RARBG" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_013.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Marvel's Agents of S H I E L D", 3 | "season": 2, 4 | "episode": 1, 5 | "resolution": "1080p", 6 | "quality": "WEB-DL", 7 | "audio": "DD5.1", 8 | "group": "DL.DD5.1" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_035.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Dawn Of The Planet of The Apes", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "WEB-DL", 6 | "codec": "H264", 7 | "audio": "DD51", 8 | "group": "RARBG" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_036.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Teenage Mutant Ninja Turtles", 3 | "year": 2014, 4 | "resolution": "720p", 5 | "quality": "HDRip", 6 | "codec": "x264", 7 | "audio": "AC3.5.1", 8 | "group": "RARBG" 9 | } -------------------------------------------------------------------------------- /testdata/golden_file_058.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "doctor who", 3 | "season": 8, 4 | "episode": 12, 5 | "year": 2005, 6 | "resolution": "720p", 7 | "quality": "hdtv", 8 | "codec": "x264", 9 | "group": "fov" 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_071.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Boss", 3 | "year": 2016, 4 | "resolution": "720p", 5 | "quality": "BRRip", 6 | "codec": "x264", 7 | "audio": "AAC", 8 | "group": "ETRG", 9 | "unrated": true 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_079.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Blade Runner 2049", 3 | "year": 2017, 4 | "resolution": "1080p", 5 | "quality": "WEB-DL", 6 | "codec": "H264", 7 | "audio": "DD5.1", 8 | "group": "[rarbg.to]" 9 | } 10 | -------------------------------------------------------------------------------- /testdata/golden_file_005.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Hercules", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "WEB-DL", 6 | "codec": "H264", 7 | "audio": "DD5.1", 8 | "group": "RARBG", 9 | "extended": true 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_047.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Doctor Who", 3 | "season": 8, 4 | "episode": 11, 5 | "year": 2005, 6 | "resolution": "720p", 7 | "quality": "HDTV", 8 | "codec": "x264", 9 | "group": "FoV[rartv]" 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_016.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Walking Dead", 3 | "season": 5, 4 | "episode": 3, 5 | "resolution": "1080p", 6 | "quality": "WEB-DL", 7 | "codec": "H.264", 8 | "audio": "DD5.1", 9 | "group": "Cyphanix[rartv]" 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_061.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "sons of anarchy", 3 | "season": 5, 4 | "episode": 10, 5 | "resolution": "480p", 6 | "quality": "BluRay", 7 | "codec": "x264", 8 | "group": "GAnGSteR", 9 | "website": "720pMkv.Com" 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_062.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "-Sons.of.Anarchy.", 3 | "season": 7, 4 | "episode": 7, 5 | "resolution": "720p", 6 | "quality": "HDTV", 7 | "codec": "X264", 8 | "group": "DIMENSION", 9 | "website": "www.Speed.cd" 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_065.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Ant-Man", 3 | "year": 2015, 4 | "resolution": "1080p", 5 | "quality": "BRRip", 6 | "codec": "x264", 7 | "audio": "AAC", 8 | "group": "m2g", 9 | "sbs": "Half-SBS", 10 | "3d": true 11 | } -------------------------------------------------------------------------------- /testdata/golden_file_064.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "The Jungle Book", 3 | "year": 2016, 4 | "resolution": "1080p", 5 | "quality": "BRRip", 6 | "codec": "x264", 7 | "audio": "AAC", 8 | "group": "ETRG", 9 | "sbs": "SBS", 10 | "3d": true 11 | } -------------------------------------------------------------------------------- /testdata/golden_file_055.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Eliza Graves", 3 | "year": 2014, 4 | "resolution": "720p", 5 | "quality": "WEB-DL", 6 | "codec": "x264", 7 | "audio": "Dual Audio", 8 | "group": "DL 720p MKV x264", 9 | "container": "MKV" 10 | } -------------------------------------------------------------------------------- /testdata/golden_file_052.json: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "Annabelle", 3 | "year": 2014, 4 | "resolution": "1080p", 5 | "quality": "WEBRip", 6 | "codec": "x264", 7 | "audio": "AAC.2.0", 8 | "group": "RARBG", 9 | "hardcoded": true, 10 | "proper": true 11 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | nguage: go 2 | 3 | go: 4 | - 1.7.x 5 | - 1.8.x 6 | - master 7 | 8 | branches: 9 | only: 10 | - master 11 | 12 | before_install: 13 | - go get github.com/mattn/goveralls 14 | 15 | script: 16 | - go vet -v . 17 | - go build -v . 18 | - go test -v -covermode=count -coverprofile=coverage.out 19 | - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Pauline Middelink 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /patterns.go: -------------------------------------------------------------------------------- 1 | package parsetorrentname 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "reflect" 7 | "regexp" 8 | ) 9 | 10 | var patterns = []struct { 11 | name string 12 | // Use the last matching pattern. E.g. Year. 13 | last bool 14 | kind reflect.Kind 15 | // REs need to have 2 sub expressions (groups), the first one is "raw", and 16 | // the second one for the "clean" value. 17 | // E.g. Epiode matching on "S01E18" will result in: raw = "E18", clean = "18". 18 | re *regexp.Regexp 19 | }{ 20 | {"season", false, reflect.Int, regexp.MustCompile(`(?i)(s?([0-9]{1,2}))[ex]`)}, 21 | {"episode", false, reflect.Int, regexp.MustCompile(`(?i)([ex]([0-9]{2})(?:[^0-9]|$))`)}, 22 | {"episode", false, reflect.Int, regexp.MustCompile(`(-\s+([0-9]{1,})(?:[^0-9]|$))`)}, 23 | {"year", true, reflect.Int, regexp.MustCompile(`\b(((?:19[0-9]|20[0-9])[0-9]))\b`)}, 24 | 25 | {"resolution", false, reflect.String, regexp.MustCompile(`\b(([0-9]{3,4}p))\b`)}, 26 | {"quality", false, reflect.String, regexp.MustCompile(`(?i)\b(((?:PPV\.)?[HP]DTV|(?:HD)?CAM|B[DR]Rip|(?:HD-?)?TS|(?:PPV )?WEB-?DL(?: DVDRip)?|HDRip|DVDRip|DVDRIP|CamRip|W[EB]BRip|BluRay|DvDScr|telesync))\b`)}, 27 | {"codec", false, reflect.String, regexp.MustCompile(`(?i)\b((xvid|[hx]\.?26[45]))\b`)}, 28 | {"audio", false, reflect.String, regexp.MustCompile(`(?i)\b((MP3|DD5\.?1|Dual[\- ]Audio|LiNE|DTS|AAC[.-]LC|AAC(?:\.?2\.0)?|AC3(?:\.5\.1)?))\b`)}, 29 | {"region", false, reflect.String, regexp.MustCompile(`(?i)\b(R([0-9]))\b`)}, 30 | {"size", false, reflect.String, regexp.MustCompile(`(?i)\b((\d+(?:\.\d+)?(?:GB|MB)))\b`)}, 31 | {"website", false, reflect.String, regexp.MustCompile(`^(\[ ?([^\]]+?) ?\])`)}, 32 | {"language", false, reflect.String, regexp.MustCompile(`(?i)\b((rus\.eng|ita\.eng))\b`)}, 33 | {"sbs", false, reflect.String, regexp.MustCompile(`(?i)\b(((?:Half-)?SBS))\b`)}, 34 | {"container", false, reflect.String, regexp.MustCompile(`(?i)\b((MKV|AVI|MP4))\b`)}, 35 | 36 | {"group", false, reflect.String, regexp.MustCompile(`\b(- ?([^-]+(?:-={[^-]+-?$)?))$`)}, 37 | 38 | {"extended", false, reflect.Bool, regexp.MustCompile(`(?i)\b(EXTENDED(:?.CUT)?)\b`)}, 39 | {"hardcoded", false, reflect.Bool, regexp.MustCompile(`(?i)\b((HC))\b`)}, 40 | {"proper", false, reflect.Bool, regexp.MustCompile(`(?i)\b((PROPER))\b`)}, 41 | {"repack", false, reflect.Bool, regexp.MustCompile(`(?i)\b((REPACK))\b`)}, 42 | {"widescreen", false, reflect.Bool, regexp.MustCompile(`(?i)\b((WS))\b`)}, 43 | {"unrated", false, reflect.Bool, regexp.MustCompile(`(?i)\b((UNRATED))\b`)}, 44 | {"threeD", false, reflect.Bool, regexp.MustCompile(`(?i)\b((3D))\b`)}, 45 | } 46 | 47 | func init() { 48 | for _, pat := range patterns { 49 | if pat.re.NumSubexp() != 2 { 50 | fmt.Printf("Pattern %q does not have enough capture groups. want 2, got %d\n", pat.name, pat.re.NumSubexp()) 51 | os.Exit(1) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /parser.go: -------------------------------------------------------------------------------- 1 | package parsetorrentname 2 | 3 | import ( 4 | "reflect" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // TorrentInfo is the resulting structure returned by Parse 10 | type TorrentInfo struct { 11 | Title string 12 | Season int `json:"season,omitempty"` 13 | Episode int `json:"episode,omitempty"` 14 | Year int `json:"year,omitempty"` 15 | Resolution string `json:"resolution,omitempty"` 16 | Quality string `json:"quality,omitempty"` 17 | Codec string `json:"codec,omitempty"` 18 | Audio string `json:"audio,omitempty"` 19 | Group string `json:"group,omitempty"` 20 | Region string `json:"region,omitempty"` 21 | Extended bool `json:"extended,omitempty"` 22 | Hardcoded bool `json:"hardcoded,omitempty"` 23 | Proper bool `json:"proper,omitempty"` 24 | Repack bool `json:"repack,omitempty"` 25 | Container string `json:"container,omitempty"` 26 | Widescreen bool `json:"widescreen,omitempty"` 27 | Website string `json:"website,omitempty"` 28 | Language string `json:"language,omitempty"` 29 | Sbs string `json:"sbs,omitempty"` 30 | Unrated bool `json:"unrated,omitempty"` 31 | Size string `json:"size,omitempty"` 32 | ThreeD bool `json:"3d,omitempty"` 33 | } 34 | 35 | func setField(tor *TorrentInfo, field, raw, val string) { 36 | ttor := reflect.TypeOf(tor) 37 | torV := reflect.ValueOf(tor) 38 | field = strings.Title(field) 39 | v, _ := ttor.Elem().FieldByName(field) 40 | //fmt.Printf(" field=%v, type=%+v, value=%v\n", field, v.Type, val) 41 | switch v.Type.Kind() { 42 | case reflect.Bool: 43 | torV.Elem().FieldByName(field).SetBool(true) 44 | case reflect.Int: 45 | clean, _ := strconv.ParseInt(val, 10, 64) 46 | torV.Elem().FieldByName(field).SetInt(clean) 47 | case reflect.Uint: 48 | clean, _ := strconv.ParseUint(val, 10, 64) 49 | torV.Elem().FieldByName(field).SetUint(clean) 50 | case reflect.String: 51 | torV.Elem().FieldByName(field).SetString(val) 52 | } 53 | } 54 | 55 | // Parse breaks up the given filename in TorrentInfo 56 | func Parse(filename string) (*TorrentInfo, error) { 57 | tor := &TorrentInfo{} 58 | //fmt.Printf("filename %q\n", filename) 59 | 60 | var startIndex, endIndex = 0, len(filename) 61 | cleanName := strings.Replace(filename, "_", " ", -1) 62 | for _, pattern := range patterns { 63 | matches := pattern.re.FindAllStringSubmatch(cleanName, -1) 64 | if len(matches) == 0 { 65 | continue 66 | } 67 | matchIdx := 0 68 | if pattern.last { 69 | // Take last occurence of element. 70 | matchIdx = len(matches) - 1 71 | } 72 | //fmt.Printf(" %s: pattern:%q match:%#v\n", pattern.name, pattern.re, matches[matchIdx]) 73 | 74 | index := strings.Index(cleanName, matches[matchIdx][1]) 75 | if index == 0 { 76 | startIndex = len(matches[matchIdx][1]) 77 | //fmt.Printf(" startIndex moved to %d [%q]\n", startIndex, filename[startIndex:endIndex]) 78 | } else if index < endIndex { 79 | endIndex = index 80 | //fmt.Printf(" endIndex moved to %d [%q]\n", endIndex, filename[startIndex:endIndex]) 81 | } 82 | setField(tor, pattern.name, matches[matchIdx][1], matches[matchIdx][2]) 83 | } 84 | 85 | // Start process for title 86 | //fmt.Println(" title: ") 87 | raw := strings.Split(filename[startIndex:endIndex], "(")[0] 88 | cleanName = raw 89 | if strings.HasPrefix(cleanName, "- ") { 90 | cleanName = raw[2:] 91 | } 92 | if strings.ContainsRune(cleanName, '.') && !strings.ContainsRune(cleanName, ' ') { 93 | cleanName = strings.Replace(cleanName, ".", " ", -1) 94 | } 95 | cleanName = strings.Replace(cleanName, "_", " ", -1) 96 | //cleanName = re.sub('([\[\(_]|- )$', '', cleanName).strip() 97 | setField(tor, "title", raw, strings.TrimSpace(cleanName)) 98 | 99 | return tor, nil 100 | } 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # parse-torrent-name 2 | 3 | [![GoDoc](https://godoc.org/github.com/middelink/go-parse-torrent-name?status.svg)](https://godoc.org/github.com/middelink/go-parse-torrent-name) 4 | [![License](https://img.shields.io/github/license/middelink/go-parse-torrent-name.svg)](https://github.com/middelink/go-parse-torrent-name/blob/master/LICENSE) 5 | [![Build Status](https://travis-ci.org/middelink/go-parse-torrent-name.svg?branch=master)](https://travis-ci.org/middelink/go-parse-torrent-name) 6 | [![Coverage Status](https://coveralls.io/repos/github/middelink/go-parse-torrent-name/badge.svg?branch=master)](https://coveralls.io/github/middelink/go-parse-torrent-name?branch=master) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/middelink/go-parse-torrent-name)](https://goreportcard.com/report/github.com/middelink/go-parse-torrent-name) 8 | 9 | > Extract media information from torrent-like filename 10 | 11 | A Go port of [Jānis](https://github.com/jzjzjzj)' awesome 12 | [library](https://github.com/jzjzjzj/parse-torrent-name) written in 13 | javascript. 14 | 15 | Extract all possible media information present in filenames. Multiple regex 16 | rules are applied on filename string each of which extracts correponding 17 | information from the filename. If a regex rule matches, the corresponding part 18 | is removed from the filename. In the end, the remaining part is taken as the 19 | title of the content. 20 | 21 | ## Why? 22 | 23 | Online APIs by providers like 24 | [TMDb](https://www.themoviedb.org/documentation/api), 25 | [TVDb](http://thetvdb.com/wiki/index.php?title=Programmers_API) and 26 | [OMDb](http://www.omdbapi.com/) don't react to well to search 27 | queries which include any kind of extra information. To get proper results from 28 | these APIs, only the title of the content should be provided as the search 29 | query where this library comes into play. The accuracy of the results can be 30 | improved by passing in the year which can also be extracted using this library. 31 | 32 | ## Usage 33 | 34 | ```go 35 | import PTN 36 | 37 | info = PTN.parse('A freakishly cool movie or TV episode') 38 | 39 | print info # All details that were parsed 40 | ``` 41 | 42 | PTN works well for both movies and TV episodes. All meaningful information is 43 | extracted and returned together in a dictionary. The text which could not be 44 | parsed is returned in the `excess` field. 45 | 46 | ### Movies 47 | 48 | ```py 49 | PTN.parse('San Andreas 2015 720p WEB-DL x264 AAC-JYK') 50 | # { 51 | # 'group': 'JYK', 52 | # 'title': 'San Andreas', 53 | # 'resolution': '720p', 54 | # 'codec': 'x264', 55 | # 'year': '2015', 56 | # 'audio': 'AAC', 57 | # 'quality': 'WEB-DL' 58 | # } 59 | 60 | PTN.parse('The Martian 2015 540p HDRip KORSUB x264 AAC2 0-FGT') 61 | # { 62 | # 'group': '0-FGT', 63 | # 'title': 'The Martian', 64 | # 'resolution': '540p', 65 | # 'excess': ['KORSUB', '2'], 66 | # 'codec': 'x264', 67 | # 'year': 2015, 68 | # 'audio': 'AAC', 69 | # 'quality': 'HDRip' 70 | # } 71 | ``` 72 | 73 | ### TV episodes 74 | 75 | ```py 76 | PTN.parse('Mr Robot S01E05 HDTV x264-KILLERS[ettv]') 77 | # { 78 | # 'episode': 5, 79 | # 'season': 1, 80 | # 'title': 'Mr Robot', 81 | # 'codec': 'x264', 82 | # 'group': 'KILLERS[ettv]' 83 | # 'quality': 'HDTV' 84 | # } 85 | 86 | PTN.parse('friends.s02e01.720p.bluray-sujaidr') 87 | # { 88 | # 'episode': 1, 89 | # 'season': 2, 90 | # 'title': 'friends', 91 | # 'resolution': '720p', 92 | # 'group': 'sujaidr', 93 | # 'quality': 'bluray' 94 | # } 95 | ``` 96 | 97 | ### Note 98 | 99 | PTN does not garantee the fields `group`, `excess` and `episodeName` as these 100 | fields might be interchanged with each other. This shoudn't affect most 101 | applications since episode name can be fetched from an online database 102 | after getting the season and episode number correctly. 103 | 104 | ### Parts extracted 105 | 106 | * audio 107 | * codec 108 | * container 109 | * episode 110 | * episodeName 111 | * excess 112 | * extended 113 | * garbage 114 | * group 115 | * hardcoded 116 | * language 117 | * proper 118 | * quality 119 | * region 120 | * repack 121 | * resolution 122 | * season 123 | * title 124 | * website 125 | * widescreen 126 | * year 127 | 128 | ## Install 129 | 130 | ### Automatic 131 | 132 | PTN can be installed using `go get`. 133 | 134 | ```sh 135 | $ go get github.com/middelink/go-parse-torrent-name 136 | ``` 137 | 138 | ### Manual 139 | 140 | First clone the repository. 141 | 142 | ```sh 143 | $ git clone https://github.com/middelink/go-parse-torrent-name PTN && cd PTN 144 | ``` 145 | 146 | And run the command for installing the package. 147 | 148 | ```sh 149 | $ go install . 150 | ``` 151 | 152 | ## Contributing 153 | 154 | Take a look at the open 155 | [issues](https://github.com/jzjzjzj/parse-torrent-name/issues) on the original 156 | project and submit a PR! 157 | 158 | ## License 159 | 160 | MIT © [Pauline Middelink](http://www.polyware.nl/~middelink) 161 | -------------------------------------------------------------------------------- /parser_test.go: -------------------------------------------------------------------------------- 1 | package parsetorrentname 2 | 3 | import ( 4 | "encoding/json" 5 | "flag" 6 | "fmt" 7 | "io/ioutil" 8 | "path/filepath" 9 | "reflect" 10 | "testing" 11 | ) 12 | 13 | var updateGoldenFiles = flag.Bool("update", false, "update golden files in testdata/") 14 | 15 | var testData = []string{ 16 | "The Walking Dead S05E03 720p HDTV x264-ASAP[ettv]", 17 | "Hercules (2014) 1080p BrRip H264 - YIFY", 18 | "Dawn.of.the.Planet.of.the.Apes.2014.HDRip.XViD-EVO", 19 | "The Big Bang Theory S08E06 HDTV XviD-LOL [eztv]", 20 | "22 Jump Street (2014) 720p BrRip x264 - YIFY", 21 | "Hercules.2014.EXTENDED.1080p.WEB-DL.DD5.1.H264-RARBG", 22 | "Hercules.2014.Extended.Cut.HDRip.XViD-juggs[ETRG]", 23 | "Hercules (2014) WEBDL DVDRip XviD-MAX", 24 | "WWE Hell in a Cell 2014 PPV WEB-DL x264-WD -={SPARROW}=-", 25 | "UFC.179.PPV.HDTV.x264-Ebi[rartv]", 26 | "Marvels Agents of S H I E L D S02E05 HDTV x264-KILLERS [eztv]", 27 | "X-Men.Days.of.Future.Past.2014.1080p.WEB-DL.DD5.1.H264-RARBG", 28 | "Guardians Of The Galaxy 2014 R6 720p HDCAM x264-JYK", 29 | "Marvel's.Agents.of.S.H.I.E.L.D.S02E01.Shadows.1080p.WEB-DL.DD5.1", 30 | "Marvels Agents of S.H.I.E.L.D. S02E06 HDTV x264-KILLERS[ettv]", 31 | "Guardians of the Galaxy (CamRip / 2014)", 32 | "The.Walking.Dead.S05E03.1080p.WEB-DL.DD5.1.H.264-Cyphanix[rartv]", 33 | "Brave.2012.R5.DVDRip.XViD.LiNE-UNiQUE", 34 | "Lets.Be.Cops.2014.BRRip.XViD-juggs[ETRG]", 35 | "These.Final.Hours.2013.WBBRip XViD", 36 | "Downton Abbey 5x06 HDTV x264-FoV [eztv]", 37 | "Annabelle.2014.HC.HDRip.XViD.AC3-juggs[ETRG]", 38 | "Lucy.2014.HC.HDRip.XViD-juggs[ETRG]", 39 | "The Flash 2014 S01E04 HDTV x264-FUM[ettv]", 40 | "South Park S18E05 HDTV x264-KILLERS [eztv]", 41 | "The Flash 2014 S01E03 HDTV x264-LOL[ettv]", 42 | "The Flash 2014 S01E01 HDTV x264-LOL[ettv]", 43 | "Lucy 2014 Dual-Audio WEBRip 1400Mb", 44 | "Teenage Mutant Ninja Turtles (HdRip / 2014)", 45 | "Teenage Mutant Ninja Turtles (unknown_release_type / 2014)", 46 | "The Simpsons S26E05 HDTV x264 PROPER-LOL [eztv]", 47 | "2047 - Sights of Death (2014) 720p BrRip x264 - YIFY", 48 | "Two and a Half Men S12E01 HDTV x264 REPACK-LOL [eztv]", 49 | "Dinosaur 13 2014 WEBrip XviD AC3 MiLLENiUM", 50 | "Teenage.Mutant.Ninja.Turtles.2014.HDRip.XviD.MP3-RARBG", 51 | "Dawn.Of.The.Planet.of.The.Apes.2014.1080p.WEB-DL.DD51.H264-RARBG", 52 | "Teenage.Mutant.Ninja.Turtles.2014.720p.HDRip.x264.AC3.5.1-RARBG", 53 | "Gotham.S01E05.Viper.WEB-DL.x264.AAC", 54 | "Into.The.Storm.2014.1080p.WEB-DL.AAC2.0.H264-RARBG", 55 | "Lucy 2014 Dual-Audio 720p WEBRip", 56 | "Into The Storm 2014 1080p BRRip x264 DTS-JYK", 57 | "Sin.City.A.Dame.to.Kill.For.2014.1080p.BluRay.x264-SPARKS", 58 | "WWE Monday Night Raw 3rd Nov 2014 HDTV x264-Sir Paul", 59 | "Jack.And.The.Cuckoo-Clock.Heart.2013.BRRip XViD", 60 | "WWE Hell in a Cell 2014 HDTV x264 SNHD", 61 | "Dracula.Untold.2014.TS.XViD.AC3.MrSeeN-SiMPLE", 62 | "The Missing 1x01 Pilot HDTV x264-FoV [eztv]", 63 | "Doctor.Who.2005.8x11.Dark.Water.720p.HDTV.x264-FoV[rartv]", 64 | "Gotham.S01E07.Penguins.Umbrella.WEB-DL.x264.AAC", 65 | "One Shot [2014] DVDRip XViD-ViCKY", 66 | "The Shaukeens 2014 Hindi (1CD) DvDScr x264 AAC...Hon3y", 67 | "The Shaukeens (2014) 1CD DvDScr Rip x264 [DDR]", 68 | "Annabelle.2014.1080p.PROPER.HC.WEBRip.x264.AAC.2.0-RARBG", 69 | "Interstellar (2014) CAM ENG x264 AAC-CPG", 70 | "Guardians of the Galaxy (2014) Dual Audio DVDRip AVI", 71 | "Eliza Graves (2014) Dual Audio WEB-DL 720p MKV x264", 72 | "WWE Monday Night Raw 2014 11 10 WS PDTV x264-RKOFAN1990 -={SPARR", 73 | "Sons.of.Anarchy.S01E03", 74 | "doctor_who_2005.8x12.death_in_heaven.720p_hdtv_x264-fov", 75 | "breaking.bad.s01e01.720p.bluray.x264-reward", 76 | "Game of Thrones - 4x03 - Breaker of Chains", 77 | "[720pMkv.Com]_sons.of.anarchy.s05e10.480p.BluRay.x264-GAnGSteR", 78 | "[ www.Speed.cd ] -Sons.of.Anarchy.S07E07.720p.HDTV.X264-DIMENSION", 79 | "Community.s02e20.rus.eng.720p.Kybik.v.Kybe", 80 | "The.Jungle.Book.2016.3D.1080p.BRRip.SBS.x264.AAC-ETRG", 81 | "Ant-Man.2015.3D.1080p.BRRip.Half-SBS.x264.AAC-m2g", 82 | "Ice.Age.Collision.Course.2016.READNFO.720p.HDRIP.X264.AC3.TiTAN", 83 | "Red.Sonja.Queen.Of.Plagues.2016.BDRip.x264-W4F[PRiME]", 84 | "The Purge: Election Year (2016) HC - 720p HDRiP - 900MB - ShAaNi", 85 | "War Dogs (2016) HDTS 600MB - NBY", 86 | "The Hateful Eight (2015) 720p BluRay - x265 HEVC - 999MB - ShAaN", 87 | "The.Boss.2016.UNRATED.720p.BRRip.x264.AAC-ETRG", 88 | "Return.To.Snowy.River.1988.iNTERNAL.DVDRip.x264-W4F[PRiME]", 89 | "Akira (2016) - UpScaled - 720p - DesiSCR-Rip - Hindi - x264 - AC3 - 5.1 - Mafiaking - M2Tv", 90 | "Ben Hur 2016 TELESYNC x264 AC3 MAXPRO", 91 | "The.Secret.Life.of.Pets.2016.HDRiP.AAC-LC.x264-LEGi0N", 92 | "[HorribleSubs] Clockwork Planet - 10 [480p].mkv", 93 | "[HorribleSubs] Detective Conan - 862 [1080p].mkv", 94 | "thomas.and.friends.s19e09_s20e14.convert.hdtv.x264-w4f[eztv].mkv", 95 | "Blade.Runner.2049.2017.1080p.WEB-DL.DD5.1.H264-FGT-[rarbg.to]", 96 | "2012(2009).1080p.Dual Audio(Hindi+English) 5.1 Audios", 97 | "2012 (2009) 1080p BrRip x264 - 1.7GB - YIFY", 98 | "2012 2009 x264 720p Esub BluRay 6.0 Dual Audio English Hindi GOPISAHI", 99 | } 100 | 101 | func TestParser(t *testing.T) { 102 | for i, fname := range testData { 103 | t.Run(fmt.Sprintf("golden_file_%03d", i), func(t *testing.T) { 104 | tor, err := Parse(fname) 105 | if err != nil { 106 | t.Fatalf("test %v: parser error:\n %v", i, err) 107 | } 108 | 109 | goldenFilename := filepath.Join("testdata", fmt.Sprintf("golden_file_%03d.json", i)) 110 | 111 | if *updateGoldenFiles { 112 | buf, err := json.MarshalIndent(tor, "", " ") 113 | if err != nil { 114 | t.Fatalf("error marshaling result: %v", err) 115 | } 116 | 117 | if err = ioutil.WriteFile(goldenFilename, buf, 0644); err != nil { 118 | t.Fatalf("unable to update golden file: %v", err) 119 | } 120 | } 121 | 122 | buf, err := ioutil.ReadFile(goldenFilename) 123 | if err != nil { 124 | t.Fatalf("error loading golden file: %v", err) 125 | } 126 | 127 | var want TorrentInfo 128 | err = json.Unmarshal(buf, &want) 129 | if err != nil { 130 | t.Fatalf("error unmarshalling golden file %v: %v", goldenFilename, err) 131 | } 132 | 133 | if !reflect.DeepEqual(*tor, want) { 134 | t.Fatalf("test %v: wrong result for %q\nwant:\n %v\ngot:\n %v", i, fname, want, *tor) 135 | } 136 | }) 137 | } 138 | } 139 | --------------------------------------------------------------------------------