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

Implement episode and season search templates #3732

Merged
merged 139 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
34b61ec
Added the episode and season search templates to the tv_shows table.
p0psicles Feb 8, 2018
7138a81
Mako changes for start using Vue for editShow.mako.
p0psicles Feb 27, 2018
c32613d
Small fixes to existing Vue.js code in config.
p0psicles Feb 27, 2018
1e985e5
Moved sceneExceptions table from cache to main.db.
p0psicles Feb 27, 2018
5a73eb3
Fixed tvmaze debug log.
p0psicles Feb 27, 2018
f1b03b9
Fixed old bug where trakt is not using indexer to compare.
p0psicles Feb 27, 2018
27c078f
Fix bug in artwork, passing indexer_id while should pass object.
p0psicles Feb 27, 2018
5cf4eb3
Refactored sceneExceptions, returning now a named tuple in stead of t…
p0psicles Feb 27, 2018
307db2d
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles Feb 27, 2018
a4b097f
Refactored get_scene_exceptions_by_name to use the exception_cache, a…
p0psicles Feb 27, 2018
36ea69e
Fix typo
p0psicles Feb 27, 2018
3bc492c
Changed most of the editShow.mako to use vue for form handling.
p0psicles Feb 27, 2018
391095b
Updated theme slim src.
p0psicles Feb 27, 2018
bf56f53
Added apiv2 routes for patching ignored and required words.
p0psicles Mar 1, 2018
cfbc59d
Moved anidb to helper.
p0psicles Mar 2, 2018
2d44548
editShow.mako: Replacing get seriesObj from mako python to use apiv2.
p0psicles Mar 2, 2018
b17638d
Fixed quotes and removed json.dumps.
p0psicles Mar 2, 2018
1a58c62
Fixed editShow loading series data through mounted() function.
p0psicles Mar 2, 2018
1ad51d7
Styled the anidbReleaseGroupUi.mako component.
p0psicles Mar 2, 2018
1b113f5
Fixed the propagation of the list of strings for the requiredWords an…
p0psicles Mar 2, 2018
2b9b337
cleaned up vue and removed python imports
OmgImAlexis Mar 2, 2018
abd4f51
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles May 10, 2018
21963a9
Remove old components.
p0psicles May 10, 2018
2727c08
Add convert method to main.mako, so it can be used in other templates…
p0psicles May 11, 2018
0acb67c
Added new vue component name-pattern.
p0psicles May 11, 2018
fd59fd3
No need to create a new variable here.
p0psicles May 11, 2018
441c0b1
Make use of the namespace for the convert method.
p0psicles May 11, 2018
8fd2590
Remove the fillExamples methods, as i'm in the process of changing th…
p0psicles May 11, 2018
e80d5bc
config_Postprocessing.mako: Started implementing vue for the episode …
p0psicles May 11, 2018
90dbefd
Replaced all the different custom naming types (sports, air by date, …
p0psicles May 23, 2018
4aeeec1
Add axios clients for apiv1 and webRout rest calls.
p0psicles May 27, 2018
a21a195
Move convert method in mako to namespace.
p0psicles May 27, 2018
7c0c0b5
Get exceptions from show.
p0psicles May 27, 2018
c3dc0db
Api changes maps.
p0psicles May 27, 2018
060418c
Introduced a new component for name patterns.
p0psicles May 27, 2018
4fe55f5
Remove token from api client.
p0psicles May 29, 2018
697c5de
Added onChangePattern method, to process name-pattern component updates.
p0psicles May 29, 2018
cee4c06
Added postprocessing items to the apiv2 config.
p0psicles May 29, 2018
45c1d6c
Updated apiv2 config attributes for postprocessing.
p0psicles May 29, 2018
7aa4257
Added MultiEp style select.
p0psicles May 29, 2018
9f9eb2b
Also update animeNamingType (add absolute number) support to naming-p…
p0psicles May 30, 2018
e3bed79
Update muli-ep exaples when changing multi-ep style.
p0psicles May 30, 2018
f9f7d00
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles Jul 30, 2018
f1b3170
Fix db migration bugs after conflicts.
p0psicles Jul 30, 2018
9b8bf79
Merge remote-tracking branch 'origin/develop' into feature/templated-…
p0psicles Jan 17, 2020
77c8e9d
Added search_templates.py
p0psicles Jan 17, 2020
26cbb86
Fix duplicate creation of strings
p0psicles Jan 17, 2020
46dccf5
Separated read_from_db from generate method.
p0psicles Jan 17, 2020
5ce1b88
Add search_templates to apiv2 series result
p0psicles Jan 17, 2020
fedef2c
Update table search_templates
p0psicles Feb 8, 2020
9b0a685
Fix regression in name_parser/parser.py
p0psicles Feb 8, 2020
7805190
Move db connection to constructor.
p0psicles Feb 8, 2020
3ffc67e
Add config.templates and config.searchTemplates to apiv2.
p0psicles Feb 8, 2020
688d978
Added @properties for the templates.
p0psicles Feb 8, 2020
376c163
Added first UI's for creating search templates.
p0psicles Feb 8, 2020
388938e
Add property aliases_to_json because of the new structure of exceptions.
p0psicles Feb 18, 2020
0eb6601
Fix aliases in edit-show.vue because of new structure.
p0psicles Feb 18, 2020
f25498f
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles Mar 17, 2020
a26c212
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles Mar 17, 2020
74d225c
Yarn dev and eslint --fix
p0psicles Mar 17, 2020
cd9adcc
Fix enabling/disabling and saving default search templates.
p0psicles Mar 20, 2020
b47be60
Add flag to templates for specifying season searches.
p0psicles Mar 27, 2020
c8b2bfd
Add new tab to editShow "search templates"
p0psicles Mar 27, 2020
b8655c5
Add new component for adding search templates.
p0psicles Mar 27, 2020
0a450a9
Create new component for managing scene exceptions.
p0psicles Mar 27, 2020
b0314b1
Remove unused import.
p0psicles Mar 28, 2020
c2f1713
Add seasoned scene exceptions.
p0psicles Mar 28, 2020
84df542
Merge remote-tracking branch 'remotes/origin/develop' into feature/se…
p0psicles Mar 28, 2020
9f0bcd2
Fixed a number of small bugs, related to the renaming of seriesName (…
p0psicles Mar 28, 2020
084dbc9
Fix adding/removing scene exceptions.
p0psicles Mar 29, 2020
3191493
Merge remote-tracking branch 'remotes/origin/develop' into feature/se…
p0psicles Mar 29, 2020
c44843f
removeEmpty is not used anymore.
p0psicles Mar 29, 2020
d977bfb
Added newnlines between class.
p0psicles Mar 29, 2020
fbc2e81
Remove getAllSceneExceptions, as this is replaced by aliases.
p0psicles Mar 31, 2020
389ad6f
Removed allSceneExceptions, as this is replaced by aliases.
p0psicles Mar 31, 2020
7aac365
updated fixture with alias examples.
p0psicles Mar 31, 2020
edce48c
Merge remote-tracking branch 'remotes/origin/develop' into feature/se…
p0psicles Mar 31, 2020
f1b3c02
Added newline.
p0psicles Apr 2, 2020
b73f608
Fix stylelint
p0psicles Apr 2, 2020
c68ef83
Merge remote-tracking branch 'remotes/origin/feature/season-aliases' …
p0psicles Apr 2, 2020
2e2eecc
Fix test use TitleException.
p0psicles Apr 3, 2020
9297931
yarn dev
p0psicles Apr 3, 2020
a62a801
Fix test_parse_anime tests.
p0psicles Apr 3, 2020
a37f202
Fix api-description
p0psicles Apr 3, 2020
1c9565b
Fix flake warnings
p0psicles Apr 3, 2020
4f0497e
Utilize the field "custom" to specify if a scene exception is a custo…
p0psicles Apr 3, 2020
509aa3c
Small visual enhancement.
p0psicles Apr 3, 2020
39afa5c
Add custom field for guessit tests.
p0psicles Apr 3, 2020
c56dba8
Fix flake warnings
p0psicles Apr 4, 2020
1fd5e92
Fix typo
p0psicles Apr 4, 2020
33c5121
Flake indentation?
p0psicles Apr 4, 2020
1733d88
Let's try this
p0psicles Apr 4, 2020
18a010a
Show Medusa icon for exceptions that are not custom.
p0psicles Apr 4, 2020
495cb51
Vue lint and css-lint fixes.
p0psicles Apr 4, 2020
102be7d
Flake, we keep trying.
p0psicles Apr 4, 2020
0114353
Try to fix api tests.
p0psicles Apr 4, 2020
046e6d5
hanging indent
p0psicles Apr 4, 2020
7fe997a
Finally fixing this sh$t.
p0psicles Apr 4, 2020
53293c2
Change tooltip message
p0psicles Apr 5, 2020
e8753e4
yarn dev
p0psicles Apr 5, 2020
64d1c53
Merge remote-tracking branch 'remotes/origin/feature/season-aliases' …
p0psicles Apr 5, 2020
049a6b4
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles Apr 9, 2020
31bcc74
Add db constraint: Make sure template + season is always unique.
p0psicles Apr 10, 2020
561c080
Rename show_name to title.
p0psicles Apr 10, 2020
eb47e35
Re-generate search templates on modifactions to scene_exceptions.
p0psicles Apr 10, 2020
5b0cfd2
Prevent adding scene_exceptions that already exist.
p0psicles Apr 10, 2020
cab0a75
Add id to search_templates.
p0psicles Apr 10, 2020
0734740
Merge remote-tracking branch 'remotes/origin/develop' into feature/te…
p0psicles Nov 27, 2020
7d3cf99
Fix lint errors
p0psicles Nov 27, 2020
9207b73
hide/show templates tab.
p0psicles Nov 27, 2020
9ef2684
Merge remote-tracking branch 'origin/develop' into feature/templated-…
p0psicles Jan 8, 2022
eaf9314
Fix merge conflicts and linting
p0psicles Jan 9, 2022
3928c19
Fix adding custom search templates.
p0psicles Jan 10, 2022
b89b01c
Add first version of basic searching using the search templates
p0psicles Jan 11, 2022
9efef84
Don't search irrelevant scene seasons
p0psicles Jan 11, 2022
8103ce2
Improve default template creation for season scene exceptions
p0psicles Jan 11, 2022
31c251c
Remove debounce, not needed.
p0psicles Jan 11, 2022
66050f9
Fix debounced error
p0psicles Jan 11, 2022
6a1508b
Place back debounce
p0psicles Jan 11, 2022
e4eea94
Merge remote-tracking branch 'origin/develop' into feature/templated-…
p0psicles Jan 13, 2022
de88ad7
yarn dev
p0psicles Jan 13, 2022
258a001
Remove unique constraint
p0psicles Jan 13, 2022
47585d9
No need to re-recreate all default templates when requesting from api.
p0psicles Jan 13, 2022
5e1a731
Added info for displaying info on show / season exception.
p0psicles Jan 13, 2022
fb3dccc
Only get search_templates when detailed.
p0psicles Jan 13, 2022
306e0d4
Add test-guessit component
p0psicles Jan 22, 2022
6bd8d7b
Fixed show merging errors
p0psicles Jan 22, 2022
6e01837
Asume season 1, when no season number parsed
p0psicles Jan 22, 2022
05cbd28
Add parsing of special episodes by episode title.
p0psicles Jan 25, 2022
7cc6b8b
Change to staticmethod
p0psicles Jan 25, 2022
b7da1fd
Change check to startsWith
p0psicles Jan 25, 2022
8261b76
Rename remove -> remove_custom.
p0psicles Jan 25, 2022
5e8d37f
Merge remote-tracking branch 'origin/develop' into feature/templated-…
p0psicles Jan 25, 2022
73a2448
Add animation to red cross
p0psicles Jan 25, 2022
ba114e2
update snapshot
p0psicles Jan 25, 2022
19a564b
Fix linting issues
p0psicles Jan 25, 2022
dccaf35
Fix flake
p0psicles Jan 25, 2022
f4ce643
this image is not used
p0psicles Jan 25, 2022
fc83d46
Update changelog
p0psicles Jan 25, 2022
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
7 changes: 7 additions & 0 deletions medusa/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def release_write_lock(self):
cache = make_region()
memory_cache = make_region()
recommended_series_cache = make_region()
anidb_cache = make_region()


def configure(cache_dir):
Expand Down Expand Up @@ -70,6 +71,12 @@ def configure(cache_dir):
arguments={'filename': os.path.join(cache_dir, 'recommended.dbm'),
'lock_factory': MutexLock})

# anidb (adba) series cache
anidb_cache.configure('dogpile.cache.dbm',
expiration_time=timedelta(days=3),
arguments={'filename': os.path.join(cache_dir, 'anidb.dbm'),
'lock_factory': MutexLock})


def fallback():
"""Memory only configuration. Used for test purposes."""
Expand Down
10 changes: 10 additions & 0 deletions medusa/databases/cache_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,13 @@ def execute(self):

# clean up null values from the scene_exceptions_table
self.connection.action("DELETE FROM scene_exceptions WHERE indexer = '' or indexer is null;")


class RemoveSceneExceptionsTable(AddIndexerIds):
"""The scene_exceptions table has been moved to main.db"""
def test(self):
"""Test if the table history already has the indexer_id."""
return not self.hasTable("db_version")

def execute(self):
self.connection.action('DROP TABLE IF EXISTS scene_exceptions;')
31 changes: 30 additions & 1 deletion medusa/databases/main_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,13 @@ def execute(self):
log.info(u'Converting column indexer and default_ep_status field types to numeric')
self.connection.action("DROP TABLE IF EXISTS tmp_tv_shows")
self.connection.action("ALTER TABLE tv_shows RENAME TO tmp_tv_shows")
self.connection.action("CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer NUMERIC, show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, notify_list TEXT, imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC, archive_firstmatch NUMERIC, rls_require_words TEXT, rls_ignore_words TEXT, sports NUMERIC, anime NUMERIC, scene NUMERIC, default_ep_status NUMERIC)")
self.connection.action("CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer NUMERIC, "
"show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, "
"runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, "
"paused NUMERIC, startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, "
"notify_list TEXT, imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC, "
"archive_firstmatch NUMERIC, rls_require_words TEXT, rls_ignore_words TEXT, "
"sports NUMERIC, anime NUMERIC, scene NUMERIC, default_ep_status NUMERIC)")
self.connection.action("INSERT INTO tv_shows SELECT * FROM tmp_tv_shows")
self.connection.action("DROP TABLE tmp_tv_shows")

Expand Down Expand Up @@ -706,3 +712,26 @@ def create_series_dict():
# Flag the image migration.
from medusa import app
app.MIGRATE_IMAGES = True


class AddSearchTemplates(AddIndexerIds):
"""Adds column size to history table."""

def test(self):
"""
Test if the version is at least 44.10
"""
return self.connection.version >= (44, 10)

def execute(self):
backupDatabase(self.connection.version)

log.info(u"Creating a new table scene_exceptions in the main.db database.")

self.connection.action(
'CREATE TABLE scene_exceptions '
'(exception_id INTEGER PRIMARY KEY, indexer INTEGER, series_id INTEGER, show_name TEXT, '
'season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0, episode_search_template TEXT, season_search_template TEXT);'
)

self.inc_minor_version()
8 changes: 8 additions & 0 deletions medusa/helper/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ class ShowNotFoundException(ApplicationException):
"""
The show wasn't found on the Indexer
"""


class AnidbAdbaConnectionException(Exception):
"""
Connection exceptions raised while trying to communicate with the Anidb UDP api.

More info on the api: https://wiki.anidb.net/w/API.
"""
44 changes: 4 additions & 40 deletions medusa/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
except ImportError:
pass

import adba

from cachecontrol import CacheControlAdapter
from cachecontrol.cache import DictCache

Expand Down Expand Up @@ -1032,11 +1030,10 @@ def get_show(name, try_indexers=False):

# try scene exceptions
if not series:
series_from_name = scene_exceptions.get_scene_exceptions_by_name(series_name)[0]
series_id = series_from_name[0]
indexer_id = series_from_name[2]
if series_id:
series = Show.find_by_id(app.showList, indexer_id, series_id)
found_exceptions = list(scene_exceptions.get_scene_exceptions_by_name(series_name))
if found_exceptions:
# Only use the first exception.
series = Show.find_by_id(app.showList, found_exceptions[0].indexer, found_exceptions[0].series_id)

if not series:
match_name_only = (s.name for s in app.showList if text_type(s.imdb_year) in s.name and
Expand Down Expand Up @@ -1110,39 +1107,6 @@ def validate_show(show, season=None, episode=None):
pass


def set_up_anidb_connection():
"""Connect to anidb."""
if not app.USE_ANIDB:
log.debug(u'Usage of anidb disabled. Skipping')
return False

if not app.ANIDB_USERNAME and not app.ANIDB_PASSWORD:
log.debug(u'anidb username and/or password are not set.'
u' Aborting anidb lookup.')
return False

if not app.ADBA_CONNECTION:
def anidb_logger(msg):
return log.debug(u'anidb: {0}', msg)

try:
app.ADBA_CONNECTION = adba.Connection(keepAlive=True, log=anidb_logger)
except Exception as error:
log.warning(u'anidb exception msg: {0!r}', error)
return False

try:
if not app.ADBA_CONNECTION.authed():
app.ADBA_CONNECTION.auth(app.ANIDB_USERNAME, app.ANIDB_PASSWORD)
else:
return True
except Exception as error:
log.warning(u'anidb exception msg: {0!r}', error)
return False

return app.ADBA_CONNECTION.authed()


def backup_config_zip(file_list, archive, arcname=None):
"""Store the config file as a ZIP.

Expand Down
59 changes: 59 additions & 0 deletions medusa/helpers/anidb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Helper for anidb communications."""

import adba
import logging
from medusa import app
from medusa.cache import anidb_cache
from medusa.logger.adapters.style import BraceAdapter
from medusa.helper.exceptions import AnidbAdbaConnectionException

log = BraceAdapter(logging.getLogger(__name__))
log.logger.addHandler(logging.NullHandler())


def set_up_anidb_connection():
"""Connect to anidb."""
if not app.USE_ANIDB:
log.debug(u'Usage of anidb disabled. Skipping')
return False

if not app.ANIDB_USERNAME and not app.ANIDB_PASSWORD:
log.debug(u'anidb username and/or password are not set.'
u' Aborting anidb lookup.')
return False

if not app.ADBA_CONNECTION:
def anidb_logger(msg):
return log.debug(u'anidb: {0}', msg)

try:
app.ADBA_CONNECTION = adba.Connection(keepAlive=True, log=anidb_logger)
except Exception as error:
log.warning(u'anidb exception msg: {0!r}', error)
return False

try:
if not app.ADBA_CONNECTION.authed():
app.ADBA_CONNECTION.auth(app.ANIDB_USERNAME, app.ANIDB_PASSWORD)
else:
return True
except Exception as error:
log.warning(u'anidb exception msg: {0!r}', error)
return False

return app.ADBA_CONNECTION.authed()


@anidb_cache.cache_on_arguments()
def get_release_groups_for_anime(series_name):
"""Get release groups for an anidb anime."""
groups = []
if set_up_anidb_connection():
try:
anime = adba.Anime(app.ADBA_CONNECTION, name=series_name)
groups = anime.get_groups()
except Exception as error:
log.warning(u'Unable to retrieve Fansub Groups from AniDB. Error: {error}', {'error': error.message})
raise AnidbAdbaConnectionException(error)

return groups
41 changes: 41 additions & 0 deletions medusa/indexers/indexer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Indexer config module."""
from __future__ import unicode_literals

from six import text_type
from medusa.app import BASE_PYMEDUSA_URL
from medusa.indexers.tmdb.tmdb import Tmdb
from medusa.indexers.tvdbv2.tvdbv2_api import TVDBv2
Expand Down Expand Up @@ -114,3 +115,43 @@
'identifier': 'tmdb', # Also used as key for the custom scenename exceptions. (_get_custom_exceptions())
}
}


def create_config_json(indexer):
"""Create a json (pickable) conpatible dict, for using as an apiv2 resource."""
return {
'enabled': indexer['enabled'],
'id': indexer['id'],
'name': indexer['name'],
'module': text_type(indexer['module']),
'apiParams': {
'language': indexer['api_params']['language'],
'useZip': indexer['api_params']['use_zip'],
'session': '',
},
'xemOrigin': indexer.get('xem_origin'),
'icon': indexer.get('icon'),
'scene_loc': indexer.get('scene_loc'),
'baseUrl': indexer.get('base_url'),
'showUrl': indexer.get('show_url'),
'mappedTo': indexer.get('mapped_to'), # The attribute to which other indexers can map there thetvdb id to
'identifier': indexer.get('identifier'), # Also used as key for the custom scenename exceptions. (_get_custom_exceptions())
'validLanguages': initConfig['valid_languages'],
'langabbvToId': initConfig['langabbv_to_id'],
}


def get_indexer_config():
indexers = {
indexerConfig[indexer]['identifier']: create_config_json(indexerConfig[indexer]) for indexer in indexerConfig.keys()
}

main = {
'validLanguages': initConfig['valid_languages'],
'langabbvToId': initConfig['langabbv_to_id'],
'externalMappings': EXTERNAL_MAPPINGS,
'traktIndexers': TRAKT_INDEXERS,
'statusMap': STATUS_MAP
}

return {'indexers': indexers, 'main': main}
3 changes: 1 addition & 2 deletions medusa/name_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def build_name_cache(series_obj=None):
"""Build internal name cache.

:param series_obj: Specify series to build name cache for, if None, just do all series
:param force: Force the build name cache. Do not depend on the scene_exception_refresh table.
"""
def _cache_name(cache_series_obj):
"""Build the name cache for a single show."""
Expand All @@ -98,7 +97,7 @@ def _cache_name(cache_series_obj):
series_identifier = (cache_series_obj.indexer, cache_series_obj.series_id)
scene_exceptions = exceptions_cache[series_identifier].copy()
names = {
full_sanitize_scene_name(name): series_identifier
full_sanitize_scene_name(name.series_name): series_identifier
for season_exceptions in itervalues(scene_exceptions)
for name in season_exceptions
}
Expand Down
10 changes: 5 additions & 5 deletions medusa/name_parser/guessit_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ def get_expected_titles(show_list):
"""
expected_titles = []
for show in show_list:
names = {show.name}.union(show.exceptions)
for name in names:
if name.isdigit():
exceptions = {show.name}.union({exception.series_name for exception in show.exceptions})
for exception in exceptions:
if exception.isdigit():
# do not add numbers to expected titles.
continue

match = series_re.match(name)
match = series_re.match(exception)
if not match:
continue

series, year, _ = match.groups()
if year and not valid_year(int(year)):
series = name
series = exception

if not any([char.isdigit() for char in series]):
continue
Expand Down
4 changes: 3 additions & 1 deletion medusa/name_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def _parse_anime(result):
# "diamond is unbreakable" exception back to season 4 of it's "master" table. This will be used later
# to translate it to an absolute number, which in turn can be translated to an indexer SxEx.
# For example Diamond is unbreakable - 26 -> Season 4 -> Absolute number 100 -> tvdb S03E26
scene_season = scene_exceptions.get_scene_exceptions_by_name(result.series_name)[0][1]
found_exceptions = list(scene_exceptions.get_scene_exceptions_by_name(result.series_name))
if found_exceptions:
scene_season = found_exceptions[0].season

if result.ab_episode_numbers:
for absolute_episode in result.ab_episode_numbers:
Expand Down
13 changes: 13 additions & 0 deletions medusa/providers/generic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ def _get_episode_search_strings(self, episode, add_string=''):
if not episode:
return []

from medusa.scene_exceptions import get_scene_exceptions_by_name, get_all_scene_exceptions, get_scene_exceptions

search_string = {
'Episode': []
}
Expand Down Expand Up @@ -677,6 +679,17 @@ def _get_episode_search_strings(self, episode, add_string=''):
if episode_string_fallback:
search_string['Episode'].append(episode_string_fallback.strip())

exceptions = get_scene_exceptions_by_name(show_name)

for exception in exceptions:
if exception.episode_search_template:
anime_type = app.NAMING_ANIME
if not self.series.is_anime:
anime_type = 3
search_string['Episode'].append(
episode.formatted_search_string(exception.episode_search_template, anime_type=anime_type)
)

return [search_string]

def _get_tvdb_id(self):
Expand Down
Loading