mirror of
https://github.com/morpheus65535/bazarr
synced 2025-03-19 10:15:25 +00:00
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
1 changed files with 18 additions and 10 deletions
|
@ -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 knowit import api
|
||||
from subsyncer import subsync
|
||||
from guessit import guessit
|
||||
from database import database, dict_mapper, get_exclusion_clause
|
||||
|
||||
from analytics import track_event
|
||||
|
@ -1021,6 +1022,13 @@ def search_active(timestamp):
|
|||
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):
|
||||
if isinstance(video, Episode):
|
||||
data = database.execute(
|
||||
|
@ -1045,13 +1053,13 @@ def refine_from_db(path, video):
|
|||
if data['imdbId'] and not video.series_imdb_id:
|
||||
video.series_imdb_id = data['imdbId']
|
||||
if not video.source:
|
||||
video.source = str(data['format'])
|
||||
video.source = convert_to_guessit('source', str(data['format']))
|
||||
if not video.resolution:
|
||||
video.resolution = str(data['resolution'])
|
||||
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 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):
|
||||
data = database.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, "
|
||||
"imdbId FROM table_movies WHERE path = ?",
|
||||
|
@ -1066,13 +1074,13 @@ def refine_from_db(path, video):
|
|||
video.imdb_id = data['imdbId']
|
||||
video.alternative_titles = ast.literal_eval(data['alternativeTitles'])
|
||||
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 data['resolution']: video.resolution = data['resolution']
|
||||
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 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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue