mirror of https://github.com/morpheus65535/bazarr
Merge remote-tracking branch 'origin/development' into updater
This commit is contained in:
commit
fb324cc82c
|
@ -226,7 +226,12 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
|
|||
logging.info('BAZARR Post-processing result for file ' + path + ' : ' + out)
|
||||
|
||||
# fixme: support multiple languages at once
|
||||
return message
|
||||
if media_type == 'series':
|
||||
reversed_path = path_replace_reverse(path)
|
||||
else:
|
||||
reversed_path = path_replace_reverse_movie(path)
|
||||
|
||||
return message, reversed_path, downloaded_language_code2, downloaded_provider, subtitle.score
|
||||
|
||||
if not saved_any:
|
||||
logging.debug('BAZARR No subtitles were found for this file: ' + path)
|
||||
|
@ -431,12 +436,17 @@ def series_download_subtitles(no):
|
|||
for language in ast.literal_eval(episode[1]):
|
||||
if language is not None:
|
||||
notifications.write(msg='Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path_replace(episode[0]), queue='get_subtitle')
|
||||
message = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
|
||||
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
|
||||
series_details[0], providers_list, providers_auth, str(episode[3]),
|
||||
series_details[1], 'series')
|
||||
if message is not None:
|
||||
if result is not None:
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
store_subtitles(path_replace(episode[0]))
|
||||
history_log(1, no, episode[2], message)
|
||||
history_log(1, no, episode[2], message, path, language_code, provider, score)
|
||||
send_notifications(no, episode[2], message)
|
||||
list_missing_subtitles(no)
|
||||
|
||||
|
@ -457,11 +467,16 @@ def movies_download_subtitles(no):
|
|||
for language in ast.literal_eval(movie[1]):
|
||||
if language is not None:
|
||||
notifications.write(msg='Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path_replace_movie(movie[0]), queue='get_subtitle')
|
||||
message = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)), movie[4],
|
||||
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)), movie[4],
|
||||
providers_list, providers_auth, str(movie[3]), movie[5], 'movie')
|
||||
if message is not None:
|
||||
if result is not None:
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
store_subtitles_movie(path_replace_movie(movie[0]))
|
||||
history_log_movie(1, no, message)
|
||||
history_log_movie(1, no, message, path, language_code, provider, score)
|
||||
send_notifications_movie(no, message)
|
||||
list_missing_subtitles_movies(no)
|
||||
|
||||
|
@ -504,13 +519,18 @@ def wanted_download_subtitles(path):
|
|||
if search_active(attempt[i][1]):
|
||||
notifications.write(
|
||||
msg='Searching ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path, queue='get_subtitle')
|
||||
message = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
|
||||
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
|
||||
episode[4], providers_list, providers_auth, str(episode[5]),
|
||||
episode[7], 'series')
|
||||
if message is not None:
|
||||
if result is not None:
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
store_subtitles(path_replace(episode[0]))
|
||||
list_missing_subtitles(episode[3])
|
||||
history_log(1, episode[3], episode[2], message)
|
||||
history_log(1, episode[3], episode[2], message, path, language_code, provider, score)
|
||||
send_notifications(episode[3], episode[2], message)
|
||||
else:
|
||||
logging.debug(
|
||||
|
@ -552,13 +572,18 @@ def wanted_download_subtitles_movie(path):
|
|||
if search_active(attempt[i][1]) is True:
|
||||
notifications.write(
|
||||
msg='Searching ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path, queue='get_subtitle')
|
||||
message = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)),
|
||||
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)),
|
||||
movie[4], providers_list, providers_auth, str(movie[5]), movie[7],
|
||||
'movie')
|
||||
if message is not None:
|
||||
if result is not None:
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
store_subtitles_movie(path_replace_movie(movie[0]))
|
||||
list_missing_subtitles_movies(movie[3])
|
||||
history_log_movie(1, movie[3], message)
|
||||
history_log_movie(1, movie[3], message, path, language_code, provider, score)
|
||||
send_notifications_movie(movie[3], message)
|
||||
else:
|
||||
logging.info(
|
||||
|
|
|
@ -4,8 +4,11 @@ import os
|
|||
import re
|
||||
import types
|
||||
import logging
|
||||
import sqlite3
|
||||
|
||||
from config import settings
|
||||
from get_args import args
|
||||
from get_languages import alpha2_from_language
|
||||
|
||||
|
||||
def path_replace(path):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# coding=utf-8
|
||||
|
||||
bazarr_version = '0.7.2'
|
||||
bazarr_version = '0.7.3'
|
||||
|
||||
import gc
|
||||
import sys
|
||||
|
@ -1633,8 +1633,8 @@ def remove_subtitles():
|
|||
os.remove(subtitlesPath)
|
||||
result = language_from_alpha3(language) + " subtitles deleted from disk."
|
||||
history_log(0, sonarrSeriesId, sonarrEpisodeId, result)
|
||||
except OSError:
|
||||
pass
|
||||
except OSError as e:
|
||||
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
|
||||
store_subtitles(unicode(episodePath))
|
||||
list_missing_subtitles(sonarrSeriesId)
|
||||
|
||||
|
@ -1647,15 +1647,13 @@ def remove_subtitles_movie():
|
|||
language = request.forms.get('language')
|
||||
subtitlesPath = request.forms.get('subtitlesPath')
|
||||
radarrId = request.forms.get('radarrId')
|
||||
subfolder = ('/' + get_subtitle_destination_folder() + '/') if get_subtitle_destination_folder() else '/'
|
||||
subtitlesPath = os.path.split(subtitlesPath)
|
||||
|
||||
try:
|
||||
os.remove(subtitlesPath[0] + subfolder + subtitlesPath[1])
|
||||
os.remove(subtitlesPath)
|
||||
result = language_from_alpha3(language) + " subtitles deleted from disk."
|
||||
history_log_movie(0, radarrId, result)
|
||||
except OSError:
|
||||
pass
|
||||
except OSError as e:
|
||||
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
|
||||
store_subtitles_movie(unicode(moviePath))
|
||||
list_missing_subtitles_movies(radarrId)
|
||||
|
||||
|
@ -1682,8 +1680,13 @@ def get_subtitle():
|
|||
result = download_subtitle(episodePath, language, hi, providers_list, providers_auth, sceneName, title,
|
||||
'series')
|
||||
if result is not None:
|
||||
history_log(1, sonarrSeriesId, sonarrEpisodeId, result)
|
||||
send_notifications(sonarrSeriesId, sonarrEpisodeId, result)
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
|
||||
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
|
||||
store_subtitles(unicode(episodePath))
|
||||
list_missing_subtitles(sonarrSeriesId)
|
||||
redirect(ref)
|
||||
|
@ -1733,8 +1736,13 @@ def manual_get_subtitle():
|
|||
result = manual_download_subtitle(episodePath, language, hi, subtitle, selected_provider, providers_auth,
|
||||
sceneName, title, 'series')
|
||||
if result is not None:
|
||||
history_log(1, sonarrSeriesId, sonarrEpisodeId, result)
|
||||
send_notifications(sonarrSeriesId, sonarrEpisodeId, result)
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
|
||||
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
|
||||
store_subtitles(unicode(episodePath))
|
||||
list_missing_subtitles(sonarrSeriesId)
|
||||
redirect(ref)
|
||||
|
@ -1762,8 +1770,13 @@ def get_subtitle_movie():
|
|||
try:
|
||||
result = download_subtitle(moviePath, language, hi, providers_list, providers_auth, sceneName, title, 'movie')
|
||||
if result is not None:
|
||||
history_log_movie(1, radarrId, result)
|
||||
send_notifications_movie(radarrId, result)
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
history_log_movie(1, radarrId, message, path, language_code, provider, score)
|
||||
send_notifications_movie(radarrId, message)
|
||||
store_subtitles_movie(unicode(moviePath))
|
||||
list_missing_subtitles_movies(radarrId)
|
||||
redirect(ref)
|
||||
|
@ -1812,8 +1825,13 @@ def manual_get_subtitle_movie():
|
|||
result = manual_download_subtitle(moviePath, language, hi, subtitle, selected_provider, providers_auth,
|
||||
sceneName, title, 'movie')
|
||||
if result is not None:
|
||||
history_log_movie(1, radarrId, result)
|
||||
send_notifications_movie(radarrId, result)
|
||||
message = result[0]
|
||||
path = result[1]
|
||||
language_code = result[2]
|
||||
provider = result[3]
|
||||
score = result[4]
|
||||
history_log_movie(1, radarrId, message, path, language_code, provider, score)
|
||||
send_notifications_movie(radarrId, message)
|
||||
store_subtitles_movie(unicode(moviePath))
|
||||
list_missing_subtitles_movies(radarrId)
|
||||
redirect(ref)
|
||||
|
|
|
@ -121,5 +121,20 @@ if os.path.exists(os.path.join(args.config_dir, 'db', 'bazarr.db')):
|
|||
execute_now('sync_episodes')
|
||||
if settings.general.getboolean('use_radarr'):
|
||||
execute_now('update_movies')
|
||||
|
||||
try:
|
||||
c.execute('alter table table_history add column "video_path" "text"')
|
||||
c.execute('alter table table_history add column "language" "text"')
|
||||
c.execute('alter table table_history add column "provider" "text"')
|
||||
c.execute('alter table table_history add column "score" "text"')
|
||||
|
||||
c.execute('alter table table_history_movie add column "video_path" "text"')
|
||||
c.execute('alter table table_history_movie add column "language" "text"')
|
||||
c.execute('alter table table_history_movie add column "provider" "text"')
|
||||
c.execute('alter table table_history_movie add column "score" "text"')
|
||||
|
||||
db.commit()
|
||||
except:
|
||||
pass
|
||||
|
||||
db.close()
|
||||
|
|
|
@ -7,15 +7,15 @@ import time
|
|||
from get_args import args
|
||||
|
||||
|
||||
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
|
||||
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description, video_path=None, language=None, provider=None, score=None):
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
history = c.execute(
|
||||
'''INSERT INTO table_history(action, sonarrSeriesId, sonarrEpisodeId, timestamp, description) VALUES (?, ?, ?, ?, ?)''',
|
||||
(action, sonarrSeriesId, sonarrEpisodeId, time.time(), description))
|
||||
'''INSERT INTO table_history(action, sonarrSeriesId, sonarrEpisodeId, timestamp, description, video_path, language, provider, score) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(action, sonarrSeriesId, sonarrEpisodeId, time.time(), description, video_path, language, provider, score))
|
||||
|
||||
# Commit changes to DB
|
||||
db.commit()
|
||||
|
@ -24,14 +24,14 @@ def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
|
|||
db.close()
|
||||
|
||||
|
||||
def history_log_movie(action, radarrId, description):
|
||||
def history_log_movie(action, radarrId, description, video_path=None, language=None, provider=None, score=None):
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
history = c.execute(
|
||||
'''INSERT INTO table_history_movie(action, radarrId, timestamp, description) VALUES (?, ?, ?, ?)''',
|
||||
(action, radarrId, time.time(), description))
|
||||
'''INSERT INTO table_history_movie(action, radarrId, timestamp, description, video_path, language, provider, score) VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(action, radarrId, time.time(), description, video_path, language, provider, score))
|
||||
|
||||
# Commit changes to DB
|
||||
db.commit()
|
||||
|
|
Loading…
Reference in New Issue