mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 17:17:12 +00:00
Code cleanup and minimal file size for importation from Sonarr
This commit is contained in:
parent
3c3e2830cb
commit
a197f70874
3 changed files with 5 additions and 53 deletions
10
bazarr.py
10
bazarr.py
|
@ -1,4 +1,4 @@
|
||||||
bazarr_version = '0.1.1'
|
bazarr_version = '0.1.2'
|
||||||
|
|
||||||
from bottle import route, run, template, static_file, request, redirect
|
from bottle import route, run, template, static_file, request, redirect
|
||||||
import bottle
|
import bottle
|
||||||
|
@ -292,12 +292,6 @@ def check_update():
|
||||||
|
|
||||||
@route(base_url + 'system')
|
@route(base_url + 'system')
|
||||||
def system():
|
def system():
|
||||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
|
||||||
c = db.cursor()
|
|
||||||
c.execute("SELECT * FROM table_scheduler")
|
|
||||||
tasks = c.fetchall()
|
|
||||||
c.close()
|
|
||||||
|
|
||||||
logs = []
|
logs = []
|
||||||
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
|
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
|
||||||
logs.append(line.rstrip())
|
logs.append(line.rstrip())
|
||||||
|
@ -388,7 +382,7 @@ def system():
|
||||||
elif job.trigger.__str__().startswith('cron'):
|
elif job.trigger.__str__().startswith('cron'):
|
||||||
task_list.append([job.name, get_time_from_cron(job.trigger.fields), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
|
task_list.append([job.name, get_time_from_cron(job.trigger.fields), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
|
||||||
|
|
||||||
return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list, bazarr_version=bazarr_version)
|
return template('system', logs=logs, base_url=base_url, task_list=task_list, bazarr_version=bazarr_version)
|
||||||
|
|
||||||
@route(base_url + 'execute/<taskid>')
|
@route(base_url + 'execute/<taskid>')
|
||||||
def execute_task(taskid):
|
def execute_task(taskid):
|
||||||
|
|
|
@ -36,7 +36,7 @@ def update_all_episodes():
|
||||||
url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
|
url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
|
||||||
r = requests.get(url_sonarr_api_episode)
|
r = requests.get(url_sonarr_api_episode)
|
||||||
for episode in r.json():
|
for episode in r.json():
|
||||||
if episode['hasFile']:
|
if episode['hasFile'] and episode['episodeFile']['size'] > 20480:
|
||||||
# Add shows in Sonarr to current shows list
|
# Add shows in Sonarr to current shows list
|
||||||
current_episodes_sonarr.append(episode['id'])
|
current_episodes_sonarr.append(episode['id'])
|
||||||
|
|
||||||
|
@ -60,15 +60,6 @@ def update_all_episodes():
|
||||||
|
|
||||||
# Close database connection
|
# Close database connection
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
#Cleanup variables to free memory
|
|
||||||
del current_episodes_db
|
|
||||||
del current_episodes_db_list
|
|
||||||
del seriesIdList
|
|
||||||
del r
|
|
||||||
del current_episodes_sonarr
|
|
||||||
del deleted_items
|
|
||||||
del c
|
|
||||||
|
|
||||||
# Store substitles for all episodes
|
# Store substitles for all episodes
|
||||||
full_scan_subtitles()
|
full_scan_subtitles()
|
||||||
|
@ -110,7 +101,7 @@ def add_new_episodes():
|
||||||
url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
|
url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
|
||||||
r = requests.get(url_sonarr_api_episode)
|
r = requests.get(url_sonarr_api_episode)
|
||||||
for episode in r.json():
|
for episode in r.json():
|
||||||
if episode['hasFile']:
|
if episode['hasFile'] and episode['episodeFile']['size'] > 20480:
|
||||||
# Add shows in Sonarr to current shows list
|
# Add shows in Sonarr to current shows list
|
||||||
current_episodes_sonarr.append(episode['id'])
|
current_episodes_sonarr.append(episode['id'])
|
||||||
|
|
||||||
|
@ -132,15 +123,6 @@ def add_new_episodes():
|
||||||
|
|
||||||
# Close database connection
|
# Close database connection
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
#Cleanup variables to free memory
|
|
||||||
del current_episodes_db
|
|
||||||
del current_episodes_db_list
|
|
||||||
del seriesIdList
|
|
||||||
del r
|
|
||||||
del current_episodes_sonarr
|
|
||||||
del deleted_items
|
|
||||||
del c
|
|
||||||
|
|
||||||
# Store substitles from episodes we've just added
|
# Store substitles from episodes we've just added
|
||||||
new_scan_subtitles()
|
new_scan_subtitles()
|
||||||
|
|
|
@ -26,16 +26,6 @@ def download_subtitle(path, language, hi, providers):
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
del video
|
|
||||||
del best_subtitles
|
|
||||||
try:
|
|
||||||
del result
|
|
||||||
del downloaded_provider
|
|
||||||
del downloaded_language
|
|
||||||
del message
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def series_download_subtitles(no):
|
def series_download_subtitles(no):
|
||||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||||
c_db = conn_db.cursor()
|
c_db = conn_db.cursor()
|
||||||
|
@ -75,16 +65,6 @@ def wanted_download_subtitles(path):
|
||||||
list_missing_subtitles(episode[3])
|
list_missing_subtitles(episode[3])
|
||||||
history_log(1, episode[3], episode[2], message)
|
history_log(1, episode[3], episode[2], message)
|
||||||
|
|
||||||
del conn_db
|
|
||||||
del c_db
|
|
||||||
del episodes_details
|
|
||||||
del enabled_providers
|
|
||||||
del providers_list
|
|
||||||
try:
|
|
||||||
del message
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def wanted_search_missing_subtitles():
|
def wanted_search_missing_subtitles():
|
||||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||||
db.create_function("path_substitution", 1, path_replace)
|
db.create_function("path_substitution", 1, path_replace)
|
||||||
|
@ -95,8 +75,4 @@ def wanted_search_missing_subtitles():
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
for episode in data:
|
for episode in data:
|
||||||
wanted_download_subtitles(episode[0])
|
wanted_download_subtitles(episode[0])
|
||||||
|
|
||||||
del db
|
|
||||||
del c
|
|
||||||
del data
|
|
Loading…
Reference in a new issue