From 184d2b47e90cc19fc3b1012e48d2ed2e11f0762d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 16 Sep 2017 20:11:47 -0400 Subject: [PATCH] Continuing development --- .gitignore | 2 ++ bazarr.db | Bin 1200128 -> 1200128 bytes bazarr.py | 23 ++++++++++++----------- get_subtitle.py | 15 +++++++++++++++ views/episodes.tpl | 36 +++++++++++++++--------------------- 5 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 get_subtitle.py diff --git a/.gitignore b/.gitignore index 0d20b6487..2a7da2d1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.pyc +bazarr.db +cachefile.dbm diff --git a/bazarr.db b/bazarr.db index 3763b5dd92c563d9e249fc7cca19bdeb14a09696..97f40554ab2ad0c01b5cca3a6f8e771b4bd95f1a 100644 GIT binary patch delta 400 zcmYk%y-Pw-7{~GR+(*sp>y-)vgsu8ss#oqTzTM zHuz~7$0TD%yp^%LU$L+#!z1ZNk|4>BS(JCwa8ML#_y8_FWF&0B0(v`u9_CsdXZckV z1H4d2)w;MmytcYNkQS9Xrl3=0OvMRl58h#v?XnN{eRy{bS9q$4mtyG&=fD{zGJv1ES$`j823{Q=C`tz+O5)&~K3uzOrrqy?!K1~`$5h45YbRE({5Q&nHsv^fIkWbP20={F_wI#qDEoomJ!3InEy~13?8HHw#6{dh5!Iq6cKZd@n}(|Z delta 399 zcmYk$O-lk{5C`yQcGm34m$ZbUj5dg9i|A4ZFOftq-m(-ghASj_=ndB7cPwnJZ=`ml', method='GET') def image_proxy(url): - print url_sonarr_short + url img_pil = Image.open(BytesIO(requests.get(url_sonarr_short + '/' + url).content)) img_buffer = BytesIO() img_pil.tobytes() @@ -78,7 +78,7 @@ def episodes(no): c = conn.cursor() series_details = [] - series_details = c.execute("SELECT title, overview, poster, fanart FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone() + series_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone() sqlite3.enable_callback_tracebacks(True) episodes = c.execute("SELECT title, path_substitution(path), season, episode, subtitles, sonarrSeriesId, missing_subtitles(path) FROM table_episodes WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchall() @@ -133,22 +133,23 @@ def remove_subtitles(): try: os.remove(subtitlesPath) - store_subtitles(episodePath) - redirect('/episodes/' + sonarrSeriesId) except OSError: - redirect('/episodes/' + sonarrSeriesId + '?error=1') + pass + store_subtitles(episodePath) + redirect('/episodes/' + sonarrSeriesId) -@route('/remove_subtitles', method='GET') -def remove_subtitles(): +@route('/get_subtitle', method='GET') +def get_subtitle(): episodePath = request.GET.episodePath - subtitlesPath = request.GET.subtitlesPath + language = request.GET.language + hi = request.GET.hi sonarrSeriesId = request.GET.sonarrSeriesId - + try: - os.remove(subtitlesPath) + download_subtitle(episodePath, language, hi, None) store_subtitles(episodePath) redirect('/episodes/' + sonarrSeriesId) except OSError: - redirect('/episodes/' + sonarrSeriesId + '?error=1') + redirect('/episodes/' + sonarrSeriesId + '?error=2') run(host=ip, port=port) diff --git a/get_subtitle.py b/get_subtitle.py new file mode 100644 index 000000000..f90160f43 --- /dev/null +++ b/get_subtitle.py @@ -0,0 +1,15 @@ +import os +from babelfish import * +from subliminal import * + +# configure the cache +region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'}) + +def download_subtitle(path, language, hi, providers): + video = scan_video(path) + best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) + best_subtitle = best_subtitles[video][0] + + return save_subtitles(video, [best_subtitle]) + +#download_subtitle('Z:\Series TV\Vikings\Season 03\Vikings.S03E03.720p.HDTV.x264-KILLERS.mkv', 'fra', False, None) diff --git a/views/episodes.tpl b/views/episodes.tpl index 600abfb4c..e1611de5f 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -75,6 +75,8 @@ %import ast + %import pycountry + %from get_general_settings import *
Loading...
@@ -144,7 +146,6 @@ Title Existing subtitles Missing subtitles - @@ -156,17 +157,16 @@ %actual_languages = ast.literal_eval(episode[4]) %if actual_languages is not None: %for language in actual_languages: - - %if language[1] is not None: - - {{language[0]}} - - - %else: -
- {{language[0]}} -
- %end + %if language[1] is not None: + + {{language[0]}} + + + %else: +
+ {{language[0]}} +
+ %end %end %end @@ -174,19 +174,13 @@ %missing_languages = ast.literal_eval(episode[6]) %if missing_languages is not None: %for language in missing_languages: - + + %end %end - - %if len(missing_languages) > 0: -
- -
- %end - %end