Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle cases where guessit returns a list for a show name #8754

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sickchill/oldbeard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import urllib.request
import uuid
import zipfile
from collections.abc import Iterable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to try and except here and try collections.abc.Iterable and collections.iterable. The aliases moved in python 3.9 -> 3.10.

from contextlib import closing
from itertools import cycle
from pathlib import Path
Expand Down Expand Up @@ -851,6 +852,9 @@ def decrypt(data, encryption_version=0):


def full_sanitizeSceneName(name):
# if the name is an iterable, but not a string, then join it with spaces.
if isinstance(name, Iterable) and not isinstance(name, str):
name = " ".join(name)
return re.sub("[. -]", " ", sanitizeSceneName(name)).lower().strip()


Expand Down
29 changes: 22 additions & 7 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,34 @@ def test_fix_set_group_id(self):
"""
pass

@unittest.skip("Not yet implemented")
def test_sanitize_scene_name(self):
"""
Test sanitizeSceneName
"""
pass
cases = [
{"name": "", "anime": False, "expected": ""},
{"name": "Name, with: bad (chars)!", "anime": False, "expected": "Name.with.bad.chars"},
{"name": "Rock & Roll", "anime": False, "expected": "Rock.and.Roll"},
{"name": "This is a-test", "anime": False, "expected": "This.is.a.test"},
{"name": "Trailing dot.", "anime": False, "expected": "Trailing.dot"},
{"name": "Kuroko's Basketball", "anime": True, "expected": "Kuroko's.Basketball"},
{"name": "Name with — unusual & characters…", "anime": False, "expected": "Name.with.—.unusual.and.characters"},
{"name": "Too....many....dots...", "anime": False, "expected": "Too.many.dots"},
{"name": "'Single' and “Double” quotes", "anime": False, "expected": "Single.and.“Double”.quotes"},
]

for case in cases:
with self.subTest(case=case):
self.assertEqual(helpers.sanitizeSceneName(case["name"], anime=case["anime"]), case["expected"])

@unittest.skip("Not yet implemented")
def test_full_sanitize_scene_name(self):
"""
Test full_sanitizeSceneName
"""
pass
cases = [
{"name": "Name, with: bad (chars)!", "expected": "name with bad chars"},
{"name": ["A List"], "expected": "a list"},
]
for case in cases:
with self.subTest(case=case):
self.assertEqual(helpers.full_sanitizeSceneName(case["name"]), case["expected"])

@unittest.skip("Not yet implemented")
def test_remove_article(self):
Expand Down
Loading