Some fixes and improvements.

pull/387/head
Louis Vézina 5 years ago
parent 6d7e547d6a
commit 3ffce6e5fa

@ -53,7 +53,7 @@ def sync_episodes():
seriesIdListLength = len(seriesIdList) seriesIdListLength = len(seriesIdList)
for i, seriesId in enumerate(seriesIdList, 1): for i, seriesId in enumerate(seriesIdList, 1):
notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength, duration='long') notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength)
# Get episodes data for a series from Sonarr # Get episodes data for a series from Sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
try: try:
@ -160,8 +160,6 @@ def sync_episodes():
else: else:
logging.debug("BAZARR More than 5 episodes were added during this sync then we wont search for subtitles.") logging.debug("BAZARR More than 5 episodes were added during this sync then we wont search for subtitles.")
notifications.write(msg='Episodes sync from Sonarr ended.', queue='get_episodes')
def SonarrFormatAudioCodec(audioCodec): def SonarrFormatAudioCodec(audioCodec):
if audioCodec == 'AC-3': return 'AC3' if audioCodec == 'AC-3': return 'AC3'

@ -14,7 +14,6 @@ from get_subtitle import movies_download_subtitles
def update_movies(): def update_movies():
notifications.write(msg="Update movies list from Radarr is running...", queue='get_movies')
logging.debug('BAZARR Starting movie sync from Radarr.') logging.debug('BAZARR Starting movie sync from Radarr.')
apikey_radarr = settings.radarr.apikey apikey_radarr = settings.radarr.apikey
movie_default_enabled = settings.general.getboolean('movie_default_enabled') movie_default_enabled = settings.general.getboolean('movie_default_enabled')
@ -53,8 +52,8 @@ def update_movies():
moviesIdListLength = len(r.json()) moviesIdListLength = len(r.json())
for i, movie in enumerate(r.json(), 1): for i, movie in enumerate(r.json(), 1):
notifications.write(msg="Getting data for this movie...", queue='get_movies', item=i, notifications.write(msg="Getting movies data from Radarr...", queue='get_movies', item=i,
length=moviesIdListLength, duration='long') length=moviesIdListLength)
if movie['hasFile'] is True: if movie['hasFile'] is True:
if 'movieFile' in movie: if 'movieFile' in movie:
if movie["path"] != None and movie['movieFile']['relativePath'] != None: if movie["path"] != None and movie['movieFile']['relativePath'] != None:
@ -198,8 +197,6 @@ def update_movies():
logging.debug("BAZARR More than 5 movies were added during this sync then we wont search for subtitles.") logging.debug("BAZARR More than 5 movies were added during this sync then we wont search for subtitles.")
logging.debug('BAZARR All movies synced from Radarr into database.') logging.debug('BAZARR All movies synced from Radarr into database.')
notifications.write(msg="Update movies list from Radarr is ended.", queue='get_movies')
def get_profile_list(): def get_profile_list():

@ -52,9 +52,10 @@ def update_series():
current_shows_sonarr = [] current_shows_sonarr = []
series_to_update = [] series_to_update = []
series_to_add = [] series_to_add = []
for show in r.json(): seriesListLength = len(r.json())
notifications.write(msg="Getting series data for this show: " + show['title'], queue='get_series') for i, show in enumerate(r.json(), 1):
notifications.write(msg="Getting series data from Sonarr...", queue='get_series', item=i, length=seriesListLength)
try: try:
overview = unicode(show['overview']) overview = unicode(show['overview'])
except: except:
@ -126,8 +127,6 @@ def update_series():
c.executemany('DELETE FROM table_shows WHERE tvdbId = ?', deleted_items) c.executemany('DELETE FROM table_shows WHERE tvdbId = ?', deleted_items)
db.commit() db.commit()
db.close() db.close()
notifications.write(msg="Update series list from Sonarr is ended.", queue='get_series')
def get_profile_list(): def get_profile_list():

@ -351,7 +351,6 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
return None return None
else: else:
if not subtitle.is_valid(): if not subtitle.is_valid():
notifications.write(msg='No valid subtitles file found for this file: ' + path, queue='get_subtitle')
logging.exception('BAZARR No valid subtitles file found for this file: ' + path) logging.exception('BAZARR No valid subtitles file found for this file: ' + path)
return return
logging.debug('BAZARR Subtitles file downloaded for this file:' + path) logging.debug('BAZARR Subtitles file downloaded for this file:' + path)
@ -453,7 +452,7 @@ def series_download_subtitles(no):
for i, episode in enumerate(episodes_details, 1): for i, episode in enumerate(episodes_details, 1):
for language in ast.literal_eval(episode[1]): for language in ast.literal_eval(episode[1]):
if language is not None: if language is not None:
notifications.write(msg='Searching for series subtitles', queue='get_subtitle', duration='long', item=i, length=count_episodes_details) notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', item=i, length=count_episodes_details)
result = 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[0], providers_list, providers_auth, str(episode[3]),
series_details[1], 'series') series_details[1], 'series')
@ -468,7 +467,8 @@ def series_download_subtitles(no):
send_notifications(no, episode[2], message) send_notifications(no, episode[2], message)
list_missing_subtitles(no) list_missing_subtitles(no)
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle') if count_episodes_details:
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def episode_download_subtitles(no): def episode_download_subtitles(no):
@ -523,7 +523,7 @@ def movies_download_subtitles(no):
for i, language in enumerate(ast.literal_eval(movie[1]), 1): for i, language in enumerate(ast.literal_eval(movie[1]), 1):
if language is not None: if language is not None:
notifications.write(msg='Searching for movies subtitles', queue='get_subtitle', duration='long', item=i, length=count_movie) notifications.write(msg='Searching for movies subtitles', queue='get_subtitle', item=i, length=count_movie)
result = 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') providers_list, providers_auth, str(movie[3]), movie[5], 'movie')
if result is not None: if result is not None:
@ -537,7 +537,8 @@ def movies_download_subtitles(no):
send_notifications_movie(no, message) send_notifications_movie(no, message)
list_missing_subtitles_movies(no) list_missing_subtitles_movies(no)
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle') if count_movie:
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def wanted_download_subtitles(path, l, count_episodes): def wanted_download_subtitles(path, l, count_episodes):
@ -574,7 +575,7 @@ def wanted_download_subtitles(path, l, count_episodes):
for i in range(len(attempt)): for i in range(len(attempt)):
if attempt[i][0] == language: if attempt[i][0] == language:
if search_active(attempt[i][1]): if search_active(attempt[i][1]):
notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', duration='long', item=l, length=count_episodes) notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', item=l, length=count_episodes)
result = 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[4], providers_list, providers_auth, str(episode[5]),
episode[7], 'series') episode[7], 'series')
@ -589,8 +590,6 @@ def wanted_download_subtitles(path, l, count_episodes):
history_log(1, episode[3], episode[2], message, path, language_code, provider, score) history_log(1, episode[3], episode[2], message, path, language_code, provider, score)
send_notifications(episode[3], episode[2], message) send_notifications(episode[3], episode[2], message)
else: else:
notifications.write(msg='Searching for series subtitles', queue='get_subtitle', duration='long',
item=l, length=count_episodes)
logging.debug( logging.debug(
'BAZARR Search is not active for episode ' + episode[0] + ' Language: ' + attempt[i][0]) 'BAZARR Search is not active for episode ' + episode[0] + ' Language: ' + attempt[i][0])
@ -628,7 +627,7 @@ def wanted_download_subtitles_movie(path, l, count_movies):
for i in range(len(attempt)): for i in range(len(attempt)):
if attempt[i][0] == language: if attempt[i][0] == language:
if search_active(attempt[i][1]) is True: if search_active(attempt[i][1]) is True:
notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', duration='long', item=l, length=count_movies) notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', item=l, length=count_movies)
result = 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[4], providers_list, providers_auth, str(movie[5]), movie[7],
'movie') 'movie')
@ -643,8 +642,6 @@ def wanted_download_subtitles_movie(path, l, count_movies):
history_log_movie(1, movie[3], message, path, language_code, provider, score) history_log_movie(1, movie[3], message, path, language_code, provider, score)
send_notifications_movie(movie[3], message) send_notifications_movie(movie[3], message)
else: else:
notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', duration='long',
item=l, length=count_movies)
logging.info( logging.info(
'BAZARR Search is not active for movie ' + movie[0] + ' Language: ' + attempt[i][0]) 'BAZARR Search is not active for movie ' + movie[0] + ' Language: ' + attempt[i][0])
@ -690,7 +687,7 @@ def wanted_search_missing_subtitles():
for i, movie in enumerate(movies, 1): for i, movie in enumerate(movies, 1):
wanted_download_subtitles_movie(movie[0], i, count_movies) wanted_download_subtitles_movie(movie[0], i, count_movies)
else: else:
notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle') notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long')
logging.info("BAZARR All providers are throttled") logging.info("BAZARR All providers are throttled")
logging.info('BAZARR Finished searching for missing subtitles. Check histories for more information.') logging.info('BAZARR Finished searching for missing subtitles. Check histories for more information.')
@ -800,12 +797,12 @@ def upgrade_subtitles():
episodes_to_upgrade = [] episodes_to_upgrade = []
for episode in episodes_list: for episode in episodes_list:
if os.path.exists(path_replace(episode[0])) and int(episode[2]) < 360: if os.path.exists(path_replace(episode[0])) and int(episode[2]) < 357:
episodes_to_upgrade.append(episode) episodes_to_upgrade.append(episode)
movies_to_upgrade = [] movies_to_upgrade = []
for movie in movies_list: for movie in movies_list:
if os.path.exists(path_replace_movie(movie[0])) and int(movie[2]) < 120: if os.path.exists(path_replace_movie(movie[0])) and int(movie[2]) < 117:
movies_to_upgrade.append(movie) movies_to_upgrade.append(movie)
providers_list = get_providers() providers_list = get_providers()
@ -817,7 +814,7 @@ def upgrade_subtitles():
for i, episode in enumerate(episodes_to_upgrade, 1): for i, episode in enumerate(episodes_to_upgrade, 1):
if episode[1] in ast.literal_eval(str(episode[9])): if episode[1] in ast.literal_eval(str(episode[9])):
notifications.write(msg='Upgrading series subtitles...', notifications.write(msg='Upgrading series subtitles...',
queue='upgrade_subtitle', duration='long', item=i, length=count_episode_to_upgrade) queue='upgrade_subtitle', item=i, length=count_episode_to_upgrade)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])), result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])),
episode[3], providers_list, providers_auth, str(episode[4]), episode[3], providers_list, providers_auth, str(episode[4]),
episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True) episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True)
@ -834,7 +831,7 @@ def upgrade_subtitles():
for i, movie in enumerate(movies_to_upgrade, 1): for i, movie in enumerate(movies_to_upgrade, 1):
if movie[1] in ast.literal_eval(str(movie[8])): if movie[1] in ast.literal_eval(str(movie[8])):
notifications.write(msg='Upgrading movie subtitles...', notifications.write(msg='Upgrading movie subtitles...',
queue='upgrade_subtitle', duration='long', item=i, length=count_movie_to_upgrade) queue='upgrade_subtitle', item=i, length=count_movie_to_upgrade)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])), result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])),
movie[3], providers_list, providers_auth, str(movie[4]), movie[3], providers_list, providers_auth, str(movie[4]),
movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True) movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True)

@ -302,7 +302,7 @@ def series_full_scan_subtitles():
for i, episode in enumerate(episodes, 1): for i, episode in enumerate(episodes, 1):
notifications.write(msg='Updating all episodes subtitles from disk...', notifications.write(msg='Updating all episodes subtitles from disk...',
queue='list_subtitles_series', duration='long', item=i, length=count_episodes) queue='list_subtitles_series', item=i, length=count_episodes)
store_subtitles(path_replace(episode[0])) store_subtitles(path_replace(episode[0]))
gc.collect() gc.collect()
@ -317,7 +317,7 @@ def movies_full_scan_subtitles():
for i, movie in enumerate(movies, 1): for i, movie in enumerate(movies, 1):
notifications.write(msg='Updating all movies subtitles from disk...', notifications.write(msg='Updating all movies subtitles from disk...',
queue='list_subtitles_movies', duration='long', item=i, length=count_movies) queue='list_subtitles_movies', item=i, length=count_movies)
store_subtitles_movie(path_replace_movie(movie[0])) store_subtitles_movie(path_replace_movie(movie[0]))
gc.collect() gc.collect()

@ -320,6 +320,8 @@
var notificationTimeout; var notificationTimeout;
var timeout; var timeout;
var killer; var killer;
var item = {};
var length = {};
function doNotificationsAjax() { function doNotificationsAjax() {
$.ajax({ $.ajax({
url: url_notifications, url: url_notifications,
@ -337,7 +339,7 @@
if (length === 0) { if (length === 0) {
var message = msg; var message = msg;
} else { } else {
var message = msg + '<p><div class="ui disabled progress notification_progress" style="margin-bottom: -0.25em"><div class="bar"><div class="progress"></div></div></div>' var message = msg + '<p><div class="ui disabled progress notification_progress" data-value=' + item + ' data-total=' + length + ' style="margin-bottom: -0.25em"><div class="bar"><div class="progress"></div></div></div>'
} }
if (duration === 'temporary') { if (duration === 'temporary') {
@ -374,14 +376,12 @@
timeout: timeout, timeout: timeout,
killer: killer, killer: killer,
buttons: button, buttons: button,
force: true force: false
}).show(); }).show();
$('.notification_progress').progress({ $('.notification_progress').progress({
duration : 0, duration : 0,
autoSuccess: false, autoSuccess: false,
value : item,
total : length,
label: 'ratio', label: 'ratio',
text: { text: {
ratio: '{value} / {total}' ratio: '{value} / {total}'

Loading…
Cancel
Save