Commit a25c7df1 authored by echel0n's avatar echel0n

Further work done to subtitle refiners

parent 514ebe33
......@@ -35,7 +35,7 @@ from sickrage.core.common import Overview
from sickrage.core.common import Quality, EpisodeStatus
from sickrage.core.databases.main import MainDB
from sickrage.core.databases.main.schemas import TVEpisodeSchema
from sickrage.core.enums import MultiEpNaming
from sickrage.core.enums import MultiEpNaming, SeriesProviderID
from sickrage.core.enums import SearchFormat, FileTimestampTimezone
from sickrage.core.exceptions import EpisodeNotFoundException, EpisodeDeletedException, NoNFOException
from sickrage.core.helpers import replace_extension, modify_file_timestamp, sanitize_scene_name, remove_non_release_groups, \
......@@ -96,6 +96,11 @@ class TVEpisode(object):
def series_provider_id(self, value):
self._data_local['series_provider_id'] = value
@property
def tvdb_id(self):
if self.series_provider_id == SeriesProviderID.THETVDB:
return self.episode_id
@property
def season(self):
return self._data_local['season']
......@@ -240,6 +245,16 @@ class TVEpisode(object):
def status(self, value):
self._data_local['status'] = value
@property
def quality(self):
_, quality = Quality.split_composite_status(self.status)
return quality
# return self._data_local['quality']
@quality.setter
def quality(self, value):
self._data_local['quality'] = value
@property
def location(self):
return self._data_local['location']
......@@ -1359,6 +1374,7 @@ class TVEpisode(object):
to_return += "hasnfo: %r\n" % self.hasnfo
to_return += "hastbn: %r\n" % self.hastbn
to_return += "status: %r\n" % self.status
to_return += "quality: %r\n" % self.quality
return to_return
def to_json(self):
......
......@@ -40,6 +40,7 @@ from sickrage.core.caches.image_cache import ImageCache
from sickrage.core.common import Quality, Qualities, EpisodeStatus
from sickrage.core.databases.main import MainDB
from sickrage.core.databases.main.schemas import TVShowSchema, IMDbInfoSchema, BlacklistSchema, WhitelistSchema
from sickrage.core.enums import SeriesProviderID
from sickrage.core.exceptions import ShowNotFoundException, EpisodeNotFoundException, EpisodeDeletedException, MultipleEpisodesInDatabaseException
from sickrage.core.helpers import list_media_files, is_media_file, try_int, safe_getattr, flatten
from sickrage.core.media.util import series_image, SeriesImageType
......@@ -99,6 +100,11 @@ class TVShow(object):
def series_provider_id(self, value):
self._data_local['series_provider_id'] = value
@property
def tvdb_id(self):
if self.series_provider_id == SeriesProviderID.THETVDB:
return self.series_id
@property
def name(self):
return self._data_local['name']
......
......@@ -38,6 +38,7 @@ from sickrage.subtitles.providers.utils import hash_itasa
class Subtitles(object):
def __init__(self):
# add subtitle providers
for provider in ('itasa = sickrage.subtitles.providers.itasa:ItaSAProvider',
'legendastv = subliminal.providers.legendastv:LegendasTVProvider',
'wizdom = sickrage.subtitles.providers.wizdom:WizdomProvider',
......@@ -46,9 +47,13 @@ class Subtitles(object):
if provider not in subliminal.provider_manager.registered_extensions + subliminal.provider_manager.internal_extensions:
subliminal.provider_manager.register(str(provider))
subliminal.refiner_manager.register('release = sickrage.subtitles.refiners.release:refine')
subliminal.refiner_manager.register('tvepisode = sickrage.subtitles.refiners.tv_episode:refine')
# add subtitle refiners
for refiner in ('release = sickrage.subtitles.refiners.release:refine',
'tvepisode = sickrage.subtitles.refiners.tv_episode:refine'):
if refiner not in subliminal.refiner_manager.registered_extensions + subliminal.refiner_manager.internal_extensions:
subliminal.refiner_manager.register(str(refiner))
# configure subtitle cache
subliminal.region.configure('dogpile.cache.memory', replace_existing_backend=True)
self.PROVIDER_URLS = {
......
......@@ -29,7 +29,7 @@ from sickrage.core.common import Quality
SHOW_MAPPING = {
'series_tvdb_id': 'tvdb_id',
'series_imdb_id': 'imdb_id',
'year': 'start_year'
'year': 'startyear'
}
EPISODE_MAPPING = {
......@@ -68,11 +68,11 @@ def refine(video, tv_episode=None, **kwargs):
sickrage.app.log.debug(f'Video {video.name!r} is not an episode. Skipping refiner...')
return
if tv_episode.series:
if tv_episode.show:
sickrage.app.log.debug('Refining using Series information.')
series, year, _ = series_re.match(tv_episode.series.name).groups()
series, year, _ = series_re.match(tv_episode.show.name).groups()
enrich({'series': series, 'year': int(year) if year else None}, video)
enrich(SHOW_MAPPING, video, tv_episode.series)
enrich(SHOW_MAPPING, video, tv_episode.show)
sickrage.app.log.debug('Refining using Episode information.')
enrich(EPISODE_MAPPING, video, tv_episode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment