From 39edad882e786f65e6bd1f46fde59aed789f38b5 Mon Sep 17 00:00:00 2001 From: Kevin Lemonnier Date: Wed, 14 Jan 2015 16:06:28 +0100 Subject: [PATCH 1/2] Added config option download_url Added field to configure download_url in general --> interface Added link to download episodes in the displayShow template, using download_url --- .../interfaces/default/config_general.tmpl | 12 +++++++++++ gui/slick/interfaces/default/displayShow.tmpl | 21 +++++++++++++++++++ sickbeard/__init__.py | 7 ++++++- sickbeard/webserve.py | 5 +++-- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl index a16527b4..20e3e725 100644 --- a/gui/slick/interfaces/default/config_general.tmpl +++ b/gui/slick/interfaces/default/config_general.tmpl @@ -301,6 +301,18 @@ +
+ + +
+ + diff --git a/gui/slick/interfaces/default/displayShow.tmpl b/gui/slick/interfaces/default/displayShow.tmpl index 26268fd4..22d68a17 100644 --- a/gui/slick/interfaces/default/displayShow.tmpl +++ b/gui/slick/interfaces/default/displayShow.tmpl @@ -6,6 +6,7 @@ #from lib import subliminal #import os.path, os #import datetime +#import urllib #set global $title=$show.name ##set global $header = '' % @@ -376,6 +377,7 @@ #end if Name Airdate + Download #if $sickbeard.USE_SUBTITLES and $show.subtitles: Subtitles #end if @@ -470,6 +472,25 @@ #if int($epResult['airdate']) == 1 then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($epResult['airdate'],$show.airs,$show.network)))# + + + #if len($sickbeard.DOWNLOAD_URL) > 0 and len($epResult['location']) > 0 + #set $filename = $epResult['location'] + #for $rootDir in $sickbeard.ROOT_DIRS.split('|') + #if $rootDir.startswith('/') + #set $filename = $filename.replace($rootDir, "") + #end if + #end for + #set $filename = $sickbeard.DOWNLOAD_URL + $urllib.quote($filename.encode('utf8')) +
Download
+ #else + #if $epLoc and $show._location and $epLoc.lower().startswith($show._location.lower()): + $epLoc[len($show._location)+1:] + #elif $epLoc and (not $epLoc.lower().startswith($show._location.lower()) or not $show._location): + $epLoc + #end if + #end if + #if $sickbeard.USE_SUBTITLES and $show.subtitles: diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index a97434ca..52e6edf6 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -138,6 +138,8 @@ WEB_IPV6 = None PLAY_VIDEOS = False +DOWNLOAD_URL = None + HANDLE_REVERSE_PROXY = False PROXY_SETTING = None PROXY_INDEXERS = True @@ -525,7 +527,7 @@ def initialize(consoleLogging=True): USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, PROXY_INDEXERS, \ AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \ ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \ - ANIME_SPLIT_HOME, SCENE_DEFAULT, PLAY_VIDEOS, BACKLOG_DAYS, GIT_ORG, GIT_REPO, GIT_USERNAME, GIT_PASSWORD, \ + ANIME_SPLIT_HOME, SCENE_DEFAULT, PLAY_VIDEOS, DOWNLOAD_URL, BACKLOG_DAYS, GIT_ORG, GIT_REPO, GIT_USERNAME, GIT_PASSWORD, \ GIT_AUTOISSUES, gh if __INITIALIZED__: @@ -640,6 +642,8 @@ def initialize(consoleLogging=True): PLAY_VIDEOS = bool(check_setting_int(CFG, 'General', 'play_videos', 0)) + DOWNLOAD_URL = check_setting_str(CFG, 'General', 'download_url', "") + LOCALHOST_IP = check_setting_str(CFG, 'General', 'localhost_ip', '') CPU_PRESET = check_setting_str(CFG, 'General', 'cpu_preset', 'NORMAL') @@ -1431,6 +1435,7 @@ def save_config(): new_config['General']['web_username'] = WEB_USERNAME new_config['General']['web_password'] = helpers.encrypt(WEB_PASSWORD, ENCRYPTION_VERSION) new_config['General']['play_videos'] = int(PLAY_VIDEOS) + new_config['General']['download_url'] = DOWNLOAD_URL new_config['General']['localhost_ip'] = LOCALHOST_IP new_config['General']['cpu_preset'] = CPU_PRESET new_config['General']['anon_redirect'] = ANON_REDIRECT diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 996e3086..2257ab7b 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3431,13 +3431,14 @@ class ConfigGeneral(Config): proxy_setting=None, proxy_indexers=None, anon_redirect=None, git_path=None, git_remote=None, calendar_unprotected=None, fuzzy_dating=None, trim_zero=None, date_preset=None, date_preset_na=None, time_preset=None, - indexer_timeout=None, play_videos=None, rootDir=None, theme_name=None, + indexer_timeout=None, play_videos=None, download_url=None, rootDir=None, theme_name=None, git_reset=None, git_username=None, git_password=None, git_autoissues=None): results = [] # Misc sickbeard.PLAY_VIDEOS = config.checkbox_to_value(play_videos) + sickbeard.DOWNLOAD_URL = download_url sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) config.change_VERSION_NOTIFY(config.checkbox_to_value(version_notify)) sickbeard.AUTO_UPDATE = config.checkbox_to_value(auto_update) @@ -4716,4 +4717,4 @@ class ErrorLogs(WebRoot): if issue: ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number) - return self.redirect("/errorlogs/") \ No newline at end of file + return self.redirect("/errorlogs/") From 53c9418084a45903718ef48660747bef993b9088 Mon Sep 17 00:00:00 2001 From: Kevin Lemonnier Date: Thu, 15 Jan 2015 11:11:32 +0100 Subject: [PATCH 2/2] Don't show the Download column when the download_url is not set --- gui/slick/interfaces/default/displayShow.tmpl | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gui/slick/interfaces/default/displayShow.tmpl b/gui/slick/interfaces/default/displayShow.tmpl index 22d68a17..c85e9f49 100644 --- a/gui/slick/interfaces/default/displayShow.tmpl +++ b/gui/slick/interfaces/default/displayShow.tmpl @@ -377,7 +377,9 @@ #end if Name Airdate + #if len($sickbeard.DOWNLOAD_URL) > 0 Download + #end if #if $sickbeard.USE_SUBTITLES and $show.subtitles: Subtitles #end if @@ -473,8 +475,8 @@ #if int($epResult['airdate']) == 1 then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($epResult['airdate'],$show.airs,$show.network)))# - #if len($sickbeard.DOWNLOAD_URL) > 0 and len($epResult['location']) > 0 + #set $filename = $epResult['location'] #for $rootDir in $sickbeard.ROOT_DIRS.split('|') #if $rootDir.startswith('/') @@ -483,14 +485,10 @@ #end for #set $filename = $sickbeard.DOWNLOAD_URL + $urllib.quote($filename.encode('utf8'))
Download
- #else - #if $epLoc and $show._location and $epLoc.lower().startswith($show._location.lower()): - $epLoc[len($show._location)+1:] - #elif $epLoc and (not $epLoc.lower().startswith($show._location.lower()) or not $show._location): - $epLoc - #end if - #end if + #elif len($sickbeard.DOWNLOAD_URL) > 0 + + #end if #if $sickbeard.USE_SUBTITLES and $show.subtitles: