Add support for episode names
This commit is contained in:
@@ -2,7 +2,71 @@ import unittest
|
||||
from renamer import parse_title
|
||||
|
||||
|
||||
class TestParser(unittest.TestCase):
|
||||
class TestParserParts(unittest.TestCase):
|
||||
def test_episode_name(self):
|
||||
title = "The.Walking.Dead.S04E06.Live.Bait.1080p.WEB-DL.Rus.Eng.HDCLUB"
|
||||
res = parse_title(title)
|
||||
self.assertEqual(["Live", "Bait"], res.get("episode_name"))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"episode": ["S04E06"],
|
||||
"resolution": ["1080p"],
|
||||
"quality": ["WEB-DL"],
|
||||
"episode_name": ["Live", "Bait"],
|
||||
"language": ["Rus", "Eng"],
|
||||
"name": ["The", "Walking", "Dead"],
|
||||
"unknown": ["HDCLUB"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_episode_number(self):
|
||||
title = "Vikings.S01E01.720p.BluRay.4xRus.Eng.HDCLUB"
|
||||
res = parse_title(title)
|
||||
self.assertIn("S01E01", res.get("episode", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"episode": ["S01E01"],
|
||||
"resolution": ["720p"],
|
||||
"quality": ["BluRay"],
|
||||
"language": ["4xRus", "Eng"],
|
||||
"name": ["Vikings"],
|
||||
"unknown": ["HDCLUB"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_subtitles(self):
|
||||
title = "Lives.of.Others.Blu-RayRip.720p.RusDTS.GerAC3.EngSub"
|
||||
res = parse_title(title)
|
||||
self.assertIn("EngSub", res.get("subtitles", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"quality": ["Blu-RayRip"],
|
||||
"resolution": ["720p"],
|
||||
"audio": ["RusDTS", "GerAC3"],
|
||||
"subtitles": ["EngSub"],
|
||||
"name": ["Lives", "of", "Others"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_file_extension(self):
|
||||
title = "The Guild s04e06 Weird Respawn (by Swich).mkv"
|
||||
res = parse_title(title)
|
||||
self.assertIn("mkv", res.get("file_extension", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"name": ["The", "Guild"],
|
||||
"episode": ["s04e06"],
|
||||
"episode_name": ["Weird", "Respawn", "by", "Swich"],
|
||||
"file_extension": ["mkv"],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class TestCornerCases(unittest.TestCase):
|
||||
def test_misc_separators(self):
|
||||
title = "V tumane 2012 1080p BluRay DD5.1 x264-EA"
|
||||
res = parse_title(title)
|
||||
@@ -22,6 +86,24 @@ class TestParser(unittest.TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
def test_misc_separators_and_combine(self):
|
||||
title = "The.Dawn.Patrol.1938.1080p.WEB-DL.AAC2.0.H.264-alinto"
|
||||
res = parse_title(title)
|
||||
self.assertIn("H.264", res.get("codec", []))
|
||||
self.assertIn("alinto", res.get("unknown", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"year": ["1938"],
|
||||
"resolution": ["1080p"],
|
||||
"quality": ["WEB-DL"],
|
||||
"audio": ["AAC2.0"],
|
||||
"codec": ["H.264"],
|
||||
"name": ["The", "Dawn", "Patrol"],
|
||||
"unknown": ["alinto"],
|
||||
},
|
||||
)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_russian_char_in_resolution(self):
|
||||
title = "Trouble.with.the.Curve.2012.1080р.BluRay.Rus.Eng.HDCLUB"
|
||||
@@ -69,10 +151,10 @@ class TestParser(unittest.TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
def test_file_extension_goes_to_unknown(self):
|
||||
def test_file_extension_does_not_go_to_unknown(self):
|
||||
title = "Monsters,Inc.2001.BDRip.1080p.3xRus.Ukr.Eng.HDCLUB.mkv"
|
||||
res = parse_title(title)
|
||||
self.assertIn("mkv", res.get("unknown", []))
|
||||
self.assertNotIn("mkv", res.get("unknown", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
@@ -81,7 +163,8 @@ class TestParser(unittest.TestCase):
|
||||
"resolution": ["1080p"],
|
||||
"language": ["3xRus", "Ukr", "Eng"],
|
||||
"name": ["Monsters", "Inc"],
|
||||
"unknown": ["HDCLUB", "mkv"],
|
||||
"unknown": ["HDCLUB"],
|
||||
"file_extension": ["mkv"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -102,7 +185,6 @@ class TestParser(unittest.TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_chunk_from_three_parts(self):
|
||||
title = "Mad.Max.Road.of.Fury.Black.Chrome.edition.BDRip.1080p"
|
||||
self.assertEqual(
|
||||
@@ -162,21 +244,6 @@ class TestParser(unittest.TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
def test_subtitles(self):
|
||||
title = "Lives.of.Others.Blu-RayRip.720p.RusDTS.GerAC3.EngSub"
|
||||
res = parse_title(title)
|
||||
self.assertIn("EngSub", res.get("subtitles", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"quality": ["Blu-RayRip"],
|
||||
"resolution": ["720p"],
|
||||
"audio": ["RusDTS", "GerAC3"],
|
||||
"subtitles": ["EngSub"],
|
||||
"name": ["Lives", "of", "Others"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_strange_dot_in_name(self):
|
||||
title = "WALL·E.2008.1080p.BluRay.3xRus.Ukr.Eng.HDCLUB-Skazhutin"
|
||||
res = parse_title(title)
|
||||
@@ -192,3 +259,68 @@ class TestParser(unittest.TestCase):
|
||||
"unknown": ["HDCLUB-Skazhutin"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_splitted_by_hyphens_chunk_ends_with_empty_part(self):
|
||||
title = "The.IT.Crowd.S01E04.The.Red.Door.HR.DVDRip.HQ.Edition.x264-N-(Rus.Eng)"
|
||||
res = parse_title(title)
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"name": ["The", "IT", "Crowd"],
|
||||
"episode": ["S01E04"],
|
||||
"episode_name": ["The", "Red", "Door", "HR"],
|
||||
"quality": ["DVDRip"],
|
||||
"edition": ["HQ.Edition"],
|
||||
"codec": ["x264"],
|
||||
"unknown": ["N"],
|
||||
"language": ["Rus", "Eng"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_year_before_episode_number_and_name(self):
|
||||
title = "The.Big.Bang.Theory.2019.S12E20.The.Decision.Reverberation.1080p.AMZN.WEB-DL.DD5.1.x264-NTb_EniaHD.mkv"
|
||||
res = parse_title(title)
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"name": ["The", "Big", "Bang", "Theory"],
|
||||
"year": ["2019"],
|
||||
"episode": ["S12E20"],
|
||||
"episode_name": ["The", "Decision", "Reverberation"],
|
||||
"unknown": ["NTb", "EniaHD"],
|
||||
"resolution": ["1080p"],
|
||||
"quality": ["AMZN", "WEB-DL"],
|
||||
"audio": ["DD5.1"],
|
||||
"codec": ["x264"],
|
||||
"file_extension": ["mkv"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_unknown_stripped_from_hyphens(self):
|
||||
title = "The.Big.Bang.Theory.S04E06.720p.WEB-DL.eng.rus.[Kuraj-Bambey.Ru]-jhonny2.mkv"
|
||||
res = parse_title(title)
|
||||
self.assertIn("jhonny2", res.get("unknown", []))
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"name": ["The", "Big", "Bang", "Theory"],
|
||||
"episode": ["S04E06"],
|
||||
"resolution": ["720p"],
|
||||
"quality": ["WEB-DL"],
|
||||
"language": ["eng", "rus"],
|
||||
"unknown": ["Kuraj-Bambey", "Ru", "jhonny2"],
|
||||
"file_extension": ["mkv"],
|
||||
},
|
||||
)
|
||||
|
||||
def test_episode_name_without_series_name(self):
|
||||
title = "S27E01.Every Man's Dream.mkv"
|
||||
res = parse_title(title)
|
||||
self.assertEqual(
|
||||
res,
|
||||
{
|
||||
"episode": ["S27E01"],
|
||||
"episode_name": ["Every", "Man's", "Dream"],
|
||||
"file_extension": ["mkv"],
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user