@@ -372,7 +372,7 @@
;
$('#settings_general_check_update').click(function(){
- window.location.href = '{{base_url}}check_update';
+ window.location = '{{base_url}}check_update';
})
$('a:not(.tabs), button:not(.cancel)').click(function(){
From 6c92df08613ec1128ee1b7df00fffd8aadb30afc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 21:07:21 -0500
Subject: [PATCH 22/55] Better error management and improvemet to tasks
schduler
---
Dockerfile | 2 +-
README.md | 18 ++++++----
bazarr.py | 39 +++++++-------------
check_update.py | 2 +-
create_db.sql | 2 +-
get_episodes.py | 88 ++++++++++++++++++++++++---------------------
get_series.py | 89 ++++++++++++++++++++++++----------------------
list_subtitles.py | 21 +++++------
scheduler.py | 7 ++++
views/episodes.tpl | 2 +-
views/series.tpl | 20 +----------
views/system.tpl | 10 ++++++
12 files changed, 151 insertions(+), 149 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 9672a55b6..1f21c71aa 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,7 @@ RUN apt-get update
RUN apt-get install -y build-essential python-dev python-pip python-setuptools libjpeg-dev zlib1g-dev git libgit2-dev libffi-dev
# Get application source from Github
-RUN git clone -b development --single-branch https://github.com/morpheus65535/bazarr.git /bazarr
+RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr
VOLUME /bazarr/data
diff --git a/README.md b/README.md
index 074bc507d..105f83d24 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,9 @@ Linux:
* Open your browser and go to `http://localhost:6767/`
## Docker:
-* You can use [this image](https://hub.docker.com/r/morpheus65535/bazarr) to quickly build your own isolated app container. Thanks to [Linux Server](https://github.com/linuxserver) for the base image. It's based on the Linux instructions above. For more info about Docker check out the [official website](https://www.docker.com).
+* You can use [this image](https://hub.docker.com/r/morpheus65535/bazarr) to quickly build your own isolated app container. It's based on the Linux instructions above. For more info about Docker check out the [official website](https://www.docker.com).
+
+docker create --name=bazarr -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /path/to/series/directory:/tv -v /path/to/config/directory/on/host:/bazarr/data -p 6767:6767 --restart=always morpheus65535/bazarr:latest
## First run (important to read!!!):
@@ -77,12 +79,16 @@ Linux:
* Configure Sonarr ip, port, base url, SSL and API key.
### 4 - In "Subliminal" tab:
* Configure enabled providers and enabled languages. Enabled languages are those that you are going to be able to assign to a series later.
-### 5 - Save those settings and restart Bazarr.
+### 5 - Save those settings and restart (important!!!) Bazarr.
+
+### 6 - Wait 2 minutes
+
+### 7 - On the "Series" page, you should now see all your series listed with a wrench icon on yellow background. Those are the series that need to be configured. Click on those one you want to get subtitles for and select desired languages. You don't have to do this for every series but it will looks cleaner without all this yellow ;-). If you don't want any substitles for a series, just click on the wrench icon and then on "Save" without selecting anything.
+
+### 8 - On each series page, you should see episode files available on disk, existing subtitles and missing subtitles (in case you requested some and they aren't already existing).
+* If you don't see your episodes right now, wait some more time. It take time to do the initial synchronization between Sonarr and Bazarr.
-### 6 - On the "Series" page, click on "Update Series"
-* You should now see all your series listed with a wrench icon on yellow background. Those are the series that need to be configured. Click on each one and select desired languages. You have to do this even if you don't want subtitles for a series. Just click on the wrench icon and then on "Save".
-* When you've finished going trough all those series to configure desired languages, you have to "Update All Episodes" from the "Series" page. Don't be impatient, it will take about 1 minute by 1000 episodes Bazarr need to scan for existing internal and external subtitles. If Bazarr is accessing those episodes trough a network share, it's going to take much more longer than that. Keep in mind that Bazarr have to open each and every episode files to analyze the content.
-* Once the scan is finished, you should be able to access episodes list for each series and see those missing subtitles on the wanted page.
+### 9 - On "Wanted" page, you should see all the episodes who have missing subtitles.
### 10 - Have fun and keep in mind that providers may temporary refuse connection due to connection limit exceeded or problem on the provider web service.
diff --git a/bazarr.py b/bazarr.py
index bacf10410..e2f0a407f 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -41,7 +41,7 @@
log_level = c.fetchone()
log_level = log_level[0]
if log_level is None:
- log_level = "WARNING"
+ log_level = "INFO"
log_level = getattr(logging, log_level)
c.close()
@@ -129,30 +129,6 @@ def edit_series(no):
redirect(ref)
-@route(base_url + 'update_series')
-def update_series_list():
- ref = request.environ['HTTP_REFERER']
-
- update_series()
-
- redirect(ref)
-
-@route(base_url + 'update_all_episodes')
-def update_all_episodes_list():
- ref = request.environ['HTTP_REFERER']
-
- update_all_episodes()
-
- redirect(ref)
-
-@route(base_url + 'add_new_episodes')
-def add_new_episodes_list():
- ref = request.environ['HTTP_REFERER']
-
- add_new_episodes()
-
- redirect(ref)
-
@route(base_url + 'episodes/', method='GET')
def episodes(no):
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
@@ -321,10 +297,21 @@ def system():
task_list = []
for job in scheduler.get_jobs():
- task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None))])
+ if job.trigger.__str__().startswith('interval'):
+ task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
+ elif job.trigger.__str__().startswith('cron'):
+ task_list.append([job.name, job.trigger.__str__(), 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)
+@route(base_url + 'execute/')
+def execute_task(taskid):
+ ref = request.environ['HTTP_REFERER']
+
+ execute_now(taskid)
+
+ redirect(ref)
+
@route(base_url + 'remove_subtitles', method='POST')
def remove_subtitles():
episodePath = request.forms.get('episodePath')
diff --git a/check_update.py b/check_update.py
index cbbe97ba3..9d7c84c0c 100644
--- a/check_update.py
+++ b/check_update.py
@@ -23,7 +23,7 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
master_ref = repo.lookup_reference('refs/heads/master')
master_ref.set_target(remote_id)
repo.head.set_target(remote_id)
- result = 'Bazarr updated to latest version.'
+ result = 'Bazarr updated to latest version and restarting.'
os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py'))
else:
raise AssertionError('Unknown merge analysis result')
diff --git a/create_db.sql b/create_db.sql
index 57ece98ea..a29b2fdf1 100644
--- a/create_db.sql
+++ b/create_db.sql
@@ -40,7 +40,7 @@ CREATE TABLE "table_settings_general" (
`branch` TEXT,
`auto_update` INTEGER
);
-INSERT INTO `table_settings_general` (ip,port,base_url,path_mapping,log_level, branch, auto_update) VALUES ('0.0.0.0',6767,'/',Null,'WARNING','master','True');
+INSERT INTO `table_settings_general` (ip,port,base_url,path_mapping,log_level, branch, auto_update) VALUES ('0.0.0.0',6767,'/',Null,'INFO','master','True');
CREATE TABLE `table_scheduler` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`name` TEXT NOT NULL,
diff --git a/get_episodes.py b/get_episodes.py
index 880679d97..3f90747f9 100644
--- a/get_episodes.py
+++ b/get_episodes.py
@@ -21,6 +21,7 @@ def update_all_episodes():
base_url_sonarr = ""
else:
base_url_sonarr = "/" + config_sonarr[2].strip("/")
+ apikey_sonarr = config_sonarr[4]
# Get current episodes id in DB
current_episodes_db = c.execute('SELECT sonarrEpisodeId FROM table_episodes').fetchall()
@@ -32,7 +33,7 @@ def update_all_episodes():
seriesIdList = c.fetchall()
for seriesId in seriesIdList:
# Get episodes data for a series from Sonarr
- url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + config_sonarr[4]
+ 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)
for episode in r.json():
if episode['hasFile']:
@@ -80,47 +81,52 @@ def add_new_episodes():
base_url_sonarr = ""
else:
base_url_sonarr = "/" + config_sonarr[2].strip("/")
+ apikey_sonarr = config_sonarr[4]
- # Get current episodes in DB
- 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 = []
-
- # Get sonarrId for each series from database
- c.execute("SELECT sonarrSeriesId FROM table_shows")
- seriesIdList = c.fetchall()
- for seriesId in seriesIdList:
- # Get episodes data for a series from Sonarr
- url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + config_sonarr[4]
- r = requests.get(url_sonarr_api_episode)
-
- for episode in r.json():
- if episode['hasFile']:
- # Add shows in Sonarr to current shows list
- current_episodes_sonarr.append(episode['id'])
-
- try:
- c.execute('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode) VALUES (?, ?, ?, ?, ?, ?)''', (episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber']))
- except:
- pass
+ if apikey_sonarr == None:
+ # Close database connection
+ c.close()
+ pass
+ else:
+ # Get current episodes in DB
+ 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 = []
+
+ # Get sonarrId for each series from database
+ c.execute("SELECT sonarrSeriesId FROM table_shows")
+ seriesIdList = c.fetchall()
+ for seriesId in seriesIdList:
+ # Get episodes data for a series from 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)
+ for episode in r.json():
+ if episode['hasFile']:
+ # Add shows in Sonarr to current shows list
+ current_episodes_sonarr.append(episode['id'])
+
+ try:
+ c.execute('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode) VALUES (?, ?, ?, ?, ?, ?)''', (episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber']))
+ except:
+ pass
+ db.commit()
+
+ # Delete episodes not in Sonarr anymore
+ deleted_items = []
+ for item in current_episodes_db_list:
+ if item not in current_episodes_sonarr:
+ deleted_items.append(tuple([item]))
+ c.executemany('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?',deleted_items)
+
+ # Commit changes to database table
db.commit()
- # Delete episodes not in Sonarr anymore
- deleted_items = []
- for item in current_episodes_db_list:
- if item not in current_episodes_sonarr:
- deleted_items.append(tuple([item]))
- c.executemany('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?',deleted_items)
-
- # Commit changes to database table
- db.commit()
-
- # Close database connection
- c.close()
+ # Close database connection
+ c.close()
- # Store substitles from episodes we've just added
- new_scan_subtitles()
- try:
- list_missing_subtitles()
- except:
- pass
+ # Store substitles from episodes we've just added
+ new_scan_subtitles()
+ try:
+ list_missing_subtitles()
+ except:
+ pass
diff --git a/get_series.py b/get_series.py
index dd8875f03..07c52f924 100644
--- a/get_series.py
+++ b/get_series.py
@@ -9,49 +9,52 @@ def update_series():
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
- # Get shows data from Sonarr
- url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr
- r = requests.get(url_sonarr_api_series)
- shows_list = []
-
- # Get current shows in DB
- current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall()
- current_shows_db_list = [x[0] for x in current_shows_db]
- current_shows_sonarr = []
-
- # Parsing data returned from Sonarr
- for show in r.json():
- try:
- overview = unicode(show['overview'])
- except:
- overview = ""
- try:
- poster_big = show['images'][2]['url'].split('?')[0]
- poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1]
- except:
- poster = ""
- try:
- fanart = show['images'][0]['url'].split('?')[0]
- except:
- fanart = ""
-
- # Add shows in Sonarr to current shows list
- current_shows_sonarr.append(show['tvdbId'])
-
- # Update or insert shows list in database table
- result = c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,show["tvdbId"]))
- if result.rowcount == 0:
- c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart) 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))
-
- # 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]))
- c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items)
-
- # Commit changes to database table
- db.commit()
+ if apikey_sonarr == None:
+ pass
+ else:
+ # Get shows data from Sonarr
+ url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr
+ r = requests.get(url_sonarr_api_series)
+ shows_list = []
+
+ # Get current shows in DB
+ current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall()
+ current_shows_db_list = [x[0] for x in current_shows_db]
+ current_shows_sonarr = []
+
+ # Parsing data returned from Sonarr
+ for show in r.json():
+ try:
+ overview = unicode(show['overview'])
+ except:
+ overview = ""
+ try:
+ poster_big = show['images'][2]['url'].split('?')[0]
+ poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1]
+ except:
+ poster = ""
+ try:
+ fanart = show['images'][0]['url'].split('?')[0]
+ except:
+ fanart = ""
+
+ # Add shows in Sonarr to current shows list
+ current_shows_sonarr.append(show['tvdbId'])
+
+ # Update or insert shows list in database table
+ result = c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,show["tvdbId"]))
+ if result.rowcount == 0:
+ c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart) 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))
+
+ # 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]))
+ c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items)
+
+ # Commit changes to database table
+ db.commit()
# Close database connection
db.close()
diff --git a/list_subtitles.py b/list_subtitles.py
index 6e4d05c73..dcda27734 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -68,32 +68,33 @@ def store_subtitles(file):
def list_missing_subtitles(*no):
query_string = ''
try:
- query_string = " WHERE table_episodes.sonarrSeriesId = " + str(no[0])
+ query_string = " WHERE table_shows.tvdbId = " + str(no[0])
except:
pass
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c_db = conn_db.cursor()
episodes_subtitles = c_db.execute("SELECT table_episodes.sonarrEpisodeId, table_episodes.subtitles, table_shows.languages FROM table_episodes INNER JOIN table_shows on table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId" + query_string).fetchall()
-
- missing_subtitles_global = []
+ missing_subtitles_global = []
+
for episode_subtitles in episodes_subtitles:
actual_subtitles = []
+ actual_subtitles_list = []
desired_subtitles = []
missing_subtitles = []
if episode_subtitles[1] != None:
actual_subtitles = ast.literal_eval(episode_subtitles[1])
+ if episode_subtitles[2] != None:
desired_subtitles = ast.literal_eval(episode_subtitles[2])
- actual_subtitles_list = []
- if desired_subtitles == None:
- missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
- else:
for item in actual_subtitles:
actual_subtitles_list.append(item[0])
missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
- missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
-
+ missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
+ else:
+ missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
+
c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global))
+
conn_db.commit()
c_db.close()
@@ -125,4 +126,4 @@ def new_scan_subtitles():
c_db.close()
for episode in episodes:
- store_subtitles(path_replace(episode[0].encode('utf-8')))
\ No newline at end of file
+ store_subtitles(path_replace(episode[0].encode('utf-8')))
diff --git a/scheduler.py b/scheduler.py
index 7235838a2..a77e9efac 100644
--- a/scheduler.py
+++ b/scheduler.py
@@ -1,15 +1,22 @@
from get_general_settings import *
from get_series import *
from get_episodes import *
+from list_subtitles import *
from get_subtitle import *
from check_update import *
from apscheduler.schedulers.background import BackgroundScheduler
+from datetime import datetime
scheduler = BackgroundScheduler()
if automatic == 'True':
scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github')
scheduler.add_job(update_series, 'interval', minutes=1, max_instances=1, coalesce=True, id='update_series', name='Update series list from Sonarr')
scheduler.add_job(add_new_episodes, 'interval', minutes=1, max_instances=1, coalesce=True, id='add_new_episodes', name='Add new episodes from Sonarr')
+scheduler.add_job(update_all_episodes, 'cron', hour=4, max_instances=1, coalesce=True, id='update_all_episodes', name='Update all episodes from Sonarr')
+scheduler.add_job(list_missing_subtitles, 'interval', minutes=5, max_instances=1, coalesce=True, id='list_missing_subtitles', name='Process missing subtitles for all series')
scheduler.add_job(wanted_search_missing_subtitles, 'interval', minutes=15, max_instances=1, coalesce=True, id='wanted_search_missing_subtitles', name='Search for wanted subtitles')
scheduler.start()
+
+def execute_now(taskid):
+ scheduler.modify_job(taskid, jobstore=None, next_run_time=datetime.now())
diff --git a/views/episodes.tpl b/views/episodes.tpl
index c2a56aeb4..756d0ecd1 100644
--- a/views/episodes.tpl
+++ b/views/episodes.tpl
@@ -121,7 +121,7 @@
%if len(seasons) == 0:
-
No episode file available for this series.
+
No episode file available for this series or Bazarr is still synchronizing with Sonarr. Please come back later.
%else:
%for season in seasons:
diff --git a/views/series.tpl b/views/series.tpl
index 8dbe41ea8..2b3d6fe7d 100644
--- a/views/series.tpl
+++ b/views/series.tpl
@@ -78,12 +78,6 @@
From d5dd9098ae7c0a19f8c2d0c023949074c1b68567 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 21:37:27 -0500
Subject: [PATCH 25/55] Test
---
list_subtitles.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/list_subtitles.py b/list_subtitles.py
index dcda27734..d4e7e063e 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -89,9 +89,9 @@ def list_missing_subtitles(*no):
for item in actual_subtitles:
actual_subtitles_list.append(item[0])
missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
- missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
else:
missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
+ missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global))
From aad06f946191050b04c66b72ce22acb29efaf522 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 22:14:24 -0500
Subject: [PATCH 26/55] Bug correction
---
list_subtitles.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/list_subtitles.py b/list_subtitles.py
index d4e7e063e..33e6a51cc 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -79,13 +79,13 @@ def list_missing_subtitles(*no):
for episode_subtitles in episodes_subtitles:
actual_subtitles = []
- actual_subtitles_list = []
desired_subtitles = []
missing_subtitles = []
if episode_subtitles[1] != None:
actual_subtitles = ast.literal_eval(episode_subtitles[1])
if episode_subtitles[2] != None:
desired_subtitles = ast.literal_eval(episode_subtitles[2])
+ actual_subtitles_list = []
for item in actual_subtitles:
actual_subtitles_list.append(item[0])
missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
From 77d2a0d5d024ba3d78f26a503531f520f82d6118 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 22:31:20 -0500
Subject: [PATCH 27/55] Bug correction
---
list_subtitles.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/list_subtitles.py b/list_subtitles.py
index 33e6a51cc..52b9675f2 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -81,17 +81,17 @@ def list_missing_subtitles(*no):
actual_subtitles = []
desired_subtitles = []
missing_subtitles = []
+ actual_subtitles_list = []
if episode_subtitles[1] != None:
actual_subtitles = ast.literal_eval(episode_subtitles[1])
- if episode_subtitles[2] != None:
- desired_subtitles = ast.literal_eval(episode_subtitles[2])
- actual_subtitles_list = []
- for item in actual_subtitles:
- actual_subtitles_list.append(item[0])
- missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
- else:
- missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
- missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
+ if episode_subtitles[2] != None:
+ desired_subtitles = ast.literal_eval(episode_subtitles[2])
+ for item in actual_subtitles:
+ actual_subtitles_list.append(item[0])
+ missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
+ else:
+ missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
+ missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global))
From adc525120088550efc77daceed8b16c070e6c050 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 22:51:28 -0500
Subject: [PATCH 28/55] Test
---
list_subtitles.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/list_subtitles.py b/list_subtitles.py
index 52b9675f2..b222ecbc8 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -81,17 +81,17 @@ def list_missing_subtitles(*no):
actual_subtitles = []
desired_subtitles = []
missing_subtitles = []
- actual_subtitles_list = []
if episode_subtitles[1] != None:
actual_subtitles = ast.literal_eval(episode_subtitles[1])
- if episode_subtitles[2] != None:
- desired_subtitles = ast.literal_eval(episode_subtitles[2])
- for item in actual_subtitles:
- actual_subtitles_list.append(item[0])
- missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
- else:
- missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
- missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
+ desired_subtitles = ast.literal_eval(episode_subtitles[2])
+ actual_subtitles_list = []
+ if desired_subtitles == None:
+ missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
+ else:
+ for item in actual_subtitles:
+ actual_subtitles_list.append(item[0])
+ missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
+ missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global))
From 198fd368256d53d17b0fa47a870d21c474ac7b07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 23:27:30 -0500
Subject: [PATCH 29/55] Try to fix memory leak
---
get_episodes.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/get_episodes.py b/get_episodes.py
index 3f90747f9..f586d2e18 100644
--- a/get_episodes.py
+++ b/get_episodes.py
@@ -60,7 +60,16 @@ def update_all_episodes():
# Close database connection
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
full_scan_subtitles()
list_missing_subtitles()
@@ -124,6 +133,15 @@ def add_new_episodes():
# Close database connection
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
new_scan_subtitles()
try:
From fbc136a2f177bf5a9643e767d7eb1c5353a0c61a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 23:33:22 -0500
Subject: [PATCH 30/55] test
---
get_episodes.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/get_episodes.py b/get_episodes.py
index f586d2e18..cac821c0f 100644
--- a/get_episodes.py
+++ b/get_episodes.py
@@ -143,8 +143,8 @@ def add_new_episodes():
del c
# Store substitles from episodes we've just added
- new_scan_subtitles()
- try:
- list_missing_subtitles()
- except:
- pass
+ #new_scan_subtitles()
+ #try:
+ # list_missing_subtitles()
+ #except:
+ # pass
From a7defd4e6baa3ec556ba21a554402ecb470bf917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 15 Nov 2017 23:37:18 -0500
Subject: [PATCH 31/55] Revert "test"
This reverts commit fbc136a2f177bf5a9643e767d7eb1c5353a0c61a.
---
get_episodes.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/get_episodes.py b/get_episodes.py
index cac821c0f..f586d2e18 100644
--- a/get_episodes.py
+++ b/get_episodes.py
@@ -143,8 +143,8 @@ def add_new_episodes():
del c
# Store substitles from episodes we've just added
- #new_scan_subtitles()
- #try:
- # list_missing_subtitles()
- #except:
- # pass
+ new_scan_subtitles()
+ try:
+ list_missing_subtitles()
+ except:
+ pass
From e57e03da32389c1084f3cfea30403b5fde3e50ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 05:50:52 -0500
Subject: [PATCH 32/55] Finding memory link under docker
---
get_episodes.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/get_episodes.py b/get_episodes.py
index f586d2e18..2387b39d0 100644
--- a/get_episodes.py
+++ b/get_episodes.py
@@ -2,6 +2,9 @@
import sqlite3
import requests
+from pympler.tracker import SummaryTracker
+tracker = SummaryTracker()
+
from get_general_settings import *
from list_subtitles import *
@@ -148,3 +151,4 @@ def add_new_episodes():
list_missing_subtitles()
except:
pass
+ tracker.print_diff()
From d9bff60884f998dae0a0d67351b3ed09b8d3de08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 09:22:55 -0500
Subject: [PATCH 33/55] Bug correction
---
bazarr.py | 8 ++++----
get_episodes.py | 4 ----
list_subtitles.py | 5 +++--
3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/bazarr.py b/bazarr.py
index b5f5e103f..4e54a8568 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -2,8 +2,8 @@
from bottle import route, run, template, static_file, request, redirect
import bottle
-bottle.debug(True)
-bottle.TEMPLATES.clear()
+#bottle.debug(True)
+#bottle.TEMPLATES.clear()
import os
bottle.TEMPLATE_PATH.insert(0,os.path.join(os.path.dirname(__file__), 'views/'))
@@ -67,9 +67,9 @@ def configure_logging():
f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',
'%d/%m/%Y %H:%M:%S')
fh.setFormatter(f)
- logging.getLogger("enzyme").setLevel(logging.WARNING)
+ logging.getLogger("enzyme").setLevel(logging.ERROR)
logging.getLogger("apscheduler").setLevel(logging.WARNING)
- logging.getLogger("subliminal").setLevel(logging.WARNING)
+ logging.getLogger("subliminal").setLevel(logging.ERROR)
root = logging.getLogger()
root.setLevel(log_level)
root.addHandler(fh)
diff --git a/get_episodes.py b/get_episodes.py
index 2387b39d0..f586d2e18 100644
--- a/get_episodes.py
+++ b/get_episodes.py
@@ -2,9 +2,6 @@
import sqlite3
import requests
-from pympler.tracker import SummaryTracker
-tracker = SummaryTracker()
-
from get_general_settings import *
from list_subtitles import *
@@ -151,4 +148,3 @@ def add_new_episodes():
list_missing_subtitles()
except:
pass
- tracker.print_diff()
diff --git a/list_subtitles.py b/list_subtitles.py
index b222ecbc8..e5c47aa03 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -83,6 +83,7 @@ def list_missing_subtitles(*no):
missing_subtitles = []
if episode_subtitles[1] != None:
actual_subtitles = ast.literal_eval(episode_subtitles[1])
+ if episode_subtitles[2] != None:
desired_subtitles = ast.literal_eval(episode_subtitles[2])
actual_subtitles_list = []
if desired_subtitles == None:
@@ -91,7 +92,7 @@ def list_missing_subtitles(*no):
for item in actual_subtitles:
actual_subtitles_list.append(item[0])
missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
- missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
+ missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global))
@@ -118,7 +119,7 @@ def series_scan_subtitles(no):
store_subtitles(path_replace(episode[0].encode('utf-8')))
list_missing_subtitles(no)
-
+
def new_scan_subtitles():
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c_db = conn_db.cursor()
From cd3f2b0721497df08540bc031818e76e498b3fc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 09:53:12 -0500
Subject: [PATCH 34/55] Bug correction
---
bazarr.py | 13 ++++++++-----
views/episodes.tpl | 6 ++++--
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/bazarr.py b/bazarr.py
index 4e54a8568..ce1d72ea4 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -142,7 +142,8 @@ def episodes(no):
c = conn.cursor()
series_details = []
- series_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone()
+ series_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired, tvdbid FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone()
+ tvdbid = series_details[5]
episodes = c.execute("SELECT title, path_substitution(path), season, episode, subtitles, sonarrSeriesId, missing_subtitles, sonarrEpisodeId FROM table_episodes WHERE sonarrSeriesId LIKE ? ORDER BY episode ASC", (str(no),)).fetchall()
episodes = reversed(sorted(episodes, key=operator.itemgetter(2)))
@@ -151,7 +152,7 @@ def episodes(no):
seasons_list.append(list(season))
c.close()
- return template('episodes', no=no, details=series_details, seasons=seasons_list, url_sonarr_short=url_sonarr_short, base_url=base_url)
+ return template('episodes', no=no, details=series_details, seasons=seasons_list, url_sonarr_short=url_sonarr_short, base_url=base_url, tvdbid=tvdbid)
@route(base_url + 'scan_disk/', method='GET')
def scan_disk(no):
@@ -325,6 +326,7 @@ def remove_subtitles():
subtitlesPath = request.forms.get('subtitlesPath')
sonarrSeriesId = request.forms.get('sonarrSeriesId')
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
+ tvdbid = request.forms.get('tvdbid')
try:
os.remove(subtitlesPath)
@@ -333,7 +335,7 @@ def remove_subtitles():
except OSError:
pass
store_subtitles(episodePath)
- list_missing_subtitles(sonarrSeriesId)
+ list_missing_subtitles(tvdbid)
@route(base_url + 'get_subtitle', method='POST')
def get_subtitle():
@@ -344,6 +346,7 @@ def get_subtitle():
hi = request.forms.get('hi')
sonarrSeriesId = request.forms.get('sonarrSeriesId')
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
+ tvdbid = request.forms.get('tvdbid')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
@@ -360,9 +363,9 @@ def get_subtitle():
if result is not None:
history_log(1, sonarrSeriesId, sonarrEpisodeId, result)
store_subtitles(episodePath)
- list_missing_subtitles(sonarrSeriesId)
+ list_missing_subtitles(tvdbid)
redirect(ref)
except OSError:
- redirect(ref + '?error=2')
+ pass
run(host=ip, port=port, server='waitress')
diff --git a/views/episodes.tpl b/views/episodes.tpl
index 756d0ecd1..fcc318a77 100644
--- a/views/episodes.tpl
+++ b/views/episodes.tpl
@@ -221,7 +221,8 @@
language: $(this).attr("data-language"),
subtitlesPath: $(this).attr("data-subtitlesPath"),
sonarrSeriesId: $(this).attr("data-sonarrSeriesId"),
- sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId")
+ sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"),
+ tvdbid: {{tvdbid}}
};
$.ajax({
url: "{{base_url}}remove_subtitles",
@@ -238,7 +239,8 @@
language: $(this).attr("data-language"),
hi: $(this).attr("data-hi"),
sonarrSeriesId: $(this).attr("data-sonarrSeriesId"),
- sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId")
+ sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"),
+ tvdbid: {{tvdbid}}
};
$.ajax({
url: "{{base_url}}get_subtitle",
From 43abd5c3fbeafc8887447b51e6d2892f09786f5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 11:41:49 -0500
Subject: [PATCH 35/55] Memory leak investigation
---
get_subtitle.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 18e2c7baf..eb944391b 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -8,6 +8,8 @@
from list_subtitles import *
from utils import *
+from memory_profiler import profile
+
# configure the cache
region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')})
@@ -64,7 +66,7 @@ def wanted_download_subtitles(path):
store_subtitles(path_replace(episode[0]))
list_missing_subtitles(episode[3])
history_log(1, episode[3], episode[2], message)
-
+@profile
def wanted_search_missing_subtitles():
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
db.create_function("path_substitution", 1, path_replace)
From e049c1902fc49a3d19fa5e2fb0f6d9a6732dd919 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 12:03:57 -0500
Subject: [PATCH 36/55] Test
---
get_subtitle.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index eb944391b..5bbb76fcd 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -8,7 +8,8 @@
from list_subtitles import *
from utils import *
-from memory_profiler import profile
+from pympler.tracker import SummaryTracker
+tracker = SummaryTracker()
# configure the cache
region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')})
@@ -78,3 +79,4 @@ def wanted_search_missing_subtitles():
for episode in data:
wanted_download_subtitles(episode[0])
+ tracker.print_diff()
From 00aec30e15da7eedcda5941d41350f4cc98e2570 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 12:04:20 -0500
Subject: [PATCH 37/55] Test
---
get_subtitle.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 5bbb76fcd..44451c0c5 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -67,7 +67,7 @@ def wanted_download_subtitles(path):
store_subtitles(path_replace(episode[0]))
list_missing_subtitles(episode[3])
history_log(1, episode[3], episode[2], message)
-@profile
+
def wanted_search_missing_subtitles():
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
db.create_function("path_substitution", 1, path_replace)
From 2fcfa65a310c9e56f2a75873058e484fa42c7d07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 12:09:55 -0500
Subject: [PATCH 38/55] Test
---
bazarr.py | 4 ++++
get_subtitle.py | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bazarr.py b/bazarr.py
index ce1d72ea4..36c32f6e9 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -20,6 +20,9 @@
from fdsend import send_file
import urllib
+from pympler.tracker import SummaryTracker
+tracker = SummaryTracker()
+
from init_db import *
from get_languages import *
from get_providers import *
@@ -215,6 +218,7 @@ def wanted_search_missing_subtitles_list():
ref = request.environ['HTTP_REFERER']
wanted_search_missing_subtitles()
+ tracker.print_diff()
redirect(ref)
diff --git a/get_subtitle.py b/get_subtitle.py
index 44451c0c5..18e2c7baf 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -8,9 +8,6 @@
from list_subtitles import *
from utils import *
-from pympler.tracker import SummaryTracker
-tracker = SummaryTracker()
-
# configure the cache
region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')})
@@ -79,4 +76,3 @@ def wanted_search_missing_subtitles():
for episode in data:
wanted_download_subtitles(episode[0])
- tracker.print_diff()
From 185bc2a80d23684c0faa36c9249491f7e421842c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 12:23:37 -0500
Subject: [PATCH 39/55] Test
---
get_subtitle.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/get_subtitle.py b/get_subtitle.py
index 18e2c7baf..c04bf20f8 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -76,3 +76,7 @@ def wanted_search_missing_subtitles():
for episode in data:
wanted_download_subtitles(episode[0])
+
+ del db
+ del c
+ del data
From 4ac881693728722e01097f5b15424e41b7e7fd41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 12:46:59 -0500
Subject: [PATCH 40/55] Test
---
get_subtitle.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/get_subtitle.py b/get_subtitle.py
index c04bf20f8..918683c18 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -65,6 +65,13 @@ def wanted_download_subtitles(path):
list_missing_subtitles(episode[3])
history_log(1, episode[3], episode[2], message)
+ del conn_db
+ del c_db
+ del episodes_details
+ del enabled_providers
+ del providers_list
+ del message
+
def wanted_search_missing_subtitles():
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
db.create_function("path_substitution", 1, path_replace)
From 5380e079759b88bd90247d87266e8016939090cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:26:09 -0500
Subject: [PATCH 41/55] Test
---
bazarr.py | 4 ----
get_subtitle.py | 7 +++++++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/bazarr.py b/bazarr.py
index 36c32f6e9..ce1d72ea4 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -20,9 +20,6 @@
from fdsend import send_file
import urllib
-from pympler.tracker import SummaryTracker
-tracker = SummaryTracker()
-
from init_db import *
from get_languages import *
from get_providers import *
@@ -218,7 +215,6 @@ def wanted_search_missing_subtitles_list():
ref = request.environ['HTTP_REFERER']
wanted_search_missing_subtitles()
- tracker.print_diff()
redirect(ref)
diff --git a/get_subtitle.py b/get_subtitle.py
index 918683c18..04fd74c97 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -26,6 +26,13 @@ def download_subtitle(path, language, hi, providers):
except:
return None
+ del video
+ del best_subtitles
+ del result
+ del downloaded_provider
+ del downloaded_language
+ del message
+
def series_download_subtitles(no):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c_db = conn_db.cursor()
From 77162c1d48f04593d43e1c8bfb9b8085ac2c0831 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:30:48 -0500
Subject: [PATCH 42/55] Test
---
get_subtitle.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 04fd74c97..d16101b84 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -13,18 +13,18 @@
def download_subtitle(path, language, hi, providers):
video = scan_video(path)
- best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
- try:
- best_subtitle = best_subtitles[video][0]
-
- result = save_subtitles(video, [best_subtitle])
- downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8]
- downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name
- message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "."
-
- return message
- except:
- return None
+ #best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
+ #try:
+ # best_subtitle = best_subtitles[video][0]
+ #
+ # result = save_subtitles(video, [best_subtitle])
+ # downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8]
+ # downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name
+ # message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "."
+ #
+ # return message
+ #except:
+ # return None
del video
del best_subtitles
From 18603ee29d4c4f59958e4c9423a8ab5cec15f851 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:33:37 -0500
Subject: [PATCH 43/55] Test
---
get_subtitle.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index d16101b84..a93902234 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -12,7 +12,7 @@
region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')})
def download_subtitle(path, language, hi, providers):
- video = scan_video(path)
+ #video = scan_video(path)
#best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
#try:
# best_subtitle = best_subtitles[video][0]
@@ -26,12 +26,12 @@ def download_subtitle(path, language, hi, providers):
#except:
# return None
- del video
- del best_subtitles
- del result
- del downloaded_provider
- del downloaded_language
- del message
+ #del video
+ #del best_subtitles
+ #del result
+ #del downloaded_provider
+ #del downloaded_language
+ #del message
def series_download_subtitles(no):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
From 7d8ad0d585f0039e13ddfd981bbec8cb65990b7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:35:05 -0500
Subject: [PATCH 44/55] Test
---
get_subtitle.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/get_subtitle.py b/get_subtitle.py
index a93902234..5fc977739 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -12,6 +12,7 @@
region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')})
def download_subtitle(path, language, hi, providers):
+ pass
#video = scan_video(path)
#best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
#try:
From 2eef8c29e77c55980803cece14bc5d8afd86174c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:39:47 -0500
Subject: [PATCH 45/55] Test
---
get_subtitle.py | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 5fc977739..523f080c2 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -12,27 +12,26 @@
region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')})
def download_subtitle(path, language, hi, providers):
- pass
- #video = scan_video(path)
- #best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
- #try:
- # best_subtitle = best_subtitles[video][0]
- #
- # result = save_subtitles(video, [best_subtitle])
- # downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8]
- # downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name
- # message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "."
- #
- # return message
- #except:
- # return None
+ video = scan_video(path)
+ best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
+ try:
+ best_subtitle = best_subtitles[video][0]
+
+ result = save_subtitles(video, [best_subtitle])
+ downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8]
+ downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name
+ message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "."
+
+ return message
+ except:
+ return None
- #del video
- #del best_subtitles
- #del result
- #del downloaded_provider
- #del downloaded_language
- #del message
+ del video
+ del best_subtitles
+ del result
+ del downloaded_provider
+ del downloaded_language
+ del message
def series_download_subtitles(no):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
@@ -52,7 +51,7 @@ def series_download_subtitles(no):
if message is not None:
store_subtitles(path_replace(episode[0]))
history_log(1, no, episode[2], message)
- list_missing_subtitles(no)
+ #list_missing_subtitles(no)
def wanted_download_subtitles(path):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
From e1b972c56135548ab6e332200b2e2cb35a7dede1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:42:23 -0500
Subject: [PATCH 46/55] Test
---
get_subtitle.py | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 523f080c2..a32942540 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -51,26 +51,26 @@ def series_download_subtitles(no):
if message is not None:
store_subtitles(path_replace(episode[0]))
history_log(1, no, episode[2], message)
- #list_missing_subtitles(no)
+ list_missing_subtitles(no)
def wanted_download_subtitles(path):
- conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
- 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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
- c_db.close()
+ #conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
+ #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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
+ #c_db.close()
- providers_list = []
- for provider in enabled_providers:
- providers_list.append(provider[0])
+ #providers_list = []
+ #for provider in enabled_providers:
+ # providers_list.append(provider[0])
- for episode in episodes_details:
- for language in ast.literal_eval(episode[1]):
- message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list)
- if message is not None:
- store_subtitles(path_replace(episode[0]))
- list_missing_subtitles(episode[3])
- history_log(1, episode[3], episode[2], message)
+ #for episode in episodes_details:
+ # for language in ast.literal_eval(episode[1]):
+ # message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list)
+ # if message is not None:
+ # store_subtitles(path_replace(episode[0]))
+ # list_missing_subtitles(episode[3])
+ # history_log(1, episode[3], episode[2], message)
del conn_db
del c_db
From 917526340dabaeeb7c8fceb828242f3d3f0b55ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:46:30 -0500
Subject: [PATCH 47/55] Test
---
get_subtitle.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index a32942540..74f3fcd37 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -54,8 +54,8 @@ def series_download_subtitles(no):
list_missing_subtitles(no)
def wanted_download_subtitles(path):
- #conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
- #c_db = conn_db.cursor()
+ conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
+ 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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
#c_db.close()
From 6856cd6dd7e8c15fccbc793f1879b28e7acd14be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:48:47 -0500
Subject: [PATCH 48/55] Test
---
get_subtitle.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 74f3fcd37..8a1c69e5f 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -55,7 +55,7 @@ def series_download_subtitles(no):
def wanted_download_subtitles(path):
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()
#episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
#c_db.close()
From a39284d005fa8d2a5dd55e258a2ea50b62877c8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:53:39 -0500
Subject: [PATCH 49/55] Test
---
get_subtitle.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 8a1c69e5f..09b6641c7 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -58,7 +58,7 @@ def wanted_download_subtitles(path):
#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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
- #c_db.close()
+ conn.close()
#providers_list = []
#for provider in enabled_providers:
From 475754a63e58827e0f42e9b4be02408bbf51d48d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 13:55:37 -0500
Subject: [PATCH 50/55] Test
---
get_subtitle.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 09b6641c7..fd45f6416 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -58,7 +58,7 @@ def wanted_download_subtitles(path):
#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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
- conn.close()
+ conn_db.close()
#providers_list = []
#for provider in enabled_providers:
From 856323f02401191bac2f037972c838322de42add Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 16 Nov 2017 14:09:40 -0500
Subject: [PATCH 51/55] Test
---
get_subtitle.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index fd45f6416..794b8093b 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -55,22 +55,22 @@ def series_download_subtitles(no):
def wanted_download_subtitles(path):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
- #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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
- conn_db.close()
+ 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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
+ c_db.close()
- #providers_list = []
- #for provider in enabled_providers:
- # providers_list.append(provider[0])
+ providers_list = []
+ for provider in enabled_providers:
+ providers_list.append(provider[0])
- #for episode in episodes_details:
- # for language in ast.literal_eval(episode[1]):
- # message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list)
- # if message is not None:
- # store_subtitles(path_replace(episode[0]))
- # list_missing_subtitles(episode[3])
- # history_log(1, episode[3], episode[2], message)
+ for episode in episodes_details:
+ for language in ast.literal_eval(episode[1]):
+ message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list)
+ if message is not None:
+ store_subtitles(path_replace(episode[0]))
+ list_missing_subtitles(episode[3])
+ history_log(1, episode[3], episode[2], message)
del conn_db
del c_db
From 3acc2cf8d3f119398131a8ac8ce22cd84e67225f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Fri, 17 Nov 2017 23:12:37 -0500
Subject: [PATCH 52/55] Typo
---
list_subtitles.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/list_subtitles.py b/list_subtitles.py
index e5c47aa03..a5cd58ada 100644
--- a/list_subtitles.py
+++ b/list_subtitles.py
@@ -36,7 +36,7 @@ def store_subtitles(file):
languages = []
actual_subtitles = []
if os.path.exists(file):
- if os.path.splitext(file)[1] == '.mkv':
+ if os.path.splitext(file)[1] == '.mkv':
try:
with open(file, 'rb') as f:
mkv = enzyme.MKV(f)
From 5b43af7a4c33f6f0697c47436f3b15d7d478e622 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Sat, 18 Nov 2017 08:34:06 -0500
Subject: [PATCH 53/55] Unexistent variable deletion error
---
get_subtitle.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/get_subtitle.py b/get_subtitle.py
index 794b8093b..605a7c60a 100644
--- a/get_subtitle.py
+++ b/get_subtitle.py
@@ -28,10 +28,13 @@ def download_subtitle(path, language, hi, providers):
del video
del best_subtitles
- del result
- del downloaded_provider
- del downloaded_language
- del message
+ try:
+ del result
+ del downloaded_provider
+ del downloaded_language
+ del message
+ except:
+ pass
def series_download_subtitles(no):
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
@@ -77,7 +80,10 @@ def wanted_download_subtitles(path):
del episodes_details
del enabled_providers
del providers_list
- del message
+ try:
+ del message
+ except:
+ pass
def wanted_search_missing_subtitles():
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
From 09cb87feeb4be108891196d409078c93e3b91381 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Sun, 19 Nov 2017 22:38:06 -0500
Subject: [PATCH 54/55] System --> Scheduler fine tuning
---
bazarr.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++--
views/system.tpl | 2 +-
2 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/bazarr.py b/bazarr.py
index ce1d72ea4..d3dcfcc97 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -302,12 +302,87 @@ def system():
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
logs.append(line.rstrip())
+ def get_time_from_interval(interval):
+ interval_clean = interval.split('[')
+ interval_clean = interval_clean[1][:-1]
+ interval_split = interval_clean.split(':')
+
+ text = "every "
+ if interval_split[0] != "0":
+ text = text + interval_split[0]
+ if interval_split[0] == "1":
+ text = text + " hour"
+ else:
+ text = text + " hours"
+
+ if interval_split[2] == "00":
+ text = text + " and "
+ elif interval_split[1] != "00":
+ text = text + ", "
+ if interval_split[1] != "00":
+ text = text + interval_split[1].lstrip("0")
+ if interval_split[1].lstrip("0") == "1":
+ text = text + " minute"
+ else:
+ text = text + " minutes"
+
+ if interval_split[2] != "00":
+ text = text + " and "
+ if interval_split[1] == "00":
+ text = text + " and "
+ if interval_split[2] != "00":
+ text = text + interval_split[2].lstrip("0")
+ if interval_split[2].lstrip("0") == "1":
+ text = text + " second"
+ else:
+ text = text + " seconds"
+
+ return text
+
+ def get_time_from_cron(cron):
+ text = "at "
+ hour = str(cron[5])
+ minute = str(cron[6])
+ second = str(cron[7])
+
+ if hour != "0" and hour != "*":
+ text = text + hour
+ if hour == "0" or hour == "1":
+ text = text + " hour"
+ else:
+ text = text + " hours"
+
+ if minute != "*" and second != "0":
+ text = text + ", "
+ elif minute == "*" and second != "0":
+ text = text + " and "
+ elif minute != "0" and minute != "*" and second == "0":
+ text = text + " and "
+ if minute != "0" and minute != "*":
+ text = text + minute
+ if minute == "0" or minute == "1":
+ text = text + " minute"
+ else:
+ text = text + " minutes"
+
+ if second != "0" and second != "*":
+ text = text + " and "
+ if second != "0" and second != "*":
+ text = text + second
+ if second == "0" or second == "1":
+ text = text + " second"
+ else:
+ text = text + " seconds"
+
+ return text
+
+
task_list = []
for job in scheduler.get_jobs():
if job.trigger.__str__().startswith('interval'):
- task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
+ task_list.append([job.name, get_time_from_interval(str(job.trigger)), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
elif job.trigger.__str__().startswith('cron'):
- task_list.append([job.name, job.trigger.__str__(), 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)
diff --git a/views/system.tpl b/views/system.tpl
index 3f9b43ffb..7f35d7d3e 100644
--- a/views/system.tpl
+++ b/views/system.tpl
@@ -83,7 +83,7 @@
Name
-
Interval
+
Execution Frequency
Next Execution
From 3c216ad8a1c0e5a0fb67df60f3bb23ade7b3ed1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Sun, 19 Nov 2017 22:49:17 -0500
Subject: [PATCH 55/55] Bug correction
---
bazarr.py | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/bazarr.py b/bazarr.py
index d3dcfcc97..55d549548 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -307,32 +307,36 @@ def get_time_from_interval(interval):
interval_clean = interval_clean[1][:-1]
interval_split = interval_clean.split(':')
+ hour = interval_split[0]
+ minute = interval_split[1].lstrip("0")
+ second = interval_split[2].lstrip("0")
+
text = "every "
- if interval_split[0] != "0":
- text = text + interval_split[0]
- if interval_split[0] == "1":
+ if hour != "0":
+ text = text + hour
+ if hour == "1":
text = text + " hour"
else:
text = text + " hours"
- if interval_split[2] == "00":
- text = text + " and "
- elif interval_split[1] != "00":
+ if minute != "" and second != "":
text = text + ", "
- if interval_split[1] != "00":
- text = text + interval_split[1].lstrip("0")
- if interval_split[1].lstrip("0") == "1":
+ elif minute == "" and second != "":
+ text = text + " and "
+ elif minute != "" and second == "":
+ text = text + " and "
+ if minute != "":
+ text = text + minute
+ if minute == "1":
text = text + " minute"
else:
text = text + " minutes"
- if interval_split[2] != "00":
+ if second != "":
text = text + " and "
- if interval_split[1] == "00":
- text = text + " and "
- if interval_split[2] != "00":
- text = text + interval_split[2].lstrip("0")
- if interval_split[2].lstrip("0") == "1":
+ if second != "":
+ text = text + second
+ if second == "1":
text = text + " second"
else:
text = text + " seconds"