mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-26 01:27:07 +00:00
Continuing development
This commit is contained in:
parent
33e4cfc758
commit
ab8b070c68
3 changed files with 83 additions and 16 deletions
|
@ -3,6 +3,7 @@ import os
|
|||
import sqlite3
|
||||
import requests
|
||||
import logging
|
||||
import re
|
||||
from queueconfig import q4ws
|
||||
|
||||
from get_args import args
|
||||
|
@ -82,6 +83,22 @@ def sync_episodes():
|
|||
format = episode['episodeFile']['quality']['quality']['name']
|
||||
resolution = str(episode['episodeFile']['quality']['quality']['resolution']) + 'p'
|
||||
|
||||
videoCodec = episode['episodeFile']['mediaInfo']['videoCodec']
|
||||
if videoCodec.startswith('x264'): videoCodec = 'h264'
|
||||
elif videoCodec.startswith('XviD'): videoCodec = 'XviD'
|
||||
elif videoCodec.startswith('DivX'): videoCodec = 'DivX'
|
||||
elif videoCodec.startswith('MPEG-1 Video'): videoCodec = 'Mpeg'
|
||||
elif videoCodec.startswith('MPEG-2 Video'): videoCodec = 'Mpeg2'
|
||||
elif videoCodec.startswith('MPEG-4 Video'): videoCodec = 'Mpeg4'
|
||||
elif videoCodec.endswith('VP6'): videoCodec = 'VP6'
|
||||
elif videoCodec.endswith('VP7'): videoCodec = 'VP7'
|
||||
elif videoCodec.endswith('VP8'): videoCodec = 'VP8'
|
||||
elif videoCodec.endswith('VP9'): videoCodec = 'VP9'
|
||||
|
||||
audioCodec = episode['episodeFile']['mediaInfo']['audioCodec']
|
||||
if audioCodec == 'AC-3': audioCodec = 'AC3'
|
||||
elif audioCodec == 'MPEG Audio': audioCodec = 'MP3'
|
||||
|
||||
# Add episodes in sonarr to current episode list
|
||||
current_episodes_sonarr.append(episode['id'])
|
||||
|
||||
|
@ -90,16 +107,13 @@ def sync_episodes():
|
|||
episode['seasonNumber'], episode['episodeNumber'],
|
||||
sceneName, str(bool(episode['monitored'])),
|
||||
format, resolution,
|
||||
episode['episodeFile']['mediaInfo']['videoCodec'],
|
||||
episode['episodeFile']['mediaInfo']['audioCodec'],
|
||||
episode['id']))
|
||||
videoCodec, audioCodec, episode['id']))
|
||||
else:
|
||||
episodes_to_add.append((episode['seriesId'], episode['id'], episode['title'],
|
||||
episode['episodeFile']['path'], episode['seasonNumber'],
|
||||
episode['episodeNumber'], sceneName,
|
||||
str(bool(episode['monitored'])), format, resolution,
|
||||
episode['episodeFile']['mediaInfo']['videoCodec'],
|
||||
episode['episodeFile']['mediaInfo']['audioCodec']))
|
||||
videoCodec, audioCodec))
|
||||
|
||||
removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr))
|
||||
|
||||
|
|
|
@ -83,6 +83,18 @@ def update_movies():
|
|||
format = movie['movieFile']['quality']['quality']['name']
|
||||
resolution = movie['movieFile']['quality']['quality']['resolution'].lstrip('r').lower()
|
||||
|
||||
videoFormat = movie['movieFile']['mediaInfo']['videoFormat']
|
||||
videoCodecID = movie['movieFile']['mediaInfo']['videoCodecID']
|
||||
videoProfile = movie['movieFile']['mediaInfo']['videoProfile']
|
||||
videoCodecLibrary = movie['movieFile']['mediaInfo']['videoCodecLibrary']
|
||||
videoCodec = RadarrFormatVideoCodec(videoFormat, videoCodecID, videoProfile, videoCodecLibrary)
|
||||
|
||||
audioFormat = movie['movieFile']['mediaInfo']['audioFormat']
|
||||
audioCodecID = movie['movieFile']['mediaInfo']['audioCodecID']
|
||||
audioProfile = movie['movieFile']['mediaInfo']['audioProfile']
|
||||
audioAdditionalFeatures = movie['movieFile']['mediaInfo']['audioAdditionalFeatures']
|
||||
audioCodec = RadarrFormatAudioCodec(audioFormat, audioCodecID, audioProfile, audioAdditionalFeatures)
|
||||
|
||||
# Add movies in radarr to current movies list
|
||||
current_movies_radarr.append(unicode(movie['tmdbId']))
|
||||
|
||||
|
@ -99,9 +111,7 @@ def update_movies():
|
|||
profile_id_to_language(movie['qualityProfileId']), sceneName,
|
||||
unicode(bool(movie['monitored'])), movie['sortTitle'],
|
||||
movie['year'], alternativeTitles, format, resolution,
|
||||
movie['movieFile']['mediaInfo']['videoCodecLibrary'],
|
||||
movie['movieFile']['mediaInfo']['audioFormat'],
|
||||
movie["tmdbId"]))
|
||||
videoCodec, audioCodec, movie["tmdbId"]))
|
||||
else:
|
||||
if movie_default_enabled is True:
|
||||
movies_to_add.append((movie["title"],
|
||||
|
@ -111,8 +121,7 @@ def update_movies():
|
|||
profile_id_to_language(movie['qualityProfileId']), sceneName,
|
||||
unicode(bool(movie['monitored'])), movie['sortTitle'],
|
||||
movie['year'], alternativeTitles, format, resolution,
|
||||
movie['movieFile']['mediaInfo']['videoCodecLibrary'],
|
||||
movie['movieFile']['mediaInfo']['audioFormat']))
|
||||
videoCodec, audioCodec))
|
||||
else:
|
||||
movies_to_add.append((movie["title"],
|
||||
movie["path"] + separator + movie['movieFile'][
|
||||
|
@ -121,8 +130,7 @@ def update_movies():
|
|||
profile_id_to_language(movie['qualityProfileId']), sceneName,
|
||||
unicode(bool(movie['monitored'])), movie['sortTitle'],
|
||||
movie['year'], alternativeTitles, format, resolution,
|
||||
movie['moviefile']['mediaInfo']['videoCodecLibrary'],
|
||||
movie['moviefile']['mediaInfo']['audioFormat']))
|
||||
videoCodec, audioCodec))
|
||||
else:
|
||||
logging.error(
|
||||
'BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator +
|
||||
|
@ -201,5 +209,51 @@ def profile_id_to_language(id):
|
|||
return profile[1]
|
||||
|
||||
|
||||
def RadarrFormatAudioCodec(audioFormat, audioCodecID, audioProfile, audioAdditionalFeatures):
|
||||
if audioFormat == "AC-3": return "AC3"
|
||||
if audioFormat == "E-AC-3": return "EAC3"
|
||||
if audioFormat == "AAC":
|
||||
if audioCodecID == "A_AAC/MPEG4/LC/SBR":
|
||||
return "HE-AAC"
|
||||
else:
|
||||
return "AAC"
|
||||
if audioFormat.strip() == "mp3": return "MP3"
|
||||
if audioFormat == "MPEG Audio":
|
||||
if audioCodecID == "55" or audioCodecID == "A_MPEG/L3" or audioProfile == "Layer 3": return "MP3"
|
||||
if audioCodecID == "A_MPEG/L2" or audioProfile == "Layer 2": return "MP2"
|
||||
if audioFormat == "MLP FBA":
|
||||
if audioAdditionalFeatures == "16-ch":
|
||||
return "TrueHD Atmos"
|
||||
else:
|
||||
return "TrueHD"
|
||||
|
||||
return audioFormat
|
||||
|
||||
|
||||
def RadarrFormatVideoCodec(videoFormat, videoCodecID, videoProfile, videoCodecLibrary):
|
||||
if videoFormat == "x264": return "h264"
|
||||
if videoFormat == "AVC" or videoFormat == "V.MPEG4/ISO/AVC": return "h264"
|
||||
if videoFormat == "HEVC" or videoFormat == "V_MPEGH/ISO/HEVC":
|
||||
if videoCodecLibrary.startswith("x265"): return "h265"
|
||||
if videoFormat == "MPEG Video":
|
||||
if videoCodecID == "2" or videoCodecID == "V_MPEG2":
|
||||
return "Mpeg2"
|
||||
else:
|
||||
return "Mpeg"
|
||||
if videoFormat == "MPEG-1 Video": return "Mpeg"
|
||||
if videoFormat == "MPEG-2 Video": return "Mpeg2"
|
||||
if videoFormat == "MPEG-4 Visual":
|
||||
if videoCodecID.endswith("XVID") or videoCodecLibrary.startswith("XviD"): return "XviD"
|
||||
if videoCodecID.endswith("DIV3") or videoCodecID.endswith("DIVX") or videoCodecID.endswith(
|
||||
"DX50") or videoCodecLibrary.startswith("DivX"): return "DivX"
|
||||
if videoFormat == "VC-1": return "VC1"
|
||||
if videoFormat == "WMV2":
|
||||
return "WMV"
|
||||
if videoFormat == "DivX" or videoFormat == "div3":
|
||||
return "DivX"
|
||||
|
||||
return videoFormat
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
update_movies()
|
||||
|
|
|
@ -689,7 +689,7 @@ def refine_from_db(path, video):
|
|||
c = db.cursor()
|
||||
data = c.execute("SELECT table_shows.title, table_episodes.season, table_episodes.episode, table_episodes.title, table_shows.year, table_shows.tvdbId, table_shows.alternateTitles, table_episodes.format, table_episodes.resolution, table_episodes.video_codec, table_episodes.audio_codec FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ?", (path_replace_reverse(path),)).fetchone()
|
||||
db.close()
|
||||
if data != None:
|
||||
if data:
|
||||
video.series = re.sub(r'(\(\d\d\d\d\))' , '', data[0])
|
||||
video.season = int(data[1])
|
||||
video.episode = int(data[2])
|
||||
|
@ -702,8 +702,7 @@ def refine_from_db(path, video):
|
|||
if not video.resolution:
|
||||
video.resolution = str(data[8])
|
||||
if not video.video_codec:
|
||||
if data[9] == 'x264': video.video_codec = 'h264'
|
||||
elif data[9]: video.video_codec = data[9]
|
||||
if data[9]: video.video_codec = data[9]
|
||||
if not video.audio_codec:
|
||||
if data[10]: video.audio_codec = data[10]
|
||||
elif isinstance(video, Movie):
|
||||
|
@ -711,7 +710,7 @@ def refine_from_db(path, video):
|
|||
c = db.cursor()
|
||||
data = c.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec FROM table_movies WHERE path = ?", (path_replace_reverse_movie(path),)).fetchone()
|
||||
db.close()
|
||||
if data != None:
|
||||
if data:
|
||||
video.title = re.sub(r'(\(\d\d\d\d\))' , '', data[0])
|
||||
if int(data[1]) > 0: video.year = int(data[1])
|
||||
video.alternative_titles = ast.literal_eval(data[2])
|
||||
|
|
Loading…
Reference in a new issue