mirror of https://github.com/morpheus65535/bazarr
Merge branch 'development'
This commit is contained in:
commit
7c70564646
165
bazarr.py
165
bazarr.py
|
@ -1,4 +1,4 @@
|
|||
bazarr_version = '0.6.4'
|
||||
bazarr_version = '0.6.5'
|
||||
|
||||
import gc
|
||||
gc.enable()
|
||||
|
@ -85,7 +85,8 @@ import hashlib
|
|||
import time
|
||||
|
||||
from get_languages import load_language_in_db, language_from_alpha3
|
||||
from get_providers import *
|
||||
from get_providers import load_providers, get_providers, get_providers_auth
|
||||
load_providers()
|
||||
|
||||
from get_series import *
|
||||
from get_episodes import *
|
||||
|
@ -312,26 +313,29 @@ def serieseditor():
|
|||
output = template('serieseditor', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, base_url=base_url, single_language=single_language)
|
||||
return output
|
||||
|
||||
|
||||
@route(base_url + 'search_json/<query>', method='GET')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def search_json(query):
|
||||
authorize()
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title", ('%'+query+'%',))
|
||||
series = c.fetchall()
|
||||
|
||||
c.execute("SELECT title, radarrId FROM table_movies WHERE title LIKE ? ORDER BY title", ('%' + query + '%',))
|
||||
movies = c.fetchall()
|
||||
|
||||
|
||||
search_list = []
|
||||
for serie in series:
|
||||
search_list.append(dict([('name', serie[0]), ('url', base_url + 'episodes/' + str(serie[1]))]))
|
||||
|
||||
for movie in movies:
|
||||
search_list.append(dict([('name', movie[0]), ('url', base_url + 'movie/' + str(movie[1]))]))
|
||||
|
||||
if get_general_settings()[12] is True:
|
||||
c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title",
|
||||
('%' + query + '%',))
|
||||
series = c.fetchall()
|
||||
for serie in series:
|
||||
search_list.append(dict([('name', serie[0]), ('url', base_url + 'episodes/' + str(serie[1]))]))
|
||||
|
||||
if get_general_settings()[13] is True:
|
||||
c.execute("SELECT title, radarrId FROM table_movies WHERE title LIKE ? ORDER BY title", ('%' + query + '%',))
|
||||
movies = c.fetchall()
|
||||
for movie in movies:
|
||||
search_list.append(dict([('name', movie[0]), ('url', base_url + 'movie/' + str(movie[1]))]))
|
||||
c.close()
|
||||
|
||||
response.content_type = 'application/json'
|
||||
return dict(items=search_list)
|
||||
|
||||
|
@ -796,6 +800,8 @@ def save_settings():
|
|||
settings_general_ip = request.forms.get('settings_general_ip')
|
||||
settings_general_port = request.forms.get('settings_general_port')
|
||||
settings_general_baseurl = request.forms.get('settings_general_baseurl')
|
||||
if settings_general_baseurl.endswith('/') is False:
|
||||
settings_general_baseurl += '/'
|
||||
settings_general_loglevel = request.forms.get('settings_general_loglevel')
|
||||
settings_general_sourcepath = request.forms.getall('settings_general_sourcepath')
|
||||
settings_general_destpath = request.forms.getall('settings_general_destpath')
|
||||
|
@ -1473,28 +1479,8 @@ def get_subtitle():
|
|||
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
|
||||
# tvdbid = request.forms.get('tvdbid')
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1")
|
||||
enabled_providers = c.fetchall()
|
||||
c.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
try:
|
||||
result = download_subtitle(episodePath, language, hi, providers_list, providers_auth, sceneName, 'series')
|
||||
|
@ -1518,28 +1504,8 @@ def manual_search_json():
|
|||
language = request.forms.get('language')
|
||||
hi = request.forms.get('hi')
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1")
|
||||
enabled_providers = c.fetchall()
|
||||
c.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
data = manual_search(episodePath, language, hi, providers_list, providers_auth, sceneName, 'series')
|
||||
return dict(data=data)
|
||||
|
@ -1559,19 +1525,8 @@ def manual_get_subtitle():
|
|||
sonarrSeriesId = request.forms.get('sonarrSeriesId')
|
||||
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
provider = c.execute("SELECT * FROM table_settings_providers WHERE name = ?",(selected_provider,)).fetchone()
|
||||
c.close()
|
||||
providers_auth = {}
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
try:
|
||||
result = manual_download_subtitle(episodePath, language, hi, subtitle, selected_provider, providers_auth, sceneName, 'series')
|
||||
|
@ -1597,28 +1552,8 @@ def get_subtitle_movie():
|
|||
radarrId = request.forms.get('radarrId')
|
||||
# tmdbid = request.forms.get('tmdbid')
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1")
|
||||
enabled_providers = c.fetchall()
|
||||
c.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
try:
|
||||
result = download_subtitle(moviePath, language, hi, providers_list, providers_auth, sceneName, 'movie')
|
||||
|
@ -1642,28 +1577,8 @@ def manual_search_movie_json():
|
|||
language = request.forms.get('language')
|
||||
hi = request.forms.get('hi')
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1")
|
||||
enabled_providers = c.fetchall()
|
||||
c.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
data = manual_search(moviePath, language, hi, providers_list, providers_auth, sceneName, 'movie')
|
||||
return dict(data=data)
|
||||
|
@ -1682,19 +1597,8 @@ def manual_get_subtitle_movie():
|
|||
subtitle = request.forms.get('subtitle')
|
||||
radarrId = request.forms.get('radarrId')
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
provider = c.execute("SELECT * FROM table_settings_providers WHERE name = ?",(selected_provider,)).fetchone()
|
||||
c.close()
|
||||
providers_auth = {}
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
try:
|
||||
result = manual_download_subtitle(moviePath, language, hi, subtitle, selected_provider, providers_auth, sceneName, 'movie')
|
||||
|
@ -1756,6 +1660,9 @@ def test_url(protocol, url):
|
|||
else:
|
||||
return dict(status=True, version=result)
|
||||
|
||||
import warnings
|
||||
# Mute DeprecationWarning
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
|
||||
logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
|
||||
run(host=ip, port=port, server='waitress', app=app)
|
||||
|
|
|
@ -31,11 +31,19 @@ def sync_episodes():
|
|||
c = db.cursor()
|
||||
|
||||
# Get current episodes id in DB
|
||||
current_episodes_db = c.execute('SELECT sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, scene_name, monitored FROM table_episodes').fetchall()
|
||||
current_episodes_db = c.execute('SELECT sonarrEpisodeId FROM table_episodes').fetchall()
|
||||
|
||||
current_episodes_db_list = [x[0] for x in current_episodes_db]
|
||||
current_episodes_sonarr = []
|
||||
episodes_to_update = []
|
||||
episodes_to_add = []
|
||||
|
||||
# Get sonarrId for each series from database
|
||||
current_episodes_sonarr = []
|
||||
seriesIdList = c.execute("SELECT sonarrSeriesId FROM table_shows").fetchall()
|
||||
|
||||
# Close database connection
|
||||
c.close()
|
||||
|
||||
for seriesId in seriesIdList:
|
||||
# Get episodes data for a series from Sonarr
|
||||
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
|
||||
|
@ -61,27 +69,37 @@ def sync_episodes():
|
|||
sceneName = episode['episodeFile']['sceneName']
|
||||
else:
|
||||
sceneName = None
|
||||
current_episodes_sonarr.append((episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'], sceneName, str(bool(episode['monitored']))))
|
||||
|
||||
added_episodes = list(set(current_episodes_sonarr) - set(current_episodes_db))
|
||||
removed_episodes = list(set(current_episodes_db) - set(current_episodes_sonarr))
|
||||
# Add episodes in sonarr to current episode list
|
||||
current_episodes_sonarr.append(episode['id'])
|
||||
|
||||
if episode['id'] in current_episodes_db_list:
|
||||
episodes_to_update.append((episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'], sceneName, str(bool(episode['monitored'])), 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']))))
|
||||
|
||||
removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr))
|
||||
|
||||
# Update or insert movies in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
updated_result = c.executemany('''UPDATE table_episodes SET title = ?, path = ?, season = ?, episode = ?, scene_name = ?, monitored = ? WHERE sonarrEpisodeId = ?''', episodes_to_update)
|
||||
db.commit()
|
||||
|
||||
added_result = c.executemany('''INSERT OR IGNORE INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, scene_name, monitored) VALUES (?, ?, ?, ?, ?, ?, ?, ?)''', episodes_to_add)
|
||||
db.commit()
|
||||
|
||||
for removed_episode in removed_episodes:
|
||||
c.execute('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?', (removed_episode[1],))
|
||||
c.execute('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?', (removed_episode,))
|
||||
db.commit()
|
||||
|
||||
for added_episode in added_episodes:
|
||||
try:
|
||||
c.execute('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, scene_name, monitored) VALUES (?, ?, ?, ?, ?, ?, ?, ?)''', added_episode)
|
||||
except sqlite3.IntegrityError as e:
|
||||
logging.exception("You're probably an early adopter of Bazarr and this is a known issue. Please open an issue on Github and we'll fix this.")
|
||||
else:
|
||||
db.commit()
|
||||
store_subtitles(path_replace(added_episode[3]))
|
||||
|
||||
# Close database connection
|
||||
c.close()
|
||||
|
||||
for added_episode in episodes_to_add:
|
||||
store_subtitles(path_replace(added_episode[3]))
|
||||
|
||||
logging.debug('All episodes synced from Sonarr into database.')
|
||||
|
||||
list_missing_subtitles()
|
||||
|
|
101
get_movies.py
101
get_movies.py
|
@ -12,16 +12,11 @@ def update_movies():
|
|||
logging.debug('Starting movie sync from Radarr.')
|
||||
from get_settings import get_radarr_settings
|
||||
url_radarr = get_radarr_settings()[6]
|
||||
# url_radarr_short = get_radarr_settings()[7]
|
||||
apikey_radarr = get_radarr_settings()[4]
|
||||
movie_default_enabled = get_general_settings()[18]
|
||||
movie_default_language = get_general_settings()[19]
|
||||
movie_default_hi = get_general_settings()[20]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
if apikey_radarr == None:
|
||||
pass
|
||||
else:
|
||||
|
@ -42,69 +37,85 @@ def update_movies():
|
|||
logging.exception("Error trying to get movies from Radarr.")
|
||||
else:
|
||||
# Get current movies in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
current_movies_db = c.execute('SELECT tmdbId FROM table_movies').fetchall()
|
||||
db.close()
|
||||
|
||||
current_movies_db_list = [x[0] for x in current_movies_db]
|
||||
current_movies_radarr = []
|
||||
movies_to_update = []
|
||||
movies_to_add = []
|
||||
|
||||
for movie in r.json():
|
||||
if movie['hasFile'] is True:
|
||||
try:
|
||||
overview = unicode(movie['overview'])
|
||||
except:
|
||||
overview = ""
|
||||
try:
|
||||
poster_big = movie['images'][0]['url']
|
||||
poster = os.path.splitext(poster_big)[0] + '-500' + os.path.splitext(poster_big)[1]
|
||||
except:
|
||||
poster = ""
|
||||
try:
|
||||
fanart = movie['images'][1]['url']
|
||||
except:
|
||||
fanart = ""
|
||||
|
||||
if 'movieFile' in movie:
|
||||
try:
|
||||
overview = unicode(movie['overview'])
|
||||
except:
|
||||
overview = ""
|
||||
try:
|
||||
poster_big = movie['images'][0]['url']
|
||||
poster = os.path.splitext(poster_big)[0] + '-500' + os.path.splitext(poster_big)[1]
|
||||
except:
|
||||
poster = ""
|
||||
try:
|
||||
fanart = movie['images'][1]['url']
|
||||
except:
|
||||
fanart = ""
|
||||
|
||||
if 'sceneName' in movie['movieFile']:
|
||||
sceneName = movie['movieFile']['sceneName']
|
||||
else:
|
||||
sceneName = None
|
||||
else:
|
||||
sceneName = None
|
||||
|
||||
# Add movies in radarr to current movies list
|
||||
current_movies_radarr.append(unicode(movie['tmdbId']))
|
||||
# Add movies in radarr to current movies list
|
||||
current_movies_radarr.append(unicode(movie['tmdbId']))
|
||||
|
||||
# Detect file separator
|
||||
if movie['path'][0] == "/":
|
||||
separator = "/"
|
||||
else:
|
||||
separator = "\\"
|
||||
|
||||
# Update or insert movies list in database table
|
||||
try:
|
||||
if movie_default_enabled is True:
|
||||
c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored']))))
|
||||
# Detect file separator
|
||||
if movie['path'][0] == "/":
|
||||
separator = "/"
|
||||
else:
|
||||
c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), '[]',(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored']))))
|
||||
except:
|
||||
c.execute('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ? WHERE tmdbid = ?''', (movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"]))
|
||||
separator = "\\"
|
||||
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
if unicode(movie['tmdbId']) in current_movies_db_list:
|
||||
movies_to_update.append((movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"]))
|
||||
else:
|
||||
if movie_default_enabled is True:
|
||||
movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored']))))
|
||||
else:
|
||||
movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored']))))
|
||||
|
||||
# Update or insert movies in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
updated_result = c.executemany('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ? WHERE tmdbid = ?''', movies_to_update)
|
||||
db.commit()
|
||||
|
||||
if movie_default_enabled is True:
|
||||
added_result = c.executemany('''INSERT OR IGNORE INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)''', movies_to_add)
|
||||
db.commit()
|
||||
else:
|
||||
added_result = c.executemany('''INSERT OR IGNORE INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), '[]',(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?, ?, ?)''', movies_to_add)
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
# Delete movies not in radarr anymore
|
||||
added_movies = list(set(current_movies_radarr) - set(current_movies_db_list))
|
||||
removed_movies = list(set(current_movies_db_list) - set(current_movies_radarr))
|
||||
|
||||
for removed_movie in removed_movies:
|
||||
c.execute('DELETE FROM table_movies WHERE tmdbId = ?', (removed_movie,))
|
||||
db.commit()
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.executemany('DELETE FROM table_movies WHERE tmdbId = ?', removed_movies)
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
for added_movie in added_movies:
|
||||
added_path = c.execute('SELECT path FROM table_movies WHERE tmdbId = ?', (added_movie,)).fetchone()
|
||||
store_subtitles_movie(path_replace_movie(added_path[0]))
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
||||
db.close()
|
||||
|
||||
logging.debug('All movies synced from Radarr into database.')
|
||||
|
||||
|
|
|
@ -3,29 +3,65 @@ from get_argv import config_dir
|
|||
import sqlite3
|
||||
import os
|
||||
from subliminal import provider_manager
|
||||
import collections
|
||||
|
||||
# Get providers list from subliminal
|
||||
providers_list = sorted(provider_manager.names())
|
||||
def load_providers():
|
||||
# Get providers list from subliminal
|
||||
providers_list = sorted(provider_manager.names())
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Remove unsupported providers
|
||||
providers_in_db = c.execute('SELECT name FROM table_settings_providers').fetchall()
|
||||
for provider_in_db in providers_in_db:
|
||||
if provider_in_db[0] not in providers_list:
|
||||
c.execute('DELETE FROM table_settings_providers WHERE name = ?', (provider_in_db[0], ))
|
||||
# Remove unsupported providers
|
||||
providers_in_db = c.execute('SELECT name FROM table_settings_providers').fetchall()
|
||||
for provider_in_db in providers_in_db:
|
||||
if provider_in_db[0] not in providers_list:
|
||||
c.execute('DELETE FROM table_settings_providers WHERE name = ?', (provider_in_db[0], ))
|
||||
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
|
||||
# Insert providers in database table
|
||||
for provider_name in providers_list:
|
||||
c.execute('''INSERT OR IGNORE INTO table_settings_providers(name) VALUES(?)''', (provider_name, ))
|
||||
# Insert providers in database table
|
||||
for provider_name in providers_list:
|
||||
c.execute('''INSERT OR IGNORE INTO table_settings_providers(name) VALUES(?)''', (provider_name, ))
|
||||
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
||||
# Close database connection
|
||||
db.close()
|
||||
|
||||
|
||||
def get_providers():
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
enabled_providers = c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
c.close()
|
||||
|
||||
providers_list = []
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
else:
|
||||
providers_list = None
|
||||
|
||||
return providers_list
|
||||
|
||||
|
||||
def get_providers_auth():
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
enabled_providers = c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1 AND username is not NULL AND password is not NULL").fetchall()
|
||||
c.close()
|
||||
|
||||
providers_auth = collections.defaultdict(dict)
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_auth[provider[0]] = {}
|
||||
providers_auth[provider[0]]['username'] = provider[2]
|
||||
providers_auth[provider[0]]['password'] = provider[3]
|
||||
else:
|
||||
providers_auth = None
|
||||
|
||||
return providers_auth
|
|
@ -16,10 +16,6 @@ def update_series():
|
|||
serie_default_language = get_general_settings()[16]
|
||||
serie_default_hi = get_general_settings()[17]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
if apikey_sonarr == None:
|
||||
pass
|
||||
else:
|
||||
|
@ -39,10 +35,20 @@ def update_series():
|
|||
except requests.exceptions.RequestException as err:
|
||||
logging.exception("Error trying to get series from Sonarr.")
|
||||
else:
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get current shows in DB
|
||||
current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall()
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
||||
|
||||
current_shows_db_list = [x[0] for x in current_shows_db]
|
||||
current_shows_sonarr = []
|
||||
series_to_update = []
|
||||
series_to_add = []
|
||||
|
||||
for show in r.json():
|
||||
try:
|
||||
|
@ -62,28 +68,42 @@ def update_series():
|
|||
# Add shows in Sonarr to current shows list
|
||||
current_shows_sonarr.append(show['tvdbId'])
|
||||
|
||||
# Update or insert shows list in database table
|
||||
try:
|
||||
if show['tvdbId'] in current_shows_db_list:
|
||||
series_to_update.append((show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language((show['qualityProfileId'] if sonarr_version == 2 else show['languageProfileId'])),show['sortTitle'],show["tvdbId"]))
|
||||
else:
|
||||
if serie_default_enabled is True:
|
||||
c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', (show["title"], show["path"], show["tvdbId"], serie_default_language, serie_default_hi, show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle']))
|
||||
list_missing_subtitles(show["id"])
|
||||
series_to_add.append((show["title"], show["path"], show["tvdbId"], serie_default_language, serie_default_hi, show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle']))
|
||||
else:
|
||||
c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?, ?, ?)''', (show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle']))
|
||||
except:
|
||||
c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? , sortTitle = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language((show['qualityProfileId'] if sonarr_version == 2 else show['languageProfileId'])),show['sortTitle'],show["tvdbId"]))
|
||||
series_to_add.append((show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle']))
|
||||
|
||||
# Update or insert series in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
updated_result = c.executemany('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? , sortTitle = ? WHERE tvdbid = ?''', series_to_update)
|
||||
db.commit()
|
||||
|
||||
if serie_default_enabled is True:
|
||||
added_result = c.executemany('''INSERT OR IGNORE INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', series_to_add)
|
||||
db.commit()
|
||||
else:
|
||||
added_result = c.executemany('''INSERT OR IGNORE INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?, ?, ?)''', series_to_add)
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
for show in series_to_add:
|
||||
list_missing_subtitles(show[5])
|
||||
|
||||
# Delete shows not in Sonarr anymore
|
||||
deleted_items = []
|
||||
for item in current_shows_db_list:
|
||||
if item not in current_shows_sonarr:
|
||||
deleted_items.append(tuple([item]))
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items)
|
||||
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
||||
db.close()
|
||||
|
||||
def get_profile_list():
|
||||
from get_settings import get_sonarr_settings
|
||||
|
|
|
@ -29,6 +29,8 @@ def get_general_settings():
|
|||
|
||||
if cfg.has_option('general', 'base_url'):
|
||||
base_url = cfg.get('general', 'base_url')
|
||||
if base_url.endswith('/') is False:
|
||||
base_url += '/'
|
||||
else:
|
||||
base_url = '/'
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import time
|
|||
from datetime import datetime, timedelta
|
||||
from babelfish import Language
|
||||
from subliminal import region, scan_video, Video, download_best_subtitles, compute_score, save_subtitles, AsyncProviderPool, score, list_subtitles, download_subtitles
|
||||
from subliminal.subtitle import get_subtitle_path
|
||||
from get_languages import language_from_alpha3, alpha2_from_alpha3, alpha3_from_alpha2
|
||||
from bs4 import UnicodeDammit
|
||||
from get_settings import get_general_settings, pp_replace, path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
|
||||
|
@ -17,6 +18,7 @@ from utils import history_log, history_log_movie
|
|||
from notifier import send_notifications, send_notifications_movie
|
||||
import cPickle as pickle
|
||||
import codecs
|
||||
from get_providers import get_providers, get_providers_auth
|
||||
|
||||
# configure the cache
|
||||
region.configure('dogpile.cache.memory')
|
||||
|
@ -77,11 +79,11 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
|
|||
logging.error('Error saving subtitles file to disk.')
|
||||
return None
|
||||
else:
|
||||
downloaded_provider = str(result[0][0]).strip('<>').split(' ')[0][:-8]
|
||||
downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8]
|
||||
downloaded_language = language_from_alpha3(language)
|
||||
downloaded_language_code2 = alpha2_from_alpha3(language)
|
||||
downloaded_language_code3 = language
|
||||
downloaded_path = result[1]
|
||||
downloaded_path = get_subtitle_path(path, language=lang_obj)
|
||||
if used_sceneName == True:
|
||||
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(score) + "% using this scene name: " + sceneName
|
||||
else:
|
||||
|
@ -123,7 +125,7 @@ def manual_search(path, language, hi, providers, providers_auth, sceneName, medi
|
|||
hi = False
|
||||
language_set = set()
|
||||
for lang in ast.literal_eval(language):
|
||||
if lang == 'pob':
|
||||
if lang == 'pb':
|
||||
language_set.add(Language('por', 'BR'))
|
||||
else:
|
||||
language_set.add(Language(alpha3_from_alpha2(lang)))
|
||||
|
@ -182,7 +184,8 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
|
|||
use_postprocessing = get_general_settings()[10]
|
||||
postprocessing_cmd = get_general_settings()[11]
|
||||
|
||||
if language == 'pob':
|
||||
if language == 'pb':
|
||||
language = alpha3_from_alpha2(language)
|
||||
lang_obj = Language('por', 'BR')
|
||||
else:
|
||||
language = alpha3_from_alpha2(language)
|
||||
|
@ -201,7 +204,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
|
|||
else:
|
||||
try:
|
||||
best_subtitle = subtitle
|
||||
download_subtitles([best_subtitle])
|
||||
download_subtitles([best_subtitle], providers=provider, provider_configs=providers_auth)
|
||||
except Exception as e:
|
||||
logging.exception('Error downloading subtitles for ' + path)
|
||||
return None
|
||||
|
@ -219,11 +222,11 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
|
|||
logging.exception('Error saving subtitles file to disk.')
|
||||
return None
|
||||
else:
|
||||
downloaded_provider = str(result[0][0]).strip('<>').split(' ')[0][:-8]
|
||||
downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8]
|
||||
downloaded_language = language_from_alpha3(language)
|
||||
downloaded_language_code2 = alpha2_from_alpha3(language)
|
||||
downloaded_language_code3 = language
|
||||
downloaded_path = result[1]
|
||||
downloaded_path = get_subtitle_path(path, language=lang_obj)
|
||||
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(score) + "% using manual search."
|
||||
|
||||
if use_postprocessing is True:
|
||||
|
@ -265,25 +268,10 @@ def series_download_subtitles(no):
|
|||
c_db = conn_db.cursor()
|
||||
episodes_details = c_db.execute('SELECT path, missing_subtitles, sonarrEpisodeId, scene_name FROM table_episodes WHERE sonarrSeriesId = ? AND missing_subtitles != "[]"' + monitored_only_query_string, (no,)).fetchall()
|
||||
series_details = c_db.execute("SELECT hearing_impaired FROM table_shows WHERE sonarrSeriesId = ?", (no,)).fetchone()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
c_db.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
for episode in episodes_details:
|
||||
for language in ast.literal_eval(episode[1]):
|
||||
|
@ -300,25 +288,10 @@ def movies_download_subtitles(no):
|
|||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movie = c_db.execute("SELECT path, missing_subtitles, radarrId, sceneName, hearing_impaired FROM table_movies WHERE radarrId = ?", (no,)).fetchone()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
c_db.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username': providers[2], 'password': providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
for language in ast.literal_eval(movie[1]):
|
||||
if language is not None:
|
||||
|
@ -334,25 +307,10 @@ def wanted_download_subtitles(path):
|
|||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired, table_episodes.scene_name, table_episodes.failedAttempts FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
c_db.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username':providers[2], 'password':providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
for episode in episodes_details:
|
||||
attempt = episode[6]
|
||||
|
@ -390,25 +348,10 @@ def wanted_download_subtitles_movie(path):
|
|||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movies_details = c_db.execute("SELECT path, missing_subtitles, radarrId, radarrId, hearing_impaired, sceneName, failedAttempts FROM table_movies WHERE path = ? AND missing_subtitles != '[]'", (path_replace_reverse_movie(path),)).fetchall()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
c_db.close()
|
||||
|
||||
providers_list = []
|
||||
providers_auth = {}
|
||||
if len(enabled_providers) > 0:
|
||||
for provider in enabled_providers:
|
||||
providers_list.append(provider[0])
|
||||
try:
|
||||
if provider[2] is not '' and provider[3] is not '':
|
||||
provider_auth = providers_auth.append(provider[0])
|
||||
provider_auth.update({'username': providers[2], 'password': providers[3]})
|
||||
else:
|
||||
providers_auth = None
|
||||
except:
|
||||
providers_auth = None
|
||||
else:
|
||||
providers_list = None
|
||||
providers_auth = None
|
||||
providers_list = get_providers()
|
||||
providers_auth = get_providers_auth()
|
||||
|
||||
for movie in movies_details:
|
||||
attempt = movie[6]
|
||||
|
|
|
@ -407,7 +407,7 @@ def download(obj, provider, refiner, language, age, directory, encoding, single,
|
|||
# save subtitles
|
||||
total_subtitles = 0
|
||||
for v, subtitles in downloaded_subtitles.items():
|
||||
saved_subtitles = save_subtitles(v, subtitles, single=single, directory=directory, encoding=encoding)[0]
|
||||
saved_subtitles = save_subtitles(v, subtitles, single=single, directory=directory, encoding=encoding)
|
||||
total_subtitles += len(saved_subtitles)
|
||||
|
||||
if verbose > 0:
|
||||
|
|
|
@ -768,4 +768,4 @@ def save_subtitles(video, subtitles, single=False, directory=None, encoding=None
|
|||
if single:
|
||||
break
|
||||
|
||||
return [saved_subtitles, subtitle_path]
|
||||
return saved_subtitles
|
||||
|
|
43
scheduler.py
43
scheduler.py
|
@ -20,22 +20,37 @@ integration = get_general_settings()
|
|||
|
||||
|
||||
def sonarr_full_update():
|
||||
full_update = get_sonarr_settings()[5]
|
||||
if full_update == "Daily":
|
||||
scheduler.add_job(update_all_episodes, CronTrigger(hour=4), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_episodes', name='Update all episodes subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Weekly":
|
||||
scheduler.add_job(update_all_episodes, CronTrigger(day_of_week='sun'), hour=4, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_episodes', name='Update all episodes subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Manually":
|
||||
scheduler.add_job(update_all_episodes, CronTrigger(year='2100'), hour=4, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_episodes', name='Update all episodes subtitles from disk', replace_existing=True)
|
||||
if integration[12] is True:
|
||||
full_update = get_sonarr_settings()[5]
|
||||
if full_update == "Daily":
|
||||
scheduler.add_job(update_all_episodes, CronTrigger(hour=4), max_instances=1, coalesce=True,
|
||||
misfire_grace_time=15, id='update_all_episodes',
|
||||
name='Update all episodes subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Weekly":
|
||||
scheduler.add_job(update_all_episodes, CronTrigger(day_of_week='sun'), hour=4, max_instances=1, coalesce=True,
|
||||
misfire_grace_time=15, id='update_all_episodes',
|
||||
name='Update all episodes subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Manually":
|
||||
scheduler.add_job(update_all_episodes, CronTrigger(year='2100'), hour=4, max_instances=1, coalesce=True,
|
||||
misfire_grace_time=15, id='update_all_episodes',
|
||||
name='Update all episodes subtitles from disk', replace_existing=True)
|
||||
|
||||
|
||||
def radarr_full_update():
|
||||
full_update = get_radarr_settings()[5]
|
||||
if full_update == "Daily":
|
||||
scheduler.add_job(update_all_movies, CronTrigger(hour=5), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Weekly":
|
||||
scheduler.add_job(update_all_movies, CronTrigger(day_of_week='sun'), hour=5, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Manually":
|
||||
scheduler.add_job(update_all_movies, CronTrigger(year='2100'), hour=5, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True)
|
||||
if integration[13] is True:
|
||||
full_update = get_radarr_settings()[5]
|
||||
if full_update == "Daily":
|
||||
scheduler.add_job(update_all_movies, CronTrigger(hour=5), max_instances=1, coalesce=True, misfire_grace_time=15,
|
||||
id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True)
|
||||
elif full_update == "Weekly":
|
||||
scheduler.add_job(update_all_movies, CronTrigger(day_of_week='sun'), hour=5, max_instances=1, coalesce=True,
|
||||
misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk',
|
||||
replace_existing=True)
|
||||
elif full_update == "Manually":
|
||||
scheduler.add_job(update_all_movies, CronTrigger(year='2100'), hour=5, max_instances=1, coalesce=True,
|
||||
misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk',
|
||||
replace_existing=True)
|
||||
|
||||
|
||||
def execute_now(taskid):
|
||||
scheduler.modify_job(taskid, next_run_time=datetime.now())
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
background-position:center center;
|
||||
}
|
||||
#divdetails {
|
||||
background-color: #000000;
|
||||
opacity: 0.9;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
color: #ffffff;
|
||||
margin-top: 6em;
|
||||
margin-bottom: 3em;
|
||||
|
@ -175,7 +174,7 @@
|
|||
%for episode in season:
|
||||
<tr>
|
||||
<td class="collapsing">
|
||||
%if episode[9] is True:
|
||||
%if episode[9] == 'True':
|
||||
<span data-tooltip="Episode monitored in Sonarr"><i class="bookmark icon"></i></span>
|
||||
%else:
|
||||
<span data-tooltip="Episode unmonitored in Sonarr"><i class="bookmark outline icon"></i></span>
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
background-color: #333333;
|
||||
box-shadow: 0 0 10px 1px #333;
|
||||
padding: 10px;
|
||||
margin-bottom: -2em !important;
|
||||
}
|
||||
.label, .value {
|
||||
color: white !important;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
background-color: #333333;
|
||||
box-shadow: 0 0 10px 1px #333;
|
||||
padding: 10px;
|
||||
margin-bottom: -2em !important;
|
||||
}
|
||||
.label, .value {
|
||||
color: white !important;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<style>
|
||||
#divmenu {
|
||||
background-color: #000000;
|
||||
opacity: 0.8;
|
||||
padding-top: 2em;
|
||||
padding-bottom: 1em;
|
||||
padding-left: 1em;
|
||||
|
@ -101,7 +100,7 @@
|
|||
<div class="ten wide column">
|
||||
<div class="ui search">
|
||||
<div class="ui left icon fluid input">
|
||||
<input class="prompt" type="text" placeholder="Search the series in your library">
|
||||
<input class="prompt" type="text" placeholder="Search in your library">
|
||||
<i class="searchicon search icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -113,18 +112,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
% restart_required = c.execute("SELECT configured, updated FROM system").fetchone()
|
||||
% c.close()
|
||||
|
||||
% if restart_required[1] == '1' and restart_required[0] == '1':
|
||||
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply last update and changes to general settings.</div></div></div>
|
||||
% elif restart_required[1] == '1':
|
||||
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply last update.</div></div></div>
|
||||
% elif restart_required[0] == '1':
|
||||
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply changes to general settings.</div></div></div>
|
||||
% end
|
||||
</div>
|
||||
|
||||
% restart_required = c.execute("SELECT configured, updated FROM system").fetchone()
|
||||
% c.close()
|
||||
|
||||
% if restart_required[1] == '1' and restart_required[0] == '1':
|
||||
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply last update and changes to general settings.</div></div></div>
|
||||
% elif restart_required[1] == '1':
|
||||
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply last update.</div></div></div>
|
||||
% elif restart_required[0] == '1':
|
||||
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply changes to general settings.</div></div></div>
|
||||
% end
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -152,7 +151,17 @@
|
|||
|
||||
if (window.location.href.indexOf("episodes") > -1) {
|
||||
$('.menu').css('background', '#000000');
|
||||
$('.menu').css('opacity', '0.8');
|
||||
$('#divmenu').css('background', '#000000');
|
||||
$('#divmenu').css('opacity', '0.8');
|
||||
$('#divmenu').css('box-shadow', '0px 0px 5px 5px #000000');
|
||||
}
|
||||
else if (window.location.href.indexOf("movie/") > -1) {
|
||||
$('.menu').css('background', '#000000');
|
||||
$('.menu').css('opacity', '0.8');
|
||||
$('#divmenu').css('background', '#000000');
|
||||
$('#divmenu').css('opacity', '0.8');
|
||||
$('#divmenu').css('box-shadow', '0px 0px 5px 5px #000000');
|
||||
}
|
||||
else {
|
||||
$('.menu').css('background', '#272727');
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
background-position:center center;
|
||||
}
|
||||
#divdetails {
|
||||
background-color: #000000;
|
||||
opacity: 0.9;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
color: #ffffff;
|
||||
margin-top: 6em;
|
||||
margin-bottom: 3em;
|
||||
|
@ -109,7 +108,7 @@
|
|||
<button id="config" class="ui button" data-tooltip="Edit movie" data-inverted="" data-tmdbid="{{details[5]}}" data-title="{{details[0]}}" data-poster="{{details[2]}}" data-audio="{{details[6]}}" data-languages="{{!subs_languages_list}}" data-hearing-impaired="{{details[4]}}"><i class="ui inverted large compact configure icon"></i></button>
|
||||
</div>
|
||||
<h2>
|
||||
%if details[13] is True:
|
||||
%if details[13] == 'True':
|
||||
<span data-tooltip="Movie monitored in Radarr"><i class="bookmark icon"></i></span>
|
||||
%else:
|
||||
<span data-tooltip="Movie unmonitored in Radarr"><i class="bookmark outline icon"></i></span>
|
||||
|
|
|
@ -1509,6 +1509,20 @@
|
|||
};
|
||||
});
|
||||
|
||||
// Load default value for Settings_auth_type
|
||||
$('#settings_auth_type').dropdown('clear');
|
||||
$('#settings_auth_type').dropdown('set selected','{{!settings_auth[0]}}');
|
||||
|
||||
// Remove value from Password input when changing to Form login to prevent bad password saving
|
||||
$("#settings_auth_type").change(function() {
|
||||
if ($(this).val() == 'form'){
|
||||
$('#settings_auth_password').val('');
|
||||
}
|
||||
else {
|
||||
$('#settings_auth_password').val('{{settings_auth[2]}}');
|
||||
}
|
||||
});
|
||||
|
||||
$('#settings_languages').dropdown('setting', 'onAdd', function(val, txt){
|
||||
$("#settings_serie_default_languages").append(
|
||||
$("<option></option>").attr("value", val).text(txt)
|
||||
|
@ -1669,8 +1683,6 @@
|
|||
%if settings_general[19] is not None:
|
||||
$('#settings_movie_default_languages').dropdown('set selected',{{!settings_general[19]}});
|
||||
%end
|
||||
$('#settings_auth_type').dropdown('clear');
|
||||
$('#settings_auth_type').dropdown('set selected','{{!settings_auth[0]}}');
|
||||
$('#settings_branch').dropdown();
|
||||
$('#settings_sonarr_sync').dropdown();
|
||||
$('#settings_radarr_sync').dropdown();
|
||||
|
|
Loading…
Reference in New Issue