mirror of https://github.com/morpheus65535/bazarr
Merge pull request #1205 from vitiko98/sucha-new-api
Convert release data to guessit format before refining from database
This commit is contained in:
commit
855727643b
|
@ -29,6 +29,7 @@ from notifier import send_notifications, send_notifications_movie
|
||||||
from get_providers import get_providers, get_providers_auth, provider_throttle, provider_pool
|
from get_providers import get_providers, get_providers_auth, provider_throttle, provider_pool
|
||||||
from knowit import api
|
from knowit import api
|
||||||
from subsyncer import subsync
|
from subsyncer import subsync
|
||||||
|
from guessit import guessit
|
||||||
from database import database, dict_mapper, get_exclusion_clause
|
from database import database, dict_mapper, get_exclusion_clause
|
||||||
|
|
||||||
from analytics import track_event
|
from analytics import track_event
|
||||||
|
@ -1021,6 +1022,13 @@ def search_active(timestamp):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def convert_to_guessit(guessit_key, attr_from_db):
|
||||||
|
try:
|
||||||
|
return guessit(attr_from_db)[guessit_key]
|
||||||
|
except KeyError:
|
||||||
|
return attr_from_db
|
||||||
|
|
||||||
|
|
||||||
def refine_from_db(path, video):
|
def refine_from_db(path, video):
|
||||||
if isinstance(video, Episode):
|
if isinstance(video, Episode):
|
||||||
data = database.execute(
|
data = database.execute(
|
||||||
|
@ -1045,13 +1053,13 @@ def refine_from_db(path, video):
|
||||||
if data['imdbId'] and not video.series_imdb_id:
|
if data['imdbId'] and not video.series_imdb_id:
|
||||||
video.series_imdb_id = data['imdbId']
|
video.series_imdb_id = data['imdbId']
|
||||||
if not video.source:
|
if not video.source:
|
||||||
video.source = str(data['format'])
|
video.source = convert_to_guessit('source', str(data['format']))
|
||||||
if not video.resolution:
|
if not video.resolution:
|
||||||
video.resolution = str(data['resolution'])
|
video.resolution = str(data['resolution'])
|
||||||
if not video.video_codec:
|
if not video.video_codec:
|
||||||
if data['video_codec']: video.video_codec = data['video_codec']
|
if data['video_codec']: video.video_codec = convert_to_guessit('video_codec', data['video_codec'])
|
||||||
if not video.audio_codec:
|
if not video.audio_codec:
|
||||||
if data['audio_codec']: video.audio_codec = data['audio_codec']
|
if data['audio_codec']: video.audio_codec = convert_to_guessit('audio_codec', data['audio_codec'])
|
||||||
elif isinstance(video, Movie):
|
elif isinstance(video, Movie):
|
||||||
data = database.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, "
|
data = database.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, "
|
||||||
"imdbId FROM table_movies WHERE path = ?",
|
"imdbId FROM table_movies WHERE path = ?",
|
||||||
|
@ -1066,13 +1074,13 @@ def refine_from_db(path, video):
|
||||||
video.imdb_id = data['imdbId']
|
video.imdb_id = data['imdbId']
|
||||||
video.alternative_titles = ast.literal_eval(data['alternativeTitles'])
|
video.alternative_titles = ast.literal_eval(data['alternativeTitles'])
|
||||||
if not video.source:
|
if not video.source:
|
||||||
if data['format']: video.source = data['format']
|
if data['format']: video.source = convert_to_guessit('source', data['format'])
|
||||||
if not video.resolution:
|
if not video.resolution:
|
||||||
if data['resolution']: video.resolution = data['resolution']
|
if data['resolution']: video.resolution = data['resolution']
|
||||||
if not video.video_codec:
|
if not video.video_codec:
|
||||||
if data['video_codec']: video.video_codec = data['video_codec']
|
if data['video_codec']: video.video_codec = convert_to_guessit('video_codec', data['video_codec'])
|
||||||
if not video.audio_codec:
|
if not video.audio_codec:
|
||||||
if data['audio_codec']: video.audio_codec = data['audio_codec']
|
if data['audio_codec']: video.audio_codec = convert_to_guessit('audio_codec', data['audio_codec'])
|
||||||
|
|
||||||
return video
|
return video
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue