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] 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