diff --git a/gui/slick/views/config_providers.mako b/gui/slick/views/config_providers.mako index 6f76b287fd30317328464e8cb0319f8f92fd5d2e..9ae777244930abd0afe335fc702c0ba07b1f34c0 100644 --- a/gui/slick/views/config_providers.mako +++ b/gui/slick/views/config_providers.mako @@ -57,8 +57,8 @@ % endif <div> - <p class="note"><span class="red-text">*</span> ${_('Provider does not support backlog searches at this time.')}</p> - <p class="note"><span class="red-text">!</span> ${_('Provider is <b>NOT WORKING</b>.')}</p> + <p class="note"><span class="red-text">*</span> ${_('Provider does not support backlog or manual searches')}</p> + <p class="note"><span class="red-text">!</span> ${_('Provider does not support daily rss searches')}</p> </div> </div> </div> @@ -69,8 +69,6 @@ <ul id="provider_order_list"> % for curProvider in sickbeard.providers.sortedProviderList(): <% - ## These will show the '!' not saying they are broken - broken_providers = {'torrentproject', 'cpasbien'} if curProvider.provider_type == GenericProvider.NZB and not sickbeard.USE_NZBS: continue elif curProvider.provider_type == GenericProvider.TORRENT and not sickbeard.USE_TORRENTS: @@ -82,8 +80,8 @@ else: curURL = curProvider.url %> - <li class="ui-state-default ${('nzb-provider', 'torrent-provider')[bool(curProvider.provider_type == GenericProvider.TORRENT)]}" id="${curName}"> - <input type="checkbox" id="enable_${curName}" class="provider_enabler" ${('', 'checked="checked"')[curProvider.is_enabled() is True]}/> + <li class="ui-state-default ${('nzb-provider', 'torrent-provider')[curProvider.provider_type == GenericProvider.TORRENT]}" id="${curName}"> + <input type="checkbox" id="enable_${curName}" class="provider_enabler" ${('', 'checked="checked"')[curProvider.is_enabled]}/> <a href="${anon_url(curURL)}" class="imgLink" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;"> <img src="${static_url('images/providers/' + curProvider.image_name())}" @@ -91,16 +89,14 @@ height="16" style="vertical-align:middle;"/> </a> <label for="enable_${curName}" style="vertical-align:middle;">${curProvider.name}</label> - ${('<span class="red-text">*</span>', '')[bool(curProvider.supports_backlog)]} - ${('<span class="red-text">!</span>', '')[bool(curProvider.get_id() not in broken_providers)]} + ${('<span class="red-text">*</span>', '')[curProvider.can_backlog]} + ${('<span class="red-text">!</span>', '')[curProvider.can_daily]} <span class="ui-icon ui-icon-arrowthick-2-n-s pull-right" style="vertical-align:middle;"></span> - <span class="ui-icon ${('ui-icon-locked','ui-icon-unlocked')[bool(curProvider.public)]} pull-right" style="vertical-align:middle;"></span> + <span class="ui-icon ${('ui-icon-locked','ui-icon-unlocked')[curProvider.public]} pull-right" style="vertical-align:middle;"></span> </li> % endfor </ul> - - <input type="hidden" name="provider_order" id="provider_order" value="${" ".join([x.get_id()+':'+str(int(x.is_enabled())) for x in sickbeard.providers.sortedProviderList()])}"/> - + <input type="hidden" name="provider_order" id="provider_order" value="${" ".join([x.get_id(':'+str(int(x.is_enabled))) for x in sickbeard.providers.sortedProviderList()])}" /> </fieldset> </div> </div> @@ -128,9 +124,9 @@ <% provider_config_list = [] for curProvider in sickbeard.providers.sortedProviderList(): - if curProvider.provider_type == GenericProvider.NZB and (not sickbeard.USE_NZBS or not curProvider.is_enabled()): + if curProvider.provider_type == GenericProvider.NZB and not (sickbeard.USE_NZBS and curProvider.is_enabled): continue - elif curProvider.provider_type == GenericProvider.TORRENT and ( not sickbeard.USE_TORRENTS or not curProvider.is_enabled()): + elif curProvider.provider_type == GenericProvider.TORRENT and not (sickbeard.USE_TORRENTS and curProvider.is_enabled): continue provider_config_list.append(curProvider) %> @@ -149,7 +145,7 @@ <!-- start div for editing providers //--> % for curNewznabProvider in sickbeard.newznabProviderList: - <div class="providerDiv" id="${curNewznabProvider.get_id()}Div"> + <div class="providerDiv" id="${curNewznabProvider.get_id("Div")}"> % if curNewznabProvider.default and curNewznabProvider.needs_auth: <div class="field-pair row"> @@ -157,7 +153,7 @@ <label class="component-title">${_('URL')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" id="${curNewznabProvider.get_id()}_url" + <input type="text" id="${curNewznabProvider.get_id("_url")}" value="${curNewznabProvider.url}" class="form-control input-sm input350" disabled autocapitalize="off"/> </div> @@ -168,9 +164,9 @@ <label class="component-title">${_('API key')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" id="${curNewznabProvider.get_id()}_hash" + <input type="text" id="${curNewznabProvider.get_id("_hash")}" value="${curNewznabProvider.key}" - newznab_name="${curNewznabProvider.get_id()}_hash" + newznab_name="${curNewznabProvider.get_id("_hash")}" class="newznab_key form-control input-sm input350" autocapitalize="off"/> </div> </div> @@ -182,9 +178,13 @@ <label class="component-title">${_('Enable daily searches')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curNewznabProvider.get_id()}_enable_daily" - id="${curNewznabProvider.get_id()}_enable_daily" ${('', 'checked="checked"')[bool(curNewznabProvider.enable_daily)]}/> - <label for="${curNewznabProvider.get_id()}_enable_daily">${_('enable provider to perform daily searches.')}</label> + <input type="checkbox" name="${curNewznabProvider.get_id("_enable_daily")}" + id="${curNewznabProvider.get_id("_enable_daily")}" + ${('', 'checked="checked"')[curNewznabProvider.enable_daily]} + ${('disabled', '')[curNewznabProvider.can_daily]} + /> + <label for="${curNewznabProvider.get_id("_enable_daily")}">${_('enable provider to perform daily searches.')}</label> + ${('<span class="red-text"></span>'.format(_('Daily search is currently not working on this provider')), '')[curNewznabProvider.can_daily]} </div> </div> % endif @@ -195,9 +195,13 @@ <label class="component-title">${_('Enable backlog searches')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curNewznabProvider.get_id()}_enable_backlog" - id="${curNewznabProvider.get_id()}_enable_backlog" ${('', 'checked="checked"')[bool(curNewznabProvider.enable_backlog and curNewznabProvider.supports_backlog)]}/> - <label for="${curNewznabProvider.get_id()}_enable_backlog">${_('enable provider to perform backlog searches.')}</label> + <input type="checkbox" name="${curNewznabProvider.get_id("_enable_backlog")}" + id="${curNewznabProvider.get_id("_enable_backlog")}" + ${('', 'checked="checked"')[curNewznabProvider.enable_backlog and curNewznabProvider.can_backlog]} + ${('disabled', '')[curNewznabProvider.can_backlog]} + /> + <label for="${curNewznabProvider.get_id("_enable_backlog")}">${_('enable provider to perform backlog searches.')}</label> + ${('<span class="red-text"></span>'.format(_('Backlog search is currently not working on this provider')), '')[curNewznabProvider.can_backlog]} </div> </div> % endif @@ -215,18 +219,18 @@ </div> <div class="row"> <div class="col-md-12"> - <input type="radio" name="${curNewznabProvider.get_id()}_search_mode" - id="${curNewznabProvider.get_id()}_search_mode_sponly" + <input type="radio" name="${curNewznabProvider.get_id("_search_mode")}" + id="${curNewznabProvider.get_id("_search_mode_sponly")}" value="sponly" ${('', 'checked="checked"')[curNewznabProvider.search_mode=="sponly"]}/> - <label for="${curNewznabProvider.get_id()}_search_mode_sponly">${_('season packs only.')}</label> + <label for="${curNewznabProvider.get_id("_search_mode_sponly")}">${_('season packs only.')}</label> </div> </div> <div class="row"> <div class="col-md-12"> - <input type="radio" name="${curNewznabProvider.get_id()}_search_mode" - id="${curNewznabProvider.get_id()}_search_mode_eponly" + <input type="radio" name="${curNewznabProvider.get_id("_search_mode")}" + id="${curNewznabProvider.get_id("_search_mode_eponly")}" value="eponly" ${('', 'checked="checked"')[curNewznabProvider.search_mode=="eponly"]}/> - <label for="${curNewznabProvider.get_id()}_search_mode_eponly">${_('episodes only.')}</label> + <label for="${curNewznabProvider.get_id("_search_mode_eponly")}">${_('episodes only.')}</label> </div> </div> </div> @@ -239,9 +243,9 @@ <label class="component-title">${_('Enable fallback')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curNewznabProvider.get_id()}_search_fallback" - id="${curNewznabProvider.get_id()}_search_fallback" ${('', 'checked="checked"')[bool(curNewznabProvider.search_fallback)]}/> - <label for="${curNewznabProvider.get_id()}_search_fallback">${_('when searching for a complete season depending on search mode you may return no results, this helps by restarting the search using the opposite search mode.')}</label> + <input type="checkbox" name="${curNewznabProvider.get_id("_search_fallback")}" + id="${curNewznabProvider.get_id("_search_fallback")}" ${('', 'checked="checked"')[curNewznabProvider.search_fallback]}/> + <label for="${curNewznabProvider.get_id("_search_fallback")}">${_('when searching for a complete season depending on search mode you may return no results, this helps by restarting the search using the opposite search mode.')}</label> </div> </div> % endif @@ -250,14 +254,14 @@ % endfor % for curNzbProvider in [curProvider for curProvider in sickbeard.providers.sortedProviderList() if curProvider.provider_type == GenericProvider.NZB and curProvider not in sickbeard.newznabProviderList]: - <div class="providerDiv" id="${curNzbProvider.get_id()}Div"> + <div class="providerDiv" id="${curNzbProvider.get_id("Div")}"> % if hasattr(curNzbProvider, 'username'): <div class="field-pair row"> <div class="col-lg-3 col-md-4 col-sm-5 col-xs-12"> <label class="component-title">${_('Username')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curNzbProvider.get_id()}_username" + <input type="text" name="${curNzbProvider.get_id("_username")}" value="${curNzbProvider.username}" class="form-control input-sm input350" autocapitalize="off" autocomplete="no"/> </div> @@ -270,7 +274,7 @@ <label class="component-title">${_('API key')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curNzbProvider.get_id()}_api_key" + <input type="text" name="${curNzbProvider.get_id("_api_key")}" value="${curNzbProvider.api_key}" class="form-control input-sm input350" autocapitalize="off"/> </div> @@ -283,9 +287,13 @@ <label class="component-title">${_('Enable daily searches')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curNzbProvider.get_id()}_enable_daily" - id="${curNzbProvider.get_id()}_enable_daily" ${('', 'checked="checked"')[bool(curNzbProvider.enable_daily)]}/> - <label for="${curNzbProvider.get_id()}_enable_daily">${_('enable provider to perform daily searches.')}</label> + <input type="checkbox" name="${curNzbProvider.get_id("_enable_daily")}" + id="${curNzbProvider.get_id("_enable_daily")}" + ${('', 'checked="checked"')[curNzbProvider.enable_daily]} + ${('disabled', '')[curNzbProvider.can_daily]} + /> + <label for="${curNzbProvider.get_id("_enable_daily")}">${_('enable provider to perform daily searches.')}</label> + ${('<span class="red-text"></span>'.format(_('Daily search is currently not working on this provider')), '')[curNzbProvider.can_daily]} </div> </div> % endif @@ -296,9 +304,13 @@ <label class="component-title">${_('Enable backlog searches')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curNzbProvider.get_id()}_enable_backlog" - id="${curNzbProvider.get_id()}_enable_backlog" ${('', 'checked="checked"')[bool(curNzbProvider.enable_backlog and curNzbProvider.supports_backlog)]}/> - <label for="${curNzbProvider.get_id()}_enable_backlog">${_('enable provider to perform backlog searches.')}</label> + <input type="checkbox" name="${curNzbProvider.get_id("_enable_backlog")}" + id="${curNzbProvider.get_id("_enable_backlog")}" + ${('', ' checked="checked"')[curNzbProvider.enable_backlog and curNzbProvider.can_backlog]} + ${('disabled', ' ')[curNzbProvider.can_backlog]} + /> + <label for="${curNzbProvider.get_id("_enable_backlog")}">${_('enable provider to perform backlog searches.')}</label> + ${('<span class="red-text"></span>'.format(_('Backlog search is currently not working on this provider')), '')[curNzbProvider.can_backlog]} </div> </div> % endif @@ -316,18 +328,18 @@ </div> <div class="row"> <div class="col-md-12"> - <input type="radio" name="${curNzbProvider.get_id()}_search_mode" - id="${curNzbProvider.get_id()}_search_mode_sponly" + <input type="radio" name="${curNzbProvider.get_id("_search_mode")}" + id="${curNzbProvider.get_id("_search_mode_sponly")}" value="sponly" ${('', 'checked="checked"')[curNzbProvider.search_mode=="sponly"]}/> - <label for="${curNzbProvider.get_id()}_search_mode_sponly">season packs only.</label> + <label for="${curNzbProvider.get_id("_search_mode_sponly")}">season packs only.</label> </div> </div> <div class="row"> <div class="col-md-12"> - <input type="radio" name="${curNzbProvider.get_id()}_search_mode" - id="${curNzbProvider.get_id()}_search_mode_eponly" + <input type="radio" name="${curNzbProvider.get_id("_search_mode")}" + id="${curNzbProvider.get_id("_search_mode_eponly")}" value="eponly" ${('', 'checked="checked"')[curNzbProvider.search_mode=="eponly"]}/> - <label for="${curNzbProvider.get_id()}_search_mode_eponly">episodes only.</label> + <label for="${curNzbProvider.get_id("_search_mode_eponly")}">episodes only.</label> </div> </div> </div> @@ -340,9 +352,9 @@ <label class="component-title">${_('Enable fallback')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curNzbProvider.get_id()}_search_fallback" - id="${curNzbProvider.get_id()}_search_fallback" ${('', 'checked="checked"')[bool(curNzbProvider.search_fallback)]}/> - <label for="${curNzbProvider.get_id()}_search_fallback">${_('when searching for a complete season depending on search mode you may return no results, this helps by restarting the search using the opposite search mode.')}</label> + <input type="checkbox" name="${curNzbProvider.get_id("_search_fallback")}" + id="${curNzbProvider.get_id("_search_fallback")}" ${('', 'checked="checked"')[curNzbProvider.search_fallback]}/> + <label for="${curNzbProvider.get_id("_search_fallback")}">${_('when searching for a complete season depending on search mode you may return no results, this helps by restarting the search using the opposite search mode.')}</label> </div> </div> % endif @@ -351,7 +363,7 @@ % endfor % for curTorrentProvider in [curProvider for curProvider in sickbeard.providers.sortedProviderList() if curProvider.provider_type == GenericProvider.TORRENT]: - <div class="providerDiv" id="${curTorrentProvider.get_id()}Div"> + <div class="providerDiv" id="${curTorrentProvider.get_id("Div")}"> % if hasattr(curTorrentProvider, 'custom_url'): <div class="field-pair row"> @@ -359,11 +371,11 @@ <label class="component-title">${_('Custom URL')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curTorrentProvider.get_id()}_custom_url" - id="${curTorrentProvider.get_id()}_custom_url" + <input type="text" name="${curTorrentProvider.get_id("_custom_url")}" + id="${curTorrentProvider.get_id("_custom_url")}" value="${curTorrentProvider.custom_url}" class="form-control input-sm input350" autocapitalize="off"/> - <label for="${curTorrentProvider.get_id()}_custom_url">${_('the URL should include the protocol (and port if applicable). Examples: http://192.168.1.4/ or http://localhost:3000/')}</label> + <label for="${curTorrentProvider.get_id("_custom_url")}">${_('the URL should include the protocol (and port if applicable). Examples: http://192.168.1.4/ or http://localhost:3000/')}</label> </div> </div> % endif @@ -374,8 +386,8 @@ <label class="component-title">${_('Api key')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curTorrentProvider.get_id()}_api_key" - id="${curTorrentProvider.get_id()}_api_key" + <input type="text" name="${curTorrentProvider.get_id("_api_key")}" + id="${curTorrentProvider.get_id("_api_key")}" value="${curTorrentProvider.api_key}" class="form-control input-sm input350" autocapitalize="off"/> </div> @@ -388,8 +400,8 @@ <label class="component-title">${_('Digest')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curTorrentProvider.get_id()}_digest" - id="${curTorrentProvider.get_id()}_digest" + <input type="text" name="${curTorrentProvider.get_id("_digest")}" + id="${curTorrentProvider.get_id("_digest")}" value="${curTorrentProvider.digest}" class="form-control input-sm input350" autocapitalize="off"/> </div> @@ -402,8 +414,8 @@ <label class="component-title">${_('Hash')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curTorrentProvider.get_id()}_hash" - id="${curTorrentProvider.get_id()}_hash" value="${curTorrentProvider.hash}" + <input type="text" name="${curTorrentProvider.get_id("_hash")}" + id="${curTorrentProvider.get_id("_hash")}" value="${curTorrentProvider.hash}" class="form-control input-sm input350" autocapitalize="off"/> </div> </div> @@ -415,8 +427,8 @@ <label class="component-title">${_('Username')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="text" name="${curTorrentProvider.get_id()}_username" - id="${curTorrentProvider.get_id()}_username" + <input type="text" name="${curTorrentProvider.get_id("_username")}" + id="${curTorrentProvider.get_id("_username")}" value="${curTorrentProvider.username}" class="form-control input-sm input350" autocapitalize="off" autocomplete="no"/> </div> @@ -430,8 +442,8 @@ </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> <input - type="password" name="${curTorrentProvider.get_id()}_password" - id="${curTorrentProvider.get_id()}_password" value="${curTorrentProvider.password|hide}" + type="password" name="${curTorrentProvider.get_id("_password")}" + id="${curTorrentProvider.get_id("_password")}" value="${curTorrentProvider.password|hide}" class="form-control input-sm input350" autocomplete="no" autocapitalize="off" /> </div> @@ -445,7 +457,7 @@ </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> <input - type="text" name="${curTorrentProvider.get_id()}_passkey" id="${curTorrentProvider.get_id()}_passkey" + type="text" name="${curTorrentProvider.get_id("_passkey")}" id="${curTorrentProvider.get_id("_passkey")}" value="${curTorrentProvider.passkey|hide}" class="form-control input-sm input350" autocapitalize="off" /> </div> @@ -460,8 +472,8 @@ <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> <div class="row"> <div class="col-md-12"> - <input type="text" name="${curTorrentProvider.get_id()}_cookies" - id="${curTorrentProvider.get_id()}_cookies" + <input type="text" name="${curTorrentProvider.get_id("_cookies")}" + id="${curTorrentProvider.get_id("_cookies")}" value="${curTorrentProvider.cookies}" class="form-control input-sm input350" autocapitalize="off" autocomplete="no" /> @@ -469,7 +481,7 @@ </div> <div class="row"> <div class="col-md-12"> - <label for="${curTorrentProvider.get_id()}_cookies"> + <label for="${curTorrentProvider.get_id("_cookies")}"> ${_('example: uid=1234;pass=567845439634987<br>' + 'note: uid and pass are not your username/password.<br>' + 'use DevTools or Firebug to get these values after logging in on your browser.')} @@ -487,8 +499,8 @@ </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> <input - type="password" name="${curTorrentProvider.get_id()}_pin" - id="${curTorrentProvider.get_id()}_pin" value="${curTorrentProvider.pin|hide}" + type="password" name="${curTorrentProvider.get_id("_pin")}" + id="${curTorrentProvider.get_id("_pin")}" value="${curTorrentProvider.pin|hide}" class="form-control input-sm input100" autocomplete="no" autocapitalize="off" /> </div> @@ -498,19 +510,19 @@ % if hasattr(curTorrentProvider, 'ratio'): <div class="field-pair row"> <div class="col-lg-3 col-md-4 col-sm-5 col-xs-12"> - <label class="component-title" id="${curTorrentProvider.get_id()}_ratio_desc">${_('Seed ratio')}</label> + <label class="component-title" id="${curTorrentProvider.get_id("_ratio_desc")}">${_('Seed ratio')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> <div class="row"> <div class="col-md-12"> - <input type="number" min="-1" step="0.1" name="${curTorrentProvider.get_id()}_ratio" - id="${curTorrentProvider.get_id()}_ratio" value="${curTorrentProvider.ratio or ''}" + <input type="number" min="-1" step="0.1" name="${curTorrentProvider.get_id("_ratio")}" + id="${curTorrentProvider.get_id("_ratio")}" value="${curTorrentProvider.ratio}" class="form-control input-sm input75"/> </div> </div> <div class="row"> <div class="col-md-12"> - <label for="${curTorrentProvider.get_id()}_ratio">${_('stop transfer when ratio is reached<br>(-1 SickRage default to seed forever, or leave blank for downloader default)')}</label> + <label for="${curTorrentProvider.get_id("_ratio")}">${_('stop transfer when ratio is reached<br>(-1 SickRage default to seed forever, or leave blank for downloader default)')}</label> </div> </div> </div> @@ -520,11 +532,11 @@ % if hasattr(curTorrentProvider, 'minseed'): <div class="field-pair row"> <div class="col-lg-3 col-md-4 col-sm-5 col-xs-12"> - <label class="component-title" id="${curTorrentProvider.get_id()}_minseed_desc">${_('Minimum seeders')}</label> + <label class="component-title" id="${curTorrentProvider.get_id("_minseed_desc")}">${_('Minimum seeders')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="number" min="0" step="1" name="${curTorrentProvider.get_id()}_minseed" - id="${curTorrentProvider.get_id()}_minseed" + <input type="number" min="0" step="1" name="${curTorrentProvider.get_id("_minseed")}" + id="${curTorrentProvider.get_id("_minseed")}" value="${curTorrentProvider.minseed}" class="form-control input-sm input75"/> </div> </div> @@ -533,11 +545,11 @@ % if hasattr(curTorrentProvider, 'minleech'): <div class="field-pair row"> <div class="col-lg-3 col-md-4 col-sm-5 col-xs-12"> - <label class="component-title" id="${curTorrentProvider.get_id()}_minleech_desc">${_('Minimum leechers')}</label> + <label class="component-title" id="${curTorrentProvider.get_id("_minleech_desc")}">${_('Minimum leechers')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="number" min="0" step="1" name="${curTorrentProvider.get_id()}_minleech" - id="${curTorrentProvider.get_id()}_minleech" + <input type="number" min="0" step="1" name="${curTorrentProvider.get_id("_minleech")}" + id="${curTorrentProvider.get_id("_minleech")}" value="${curTorrentProvider.minleech}" class="form-control input-sm input75"/> </div> @@ -550,9 +562,9 @@ <label class="component-title">${_('Confirmed download')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_confirmed" - id="${curTorrentProvider.get_id()}_confirmed" ${('', 'checked="checked"')[bool(curTorrentProvider.confirmed)]}/> - <label for="${curTorrentProvider.get_id()}_confirmed">${_('only download torrents from trusted or verified uploaders ?')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_confirmed")}" + id="${curTorrentProvider.get_id("_confirmed")}" ${('', 'checked="checked"')[curTorrentProvider.confirmed]}/> + <label for="${curTorrentProvider.get_id("_confirmed")}">${_('only download torrents from trusted or verified uploaders ?')}</label> </div> </div> % endif @@ -563,9 +575,9 @@ <label class="component-title">${_('Ranked torrents')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_ranked" - id="${curTorrentProvider.get_id()}_ranked" ${('', 'checked="checked"')[bool(curTorrentProvider.ranked)]} /> - <label for="${curTorrentProvider.get_id()}_ranked">${_('only download ranked torrents (trusted releases)')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_ranked")}" + id="${curTorrentProvider.get_id("_ranked")}" ${('', 'checked="checked"')[curTorrentProvider.ranked]} /> + <label for="${curTorrentProvider.get_id("_ranked")}">${_('only download ranked torrents (trusted releases)')}</label> </div> </div> % endif @@ -576,9 +588,9 @@ <label class="component-title">${_('English torrents')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_engrelease" - id="${curTorrentProvider.get_id()}_engrelease" ${('', 'checked="checked"')[bool(curTorrentProvider.engrelease)]} /> - <label for="${curTorrentProvider.get_id()}_engrelease">${_('only download english torrents, or torrents containing english subtitles')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_engrelease")}" + id="${curTorrentProvider.get_id("_engrelease")}" ${('', 'checked="checked"')[curTorrentProvider.engrelease]} /> + <label for="${curTorrentProvider.get_id("_engrelease")}">${_('only download english torrents, or torrents containing english subtitles')}</label> </div> </div> % endif @@ -589,9 +601,9 @@ <label class="component-title">${_('For Spanish torrents')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_onlyspasearch" - id="${curTorrentProvider.get_id()}_onlyspasearch" ${('', 'checked="checked"')[bool(curTorrentProvider.onlyspasearch)]} /> - <label for="${curTorrentProvider.get_id()}_onlyspasearch">${_('ONLY search on this provider if show info is defined as "Spanish" (avoid provider\'s use for VOS shows)')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_onlyspasearch")}" + id="${curTorrentProvider.get_id("_onlyspasearch")}" ${('', 'checked="checked"')[curTorrentProvider.onlyspasearch]} /> + <label for="${curTorrentProvider.get_id("_onlyspasearch")}">${_('ONLY search on this provider if show info is defined as "Spanish" (avoid provider\'s use for VOS shows)')}</label> </div> </div> % endif @@ -602,7 +614,7 @@ <label class="component-title">${_('Sorting results by')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <select name="${curTorrentProvider.get_id()}_sorting" id="${curTorrentProvider.get_id()}_sorting" class="form-control input-sm input200"> + <select name="${curTorrentProvider.get_id("_sorting")}" id="${curTorrentProvider.get_id("_sorting")}" class="form-control input-sm input200"> % for curAction in ('last', 'seeders', 'leechers'): <option value="${curAction}" ${('', 'selected="selected"')[curAction == curTorrentProvider.sorting]}>${curAction}</option> % endfor @@ -617,9 +629,9 @@ <label class="component-title">${_('Freeleech')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_freeleech" - id="${curTorrentProvider.get_id()}_freeleech" ${('', 'checked="checked"')[bool(curTorrentProvider.freeleech)]}/> - <label for="${curTorrentProvider.get_id()}_freeleech">${_('only download <b>"FreeLeech"</b> torrents.')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_freeleech")}" + id="${curTorrentProvider.get_id("_freeleech")}" ${('', 'checked="checked"')[curTorrentProvider.freeleech]}/> + <label for="${curTorrentProvider.get_id("_freeleech")}">${_('only download <b>"FreeLeech"</b> torrents.')}</label> </div> </div> % endif @@ -630,9 +642,13 @@ <label class="component-title">${_('Enable daily searches')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_enable_daily" - id="${curTorrentProvider.get_id()}_enable_daily" ${('', 'checked="checked"')[bool(curTorrentProvider.enable_daily)]}/> - <label for="${curTorrentProvider.get_id()}_enable_daily">${_('enable provider to perform daily searches.')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_enable_daily")}" + id="${curTorrentProvider.get_id("_enable_daily")}" + ${('', 'checked="checked"')[curTorrentProvider.enable_daily]} + ${('disabled', ' ')[curTorrentProvider.can_daily]} + /> + <label for="${curTorrentProvider.get_id("_enable_daily")}">${_('enable provider to perform daily searches.')}</label> + ${('<span class="red-text"></span>'.format(_('Daily search is currently not working on this provider')), '')[curTorrentProvider.can_daily]} </div> </div> % endif @@ -643,9 +659,14 @@ <label class="component-title">${_('Enable backlog searches')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_enable_backlog" - id="${curTorrentProvider.get_id()}_enable_backlog" ${('', 'checked="checked"')[bool(curTorrentProvider.enable_backlog and curTorrentProvider.supports_backlog)]}/> - <label for="${curTorrentProvider.get_id()}_enable_backlog">${_('enable provider to perform backlog searches.')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_enable_backlog")}" + id="${curTorrentProvider.get_id("_enable_backlog")}" + ${('', 'checked="checked"')[curTorrentProvider.enable_backlog and curTorrentProvider.can_backlog]} + ${('disabled', '')[curTorrentProvider.can_backlog]} + /> + + <label for="${curTorrentProvider.get_id("_enable_backlog")}">${_('enable provider to perform backlog searches.')}</label> + ${('<span class="red-text"></span>'.format(_('Backlog search is currently not working on this provider')), '')[curTorrentProvider.can_backlog]} </div> </div> % endif @@ -663,18 +684,18 @@ </div> <div class="row"> <div class="col-md-12"> - <input type="radio" name="${curTorrentProvider.get_id()}_search_mode" - id="${curTorrentProvider.get_id()}_search_mode_sponly" + <input type="radio" name="${curTorrentProvider.get_id("_search_mode")}" + id="${curTorrentProvider.get_id("_search_mode_sponly")}" value="sponly" ${('', 'checked="checked"')[curTorrentProvider.search_mode=="sponly"]}/> - <label for="${curTorrentProvider.get_id()}_search_mode_sponly">season packs only.</label> + <label for="${curTorrentProvider.get_id("_search_mode_sponly")}">season packs only.</label> </div> </div> <div class="row"> <div class="col-md-12"> - <input type="radio" name="${curTorrentProvider.get_id()}_search_mode" - id="${curTorrentProvider.get_id()}_search_mode_eponly" + <input type="radio" name="${curTorrentProvider.get_id("_search_mode")}" + id="${curTorrentProvider.get_id("_search_mode_eponly")}" value="eponly" ${('', 'checked="checked"')[curTorrentProvider.search_mode=="eponly"]}/> - <label for="${curTorrentProvider.get_id()}_search_mode_eponly">episodes only.</label> + <label for="${curTorrentProvider.get_id("_search_mode_eponly")}">episodes only.</label> </div> </div> </div> @@ -687,9 +708,9 @@ <label class="component-title">${_('Enable fallback')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_search_fallback" - id="${curTorrentProvider.get_id()}_search_fallback" ${('', 'checked="checked"')[bool(curTorrentProvider.search_fallback)]}/> - <label for="${curTorrentProvider.get_id()}_search_fallback">${_('when searching for a complete season depending on search mode you may return no results, this helps by restarting the search using the opposite search mode.')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_search_fallback")}" + id="${curTorrentProvider.get_id("_search_fallback")}" ${('', 'checked="checked"')[curTorrentProvider.search_fallback]}/> + <label for="${curTorrentProvider.get_id("_search_fallback")}">${_('when searching for a complete season depending on search mode you may return no results, this helps by restarting the search using the opposite search mode.')}</label> </div> </div> % endif @@ -700,8 +721,8 @@ <label class="component-title">${_('Category')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <select name="${curTorrentProvider.get_id()}_cat" - id="${curTorrentProvider.get_id()}_cat" class="form-control input-sm input200"> + <select name="${curTorrentProvider.get_id("_cat")}" + id="${curTorrentProvider.get_id("_cat")}" class="form-control input-sm input200"> % for i in curTorrentProvider.category_dict.keys(): <option value="${curTorrentProvider.category_dict[i]}" ${('', 'selected="selected"')[curTorrentProvider.category_dict[i] == curTorrentProvider.cat]}>${i}</option> % endfor @@ -716,9 +737,9 @@ <label class="component-title">${_('Subtitled')}</label> </div> <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc"> - <input type="checkbox" name="${curTorrentProvider.get_id()}_subtitle" - id="${curTorrentProvider.get_id()}_subtitle" ${('', 'checked="checked"')[bool(curTorrentProvider.subtitle)]}/> - <label for="${curTorrentProvider.get_id()}_subtitle">${_('select torrent with Italian subtitle')}</label> + <input type="checkbox" name="${curTorrentProvider.get_id("_subtitle")}" + id="${curTorrentProvider.get_id("_subtitle")}" ${('', 'checked="checked"')[curTorrentProvider.subtitle]}/> + <label for="${curTorrentProvider.get_id("_subtitle")}">${_('select torrent with Italian subtitle')}</label> </div> </div> % endif diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 038914986feab1e0ff7b1d092a56f41c65bfd258..529af1f756bf2ccdfe7762ae06c082d784ffdd49 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -976,8 +976,8 @@ def initialize(consoleLogging=True): # pylint: disable=too-many-locals, too-man NAMING_FORCE_FOLDERS = naming.check_force_season_folders() NAMING_STRIP_YEAR = check_setting_bool(CFG, 'General', 'naming_strip_year') - USE_NZBS = check_setting_bool(CFG, 'General', 'use_nzbs') - USE_TORRENTS = check_setting_bool(CFG, 'General', 'use_torrents', True) + USE_NZBS = check_setting_bool(CFG, 'General', 'use_nzbs', USE_NZBS) + USE_TORRENTS = check_setting_bool(CFG, 'General', 'use_torrents', USE_TORRENTS) NZB_METHOD = check_setting_str(CFG, 'General', 'nzb_method', 'blackhole') if NZB_METHOD not in ('blackhole', 'sabnzbd', 'nzbget', 'download_station'): @@ -1407,130 +1407,62 @@ def initialize(consoleLogging=True): # pylint: disable=too-many-locals, too-man torrentRssProviderList = TorrentRssProvider.providers_list(TORRENTRSS_DATA) # dynamically load provider settings - for curTorrentProvider in [curProvider for curProvider in providers.sortedProviderList() if - curProvider.provider_type == GenericProvider.TORRENT]: - curTorrentProvider.enabled = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id()) - if hasattr(curTorrentProvider, 'custom_url'): - curTorrentProvider.custom_url = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_custom_url', - '', censor_log=True) - if hasattr(curTorrentProvider, 'api_key'): - curTorrentProvider.api_key = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_api_key', censor_log=True) - if hasattr(curTorrentProvider, 'hash'): - curTorrentProvider.hash = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_hash', censor_log=True) - if hasattr(curTorrentProvider, 'digest'): - curTorrentProvider.digest = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_digest', censor_log=True) - if hasattr(curTorrentProvider, 'username'): - curTorrentProvider.username = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_username', censor_log=True) - if hasattr(curTorrentProvider, 'password'): - curTorrentProvider.password = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_password', censor_log=True) - if hasattr(curTorrentProvider, 'passkey'): - curTorrentProvider.passkey = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_passkey', censor_log=True) - if hasattr(curTorrentProvider, 'pin'): - curTorrentProvider.pin = check_setting_str(CFG, curTorrentProvider.get_id().upper(), - curTorrentProvider.get_id() + '_pin', censor_log=True) - if hasattr(curTorrentProvider, 'confirmed'): - curTorrentProvider.confirmed = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_confirmed', True) - - if hasattr(curTorrentProvider, 'ranked'): - curTorrentProvider.ranked = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_ranked', True) - - if hasattr(curTorrentProvider, 'engrelease'): - curTorrentProvider.engrelease = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_engrelease') - - if hasattr(curTorrentProvider, 'onlyspasearch'): - curTorrentProvider.onlyspasearch = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_onlyspasearch') - - if hasattr(curTorrentProvider, 'sorting'): - curTorrentProvider.sorting = check_setting_str( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_sorting', 'seeders' - ) - - if hasattr(curTorrentProvider, 'options'): - curTorrentProvider.options = check_setting_str( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_options', '' - ) - - if hasattr(curTorrentProvider, 'ratio'): - curTorrentProvider.ratio = check_setting_str( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_ratio', '' - ) - - if hasattr(curTorrentProvider, 'minseed'): - curTorrentProvider.minseed = check_setting_int( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_minseed', 1, min_val=0 - ) - - if hasattr(curTorrentProvider, 'minleech'): - curTorrentProvider.minleech = check_setting_int( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_minleech', 0, min_val=0 - ) - - if hasattr(curTorrentProvider, 'freeleech'): - curTorrentProvider.freeleech = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_freeleech') - - if hasattr(curTorrentProvider, 'search_mode'): - curTorrentProvider.search_mode = check_setting_str( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_search_mode', 'eponly' - ) - - if hasattr(curTorrentProvider, 'search_fallback'): - curTorrentProvider.search_fallback = check_setting_bool( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_search_fallback' - ) - - if hasattr(curTorrentProvider, 'enable_daily'): - curTorrentProvider.enable_daily = check_setting_bool( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_enable_daily', True - ) - - if hasattr(curTorrentProvider, 'enable_backlog'): - curTorrentProvider.enable_backlog = check_setting_bool( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_enable_backlog', curTorrentProvider.supports_backlog - ) - - if hasattr(curTorrentProvider, 'cat'): - curTorrentProvider.cat = check_setting_int( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_cat', 0 - ) - - if hasattr(curTorrentProvider, 'subtitle'): - curTorrentProvider.subtitle = check_setting_bool(CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_subtitle') - - if hasattr(curTorrentProvider, 'cookies'): - curTorrentProvider.cookies = check_setting_str( - CFG, curTorrentProvider.get_id().upper(), curTorrentProvider.get_id() + '_cookies', censor_log=True - ) - - for curNzbProvider in [curProvider for curProvider in providers.sortedProviderList() if - curProvider.provider_type == GenericProvider.NZB]: - curNzbProvider.enabled = check_setting_bool(CFG, curNzbProvider.get_id().upper(), curNzbProvider.get_id()) - - if hasattr(curNzbProvider, 'api_key'): - curNzbProvider.api_key = check_setting_str(CFG, curNzbProvider.get_id().upper(), - curNzbProvider.get_id() + '_api_key', censor_log=True) - - if hasattr(curNzbProvider, 'username'): - curNzbProvider.username = check_setting_str(CFG, curNzbProvider.get_id().upper(), curNzbProvider.get_id() + '_username', censor_log=True) - if hasattr(curNzbProvider, 'search_mode'): - curNzbProvider.search_mode = check_setting_str(CFG, curNzbProvider.get_id().upper(), curNzbProvider.get_id() + '_search_mode', 'eponly') - - if hasattr(curNzbProvider, 'search_fallback'): - curNzbProvider.search_fallback = check_setting_bool(CFG, curNzbProvider.get_id().upper(), curNzbProvider.get_id() + '_search_fallback') - - if hasattr(curNzbProvider, 'enable_daily'): - curNzbProvider.enable_daily = check_setting_bool(CFG, curNzbProvider.get_id().upper(), curNzbProvider.get_id() + '_enable_daily', True) - - if hasattr(curNzbProvider, 'enable_backlog'): - curNzbProvider.enable_backlog = check_setting_bool( - CFG, curNzbProvider.get_id().upper(), curNzbProvider.get_id() + '_enable_backlog', curNzbProvider.supports_backlog + for curProvider in providers.sortedProviderList(): + curProvider.enabled = (curProvider.can_daily or curProvider.can_backlog) and \ + check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id()) + if hasattr(curProvider, 'custom_url'): + curProvider.custom_url = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_custom_url'), '', censor_log=True) + if hasattr(curProvider, 'api_key'): + curProvider.api_key = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_api_key'), censor_log=True) + if hasattr(curProvider, 'hash'): + curProvider.hash = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_hash'), censor_log=True) + if hasattr(curProvider, 'digest'): + curProvider.digest = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_digest'), censor_log=True) + if hasattr(curProvider, 'username'): + curProvider.username = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_username'), censor_log=True) + if hasattr(curProvider, 'password'): + curProvider.password = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_password'), censor_log=True) + if hasattr(curProvider, 'passkey'): + curProvider.passkey = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_passkey'), censor_log=True) + if hasattr(curProvider, 'pin'): + curProvider.pin = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_pin'), censor_log=True) + if hasattr(curProvider, 'confirmed'): + curProvider.confirmed = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_confirmed'), True) + if hasattr(curProvider, 'ranked'): + curProvider.ranked = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_ranked'), True) + if hasattr(curProvider, 'engrelease'): + curProvider.engrelease = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_engrelease')) + if hasattr(curProvider, 'onlyspasearch'): + curProvider.onlyspasearch = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_onlyspasearch')) + if hasattr(curProvider, 'sorting'): + curProvider.sorting = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_sorting'), 'seeders') + if hasattr(curProvider, 'options'): + curProvider.options = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_options'), '') + if hasattr(curProvider, 'ratio'): + curProvider.ratio = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_ratio'), '') + if hasattr(curProvider, 'minseed'): + curProvider.minseed = check_setting_int(CFG, curProvider.get_id().upper(), curProvider.get_id('_minseed'), 1, min_val=0) + if hasattr(curProvider, 'minleech'): + curProvider.minleech = check_setting_int(CFG, curProvider.get_id().upper(), curProvider.get_id('_minleech'), 0, min_val=0) + if hasattr(curProvider, 'freeleech'): + curProvider.freeleech = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_freeleech')) + if hasattr(curProvider, 'search_mode'): + curProvider.search_mode = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_search_mode'), 'eponly') + if hasattr(curProvider, 'search_fallback'): + curProvider.search_fallback = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_search_fallback')) + if hasattr(curProvider, 'enable_daily'): + curProvider.enable_daily = curProvider.can_daily and check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id( + '_enable_daily'), True) + if hasattr(curProvider, 'enable_backlog'): + curProvider.enable_backlog = curProvider.can_backlog and check_setting_bool( + CFG, curProvider.get_id().upper(), curProvider.get_id('_enable_backlog'), curProvider.can_backlog ) + if hasattr(curProvider, 'cat'): + curProvider.cat = check_setting_int(CFG, curProvider.get_id().upper(), curProvider.get_id('_cat'), 0) + if hasattr(curProvider, 'subtitle'): + curProvider.subtitle = check_setting_bool(CFG, curProvider.get_id().upper(), curProvider.get_id('_subtitle')) + if hasattr(curProvider, 'cookies'): + curProvider.cookies = check_setting_str(CFG, curProvider.get_id().upper(), curProvider.get_id('_cookies'), censor_log=True) providers.check_enabled_providers() @@ -1791,108 +1723,59 @@ def save_config(): # pylint: disable=too-many-statements, too-many-branches # For passwords you must include the word `password` in the item_name and add `helpers.encrypt(ITEM_NAME, ENCRYPTION_VERSION)` in save_config() # dynamically save provider settings - for curTorrentProvider in [curProvider for curProvider in providers.sortedProviderList() if - curProvider.provider_type == GenericProvider.TORRENT]: - new_config[curTorrentProvider.get_id().upper()] = {} - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id()] = int(curTorrentProvider.enabled) - if hasattr(curTorrentProvider, 'custom_url'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_custom_url'] = curTorrentProvider.custom_url - if hasattr(curTorrentProvider, 'digest'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_digest'] = curTorrentProvider.digest - if hasattr(curTorrentProvider, 'hash'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_hash'] = curTorrentProvider.hash - if hasattr(curTorrentProvider, 'api_key'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_api_key'] = curTorrentProvider.api_key - if hasattr(curTorrentProvider, 'username'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_username'] = curTorrentProvider.username - if hasattr(curTorrentProvider, 'password'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_password'] = helpers.encrypt( - curTorrentProvider.password, ENCRYPTION_VERSION) - if hasattr(curTorrentProvider, 'passkey'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_passkey'] = curTorrentProvider.passkey - if hasattr(curTorrentProvider, 'pin'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_pin'] = curTorrentProvider.pin - if hasattr(curTorrentProvider, 'confirmed'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_confirmed'] = int( - curTorrentProvider.confirmed) - if hasattr(curTorrentProvider, 'ranked'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_ranked'] = int( - curTorrentProvider.ranked) - if hasattr(curTorrentProvider, 'engrelease'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_engrelease'] = int( - curTorrentProvider.engrelease) - if hasattr(curTorrentProvider, 'onlyspasearch'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_onlyspasearch'] = int( - curTorrentProvider.onlyspasearch) - if hasattr(curTorrentProvider, 'sorting'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_sorting'] = curTorrentProvider.sorting - if hasattr(curTorrentProvider, 'ratio'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_ratio'] = curTorrentProvider.ratio - if hasattr(curTorrentProvider, 'minseed'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_minseed'] = int( - curTorrentProvider.minseed) - if hasattr(curTorrentProvider, 'minleech'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_minleech'] = int( - curTorrentProvider.minleech) - if hasattr(curTorrentProvider, 'options'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_options'] = curTorrentProvider.options - if hasattr(curTorrentProvider, 'freeleech'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_freeleech'] = int( - curTorrentProvider.freeleech) - if hasattr(curTorrentProvider, 'search_mode'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_search_mode'] = curTorrentProvider.search_mode - if hasattr(curTorrentProvider, 'search_fallback'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_search_fallback'] = int( - curTorrentProvider.search_fallback) - if hasattr(curTorrentProvider, 'enable_daily'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_enable_daily'] = int( - curTorrentProvider.enable_daily) - if hasattr(curTorrentProvider, 'enable_backlog'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_enable_backlog'] = int( - curTorrentProvider.enable_backlog) - if hasattr(curTorrentProvider, 'cat'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_cat'] = int( - curTorrentProvider.cat) - if hasattr(curTorrentProvider, 'subtitle'): - new_config[curTorrentProvider.get_id().upper()][curTorrentProvider.get_id() + '_subtitle'] = int( - curTorrentProvider.subtitle) - if hasattr(curTorrentProvider, 'cookies'): - new_config[curTorrentProvider.get_id().upper()][ - curTorrentProvider.get_id() + '_cookies'] = curTorrentProvider.cookies - - for curNzbProvider in [curProvider for curProvider in providers.sortedProviderList() if - curProvider.provider_type == GenericProvider.NZB]: - new_config[curNzbProvider.get_id().upper()] = {} - new_config[curNzbProvider.get_id().upper()][curNzbProvider.get_id()] = int(curNzbProvider.enabled) - - if hasattr(curNzbProvider, 'api_key'): - new_config[curNzbProvider.get_id().upper()][ - curNzbProvider.get_id() + '_api_key'] = curNzbProvider.api_key - if hasattr(curNzbProvider, 'username'): - new_config[curNzbProvider.get_id().upper()][ - curNzbProvider.get_id() + '_username'] = curNzbProvider.username - if hasattr(curNzbProvider, 'search_mode'): - new_config[curNzbProvider.get_id().upper()][ - curNzbProvider.get_id() + '_search_mode'] = curNzbProvider.search_mode - if hasattr(curNzbProvider, 'search_fallback'): - new_config[curNzbProvider.get_id().upper()][curNzbProvider.get_id() + '_search_fallback'] = int( - curNzbProvider.search_fallback) - if hasattr(curNzbProvider, 'enable_daily'): - new_config[curNzbProvider.get_id().upper()][curNzbProvider.get_id() + '_enable_daily'] = int( - curNzbProvider.enable_daily) - if hasattr(curNzbProvider, 'enable_backlog'): - new_config[curNzbProvider.get_id().upper()][curNzbProvider.get_id() + '_enable_backlog'] = int( - curNzbProvider.enable_backlog) + for curProvider in providers.sortedProviderList(): + new_config[curProvider.get_id().upper()] = {} + new_config[curProvider.get_id().upper()][curProvider.get_id()] = int(curProvider.enabled) + if hasattr(curProvider, 'custom_url'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_custom_url')] = curProvider.custom_url + if hasattr(curProvider, 'digest'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_digest')] = curProvider.digest + if hasattr(curProvider, 'hash'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_hash')] = curProvider.hash + if hasattr(curProvider, 'api_key'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_api_key')] = curProvider.api_key + if hasattr(curProvider, 'username'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_username')] = curProvider.username + if hasattr(curProvider, 'password'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_password')] = helpers.encrypt(curProvider.password, ENCRYPTION_VERSION) + if hasattr(curProvider, 'passkey'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_passkey')] = curProvider.passkey + if hasattr(curProvider, 'pin'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_pin')] = curProvider.pin + if hasattr(curProvider, 'confirmed'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_confirmed')] = int(curProvider.confirmed) + if hasattr(curProvider, 'ranked'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_ranked')] = int(curProvider.ranked) + if hasattr(curProvider, 'engrelease'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_engrelease')] = int(curProvider.engrelease) + if hasattr(curProvider, 'onlyspasearch'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_onlyspasearch')] = int(curProvider.onlyspasearch) + if hasattr(curProvider, 'sorting'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_sorting')] = curProvider.sorting + if hasattr(curProvider, 'ratio'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_ratio')] = curProvider.ratio + if hasattr(curProvider, 'minseed'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_minseed')] = int(curProvider.minseed) + if hasattr(curProvider, 'minleech'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_minleech')] = int(curProvider.minleech) + if hasattr(curProvider, 'options'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_options')] = curProvider.options + if hasattr(curProvider, 'freeleech'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_freeleech')] = int(curProvider.freeleech) + if hasattr(curProvider, 'search_mode'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_search_mode')] = curProvider.search_mode + if hasattr(curProvider, 'search_fallback'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_search_fallback')] = int(curProvider.search_fallback) + if hasattr(curProvider, 'enable_daily'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_enable_daily')] = int(curProvider.enable_daily and curProvider.can_daily) + if hasattr(curProvider, 'enable_backlog'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_enable_backlog')] = int(curProvider.enable_backlog and curProvider.can_backlog) + if hasattr(curProvider, 'cat'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_cat')] = int(curProvider.cat) + if hasattr(curProvider, 'subtitle'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_subtitle')] = int(curProvider.subtitle) + if hasattr(curProvider, 'cookies'): + new_config[curProvider.get_id().upper()][curProvider.get_id('_cookies')] = curProvider.cookies new_config.update({ 'General': { diff --git a/sickbeard/config.py b/sickbeard/config.py index d3327687c8b96c1e31f19920e3b05f8a3f75fa72..935d72507713363a78cbc92247700374ab8fac89 100644 --- a/sickbeard/config.py +++ b/sickbeard/config.py @@ -29,6 +29,7 @@ import rarfile import six # noinspection PyUnresolvedReferences from six.moves.urllib import parse +from tornado.escape import xhtml_unescape import sickbeard from sickbeard import db, helpers, logger, naming @@ -654,14 +655,12 @@ def clean_url(url): """ if url and url.strip(): - - url = url.strip() + url = xhtml_unescape(url.strip()) if '://' not in url: url = '//' + url scheme, netloc, path, query, fragment = parse.urlsplit(url, 'http') - if not path: path += '/' diff --git a/sickbeard/properFinder.py b/sickbeard/properFinder.py index be97e993afb972872caa52268d4e8c96c2d03702..446f006226c826e0f75cfdc5f76fa3e1debc43f7 100644 --- a/sickbeard/properFinder.py +++ b/sickbeard/properFinder.py @@ -79,7 +79,7 @@ class ProperFinder(object): # pylint: disable=too-few-public-methods # for each provider get a list of the origThreadName = threading.currentThread().name - providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active()] + providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active] for curProvider in providers: threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]" diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py index 1f39060806775959d10ddab947dd57707102ecbd..273d80689840898053d064444a658031c21a7dc6 100644 --- a/sickbeard/providers/__init__.py +++ b/sickbeard/providers/__init__.py @@ -53,7 +53,7 @@ def sortedProviderList(randomize=False): # add all enabled providers first for curModule in providerDict: - if providerDict[curModule] not in newList and providerDict[curModule].is_enabled(): + if providerDict[curModule] not in newList and providerDict[curModule].is_enabled: newList.append(providerDict[curModule]) # add any modules that are missing from that list @@ -95,11 +95,11 @@ def check_enabled_providers(): if not sickbeard.DEVELOPER: backlog_enabled, daily_enabled = False, False for provider in sortedProviderList(): - if provider.is_active(): - if provider.enable_daily: + if provider.is_active: + if provider.enable_daily and provider.can_daily: daily_enabled = True - if provider.enable_backlog: + if provider.enable_backlog and provider.can_backlog: backlog_enabled = True if backlog_enabled and daily_enabled: diff --git a/sickbeard/providers/binsearch.py b/sickbeard/providers/binsearch.py index 38b436bb359bee053d58c4ef197dc23b340b2fc0..3b9cc8a3bf2af9f41983e70f5641e4a934444448 100644 --- a/sickbeard/providers/binsearch.py +++ b/sickbeard/providers/binsearch.py @@ -39,6 +39,7 @@ class BinSearchProvider(NZBProvider): self.public = True self.supports_backlog = False + self.ability_status = self.PROVIDER_BROKEN self.cache = BinSearchCache(self, min_time=30) # only poll Binsearch every 30 minutes max diff --git a/sickbeard/providers/cpasbien.py b/sickbeard/providers/cpasbien.py index 8a756eb50bd39b2da721fc617e8ff1fb58ac1494..4bed1de5a880bc713904a6ccb36f3b7bc6c90ad6 100644 --- a/sickbeard/providers/cpasbien.py +++ b/sickbeard/providers/cpasbien.py @@ -41,6 +41,7 @@ class CpasbienProvider(TorrentProvider): self.proper_strings = ['PROPER', 'REPACK'] self.cache = tvcache.TVCache(self) + self.ability_status = self.PROVIDER_BACKLOG def search(self, search_strings, age=0, ep_obj=None): # pylint: disable=too-many-locals results = [] diff --git a/sickbeard/providers/hdtorrents_it.py b/sickbeard/providers/hdtorrents_it.py index 9de585f1141e8607c6917d1226e7b249e1f5d7e8..b078db1476552ac30a9fc455edf900d186a9646f 100644 --- a/sickbeard/providers/hdtorrents_it.py +++ b/sickbeard/providers/hdtorrents_it.py @@ -187,7 +187,5 @@ class HDTorrentsProvider_IT(TorrentProvider): # pylint: disable=too-many-instan return results - def seed_ratio(self): - return self.ratio provider = HDTorrentsProvider_IT() diff --git a/sickbeard/providers/torrentproject.py b/sickbeard/providers/torrentproject.py index a598c9f41ebfd5e111506c12b168c96dd2883d30..d9432febabb6492ab1772cb3fd108de7ac4dff99 100644 --- a/sickbeard/providers/torrentproject.py +++ b/sickbeard/providers/torrentproject.py @@ -46,6 +46,7 @@ class TorrentProjectProvider(TorrentProvider): # pylint: disable=too-many-insta self.custom_url = None + self.ability_status = self.PROVIDER_BACKLOG # Proper Strings # Cache diff --git a/sickbeard/search.py b/sickbeard/search.py index e75efa4e3a340adcd5401c2c6aeff530a1ad1a89..f10f243de8c1836f04c30966216d8f75c09846ac 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -371,14 +371,13 @@ def searchForNeededEpisodes(): origThreadName = threading.currentThread().name - providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active() and x.enable_daily] + providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active and x.enable_daily and x.can_daily] for curProvider in providers: threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]" curProvider.cache.update_cache() for curProvider in providers: threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]" - curFoundResults = {} try: curFoundResults = curProvider.search_rss(episodes) except AuthException as e: @@ -440,7 +439,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False): origThreadName = threading.currentThread().name - providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active() and x.enable_backlog] + providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active and x.can_backlog and x.enable_backlog] for curProvider in providers: threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]" curProvider.cache.update_cache() diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index dbea9b9c3cdf55798210a412cbac56fa23144a88..6e60df4d99b6eb68f05c2cd0947ec2eaf9789da2 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -88,7 +88,7 @@ from sickrage.system.Shutdown import Shutdown try: import json except ImportError: - # noinspection PyPackageRequirements + # noinspection PyPackageRequirements,PyUnresolvedReferences import simplejson as json @@ -156,6 +156,7 @@ class PageTemplate(MakoTemplate): kwargs[key] = self.arguments[key] kwargs['makoStartTime'] = time.time() + # noinspection PyBroadException try: return self.template.render_unicode(*args, **kwargs) except Exception: @@ -277,12 +278,12 @@ class WebHandler(BaseHandler): for arg, value in six.iteritems(kwargs): if len(value) == 1: kwargs[arg] = xhtml_escape(value[0]) - elif isinstance(value, basestring): + elif isinstance(value, six.string_types): kwargs[arg] = xhtml_escape(value) elif isinstance(value, list): kwargs[arg] = [xhtml_escape(v) for v in value] else: - raise + raise Exception result = function(**kwargs) return result @@ -330,6 +331,7 @@ class KeyHandler(RequestHandler): super(KeyHandler, self).__init__(*args, **kwargs) def get(self, *args, **kwargs): + # noinspection PyBroadException try: if self.get_argument('u', '') != sickbeard.WEB_USERNAME or self.get_argument('p', '') != sickbeard.WEB_PASSWORD: raise Exception @@ -2228,6 +2230,7 @@ class Home(WebRoot): continue if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): + # noinspection PyTypeChecker if not [x for x in episodes if x['episodeindexid'] == searchThread.segment.indexerid]: episodes += getEpisodes(searchThread, searchstatus) else: @@ -2259,6 +2262,7 @@ class Home(WebRoot): if error_msg or not ep_obj: return json.dumps({'result': 'failure', 'errorMessage': error_msg}) + # noinspection PyBroadException try: new_subtitles = ep_obj.download_subtitles() # pylint: disable=no-member except Exception: @@ -2425,6 +2429,7 @@ class HomeNews(Home): super(HomeNews, self).__init__(*args, **kwargs) def index(self, *args_, **kwargs_): + # noinspection PyBroadException try: news = sickbeard.versionCheckScheduler.action.check_for_new_news() except Exception: @@ -2447,6 +2452,7 @@ class HomeChangeLog(Home): super(HomeChangeLog, self).__init__(*args, **kwargs) def index(self, *args_, **kwargs_): + # noinspection PyBroadException try: changes = helpers.getURL('http://sickrage.github.io/sickrage-news/CHANGES.md', session=helpers.make_session(), returns='text') except Exception: @@ -2547,6 +2553,7 @@ class HomeAddShows(Home): logger.log("Searching for Show with searchterm(s): {0} on Indexer: {1}".format( searchTerms, sickbeard.indexerApi(indexer).name), logger.DEBUG) for searchTerm in searchTerms: + # noinspection PyBroadException try: indexerResults = t[searchTerm] except Exception: @@ -2590,12 +2597,14 @@ class HomeAddShows(Home): main_db_con = db.DBConnection() for root_dir in root_dirs: + # noinspection PyBroadException try: file_list = ek(os.listdir, root_dir) except Exception: continue for cur_file in file_list: + # noinspection PyBroadException try: cur_path = ek(os.path.normpath, ek(os.path.join, root_dir, cur_file)) if not ek(os.path.isdir, cur_path): @@ -3775,6 +3784,7 @@ class History(WebRoot): 'time': row[b'date'] } + # noinspection PyTypeChecker if not any((history[b'show_id'] == row[b'show_id'] and history[b'season'] == row[b'season'] and history[b'episode'] == row[b'episode'] and @@ -4601,6 +4611,7 @@ class ConfigProviders(Config): if not name: return json.dumps({'error': 'Invalid name specified'}) + url = config.clean_url(url) tempProvider = rsstorrent.TorrentRssProvider(name, url, cookies, titleTAG) if tempProvider.get_id() in (x.get_id() for x in sickbeard.torrentRssProviderList): @@ -4737,204 +4748,86 @@ class ConfigProviders(Config): torrentRssProviderDict[cur_id].enabled = cur_enabled # dynamically load provider settings - for curTorrentProvider in [prov for prov in sickbeard.providers.sortedProviderList() if - prov.provider_type == GenericProvider.TORRENT]: + for curProvider in sickbeard.providers.sortedProviderList(): + if hasattr(curProvider, 'custom_url'): + curProvider.custom_url = str(kwargs.get(curProvider.get_id('_custom_url'), '')).strip() + + if hasattr(curProvider, 'minseed'): + curProvider.minseed = int(str(kwargs.get(curProvider.get_id('_minseed'), 0)).strip()) + + if hasattr(curProvider, 'minleech'): + curProvider.minleech = int(str(kwargs.get(curProvider.get_id('_minleech'), 0)).strip()) + + if hasattr(curProvider, 'ratio'): + if curProvider.get_id('_ratio') in kwargs: + ratio = str(kwargs.get(curProvider.get_id('_ratio'))).strip() + print (ratio) + if ratio in ('None', None, ''): + curProvider.ratio = None + else: + curProvider.ratio = max(float(ratio), -1) + else: + curProvider.ratio = None - if hasattr(curTorrentProvider, 'custom_url'): - try: - curTorrentProvider.custom_url = str(kwargs[curTorrentProvider.get_id() + '_custom_url']).strip() - except Exception: - curTorrentProvider.custom_url = None + if hasattr(curProvider, 'digest'): + curProvider.digest = str(kwargs.get(curProvider.get_id('_digest'), '')).strip() or None - if hasattr(curTorrentProvider, 'minseed'): - try: - curTorrentProvider.minseed = int(str(kwargs[curTorrentProvider.get_id() + '_minseed']).strip()) - except Exception: - curTorrentProvider.minseed = 0 + if hasattr(curProvider, 'hash'): + curProvider.hash = str(kwargs.get(curProvider.get_id('_hash'), '')).strip() or None - if hasattr(curTorrentProvider, 'minleech'): - try: - curTorrentProvider.minleech = int(str(kwargs[curTorrentProvider.get_id() + '_minleech']).strip()) - except Exception: - curTorrentProvider.minleech = 0 + if hasattr(curProvider, 'api_key'): + curProvider.api_key = str(kwargs.get(curProvider.get_id('_api_key'), '')).strip() or None - if hasattr(curTorrentProvider, 'ratio'): - try: - ratio = float(str(kwargs[curTorrentProvider.get_id() + '_ratio']).strip()) - curTorrentProvider.ratio = (ratio, -1)[ratio < 0] - except Exception: - curTorrentProvider.ratio = None + if hasattr(curProvider, 'username'): + curProvider.username = str(kwargs.get(curProvider.get_id('_username'), '')).strip() or None - if hasattr(curTorrentProvider, 'digest'): - try: - curTorrentProvider.digest = str(kwargs[curTorrentProvider.get_id() + '_digest']).strip() - except Exception: - curTorrentProvider.digest = None + if hasattr(curProvider, 'password'): + curProvider.password = filters.unhide(curProvider.password, str(kwargs.get(curProvider.get_id('_password'), '')).strip()) - if hasattr(curTorrentProvider, 'hash'): - try: - curTorrentProvider.hash = str(kwargs[curTorrentProvider.get_id() + '_hash']).strip() - except Exception: - curTorrentProvider.hash = None + if hasattr(curProvider, 'passkey'): + curProvider.passkey = filters.unhide(curProvider.passkey, str(kwargs.get(curProvider.get_id('_passkey'), '')).strip()) - if hasattr(curTorrentProvider, 'api_key'): - try: - curTorrentProvider.api_key = str(kwargs[curTorrentProvider.get_id() + '_api_key']).strip() - except Exception: - curTorrentProvider.api_key = None + if hasattr(curProvider, 'pin'): + curProvider.pin = filters.unhide(curProvider.pin, str(kwargs.get(curProvider.get_id('_pin'), '')).strip()) - if hasattr(curTorrentProvider, 'username'): - try: - curTorrentProvider.username = str(kwargs[curTorrentProvider.get_id() + '_username']).strip() - except Exception: - curTorrentProvider.username = None + if hasattr(curProvider, 'confirmed'): + curProvider.confirmed = config.checkbox_to_value(kwargs.get(curProvider.get_id('_confirmed'))) - if hasattr(curTorrentProvider, 'password'): - try: - curTorrentProvider.password = filters.unhide(curTorrentProvider.password, str(kwargs[curTorrentProvider.get_id() + '_password']).strip()) - except Exception: - curTorrentProvider.password = None + if hasattr(curProvider, 'ranked'): + curProvider.ranked = config.checkbox_to_value(kwargs.get(curProvider.get_id('_ranked'))) - if hasattr(curTorrentProvider, 'passkey'): - try: - curTorrentProvider.passkey = filters.unhide(curTorrentProvider.passkey, str(kwargs[curTorrentProvider.get_id() + '_passkey']).strip()) - except Exception: - curTorrentProvider.passkey = None + if hasattr(curProvider, 'engrelease'): + curProvider.engrelease = config.checkbox_to_value(kwargs.get(curProvider.get_id('_engrelease'))) - if hasattr(curTorrentProvider, 'pin'): - try: - curTorrentProvider.pin = filters.unhide(curTorrentProvider.pin, str(kwargs[curTorrentProvider.get_id() + '_pin']).strip()) - except Exception: - curTorrentProvider.pin = None + if hasattr(curProvider, 'onlyspasearch'): + curProvider.onlyspasearch = config.checkbox_to_value(kwargs.get(curProvider.get_id('_onlyspasearch'))) - if hasattr(curTorrentProvider, 'confirmed'): - try: - curTorrentProvider.confirmed = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_confirmed']) - except Exception: - curTorrentProvider.confirmed = 0 + if hasattr(curProvider, 'sorting'): + curProvider.sorting = str(kwargs.get(curProvider.get_id('_sorting'), 'seeders')).strip() - if hasattr(curTorrentProvider, 'ranked'): - try: - curTorrentProvider.ranked = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_ranked']) - except Exception: - curTorrentProvider.ranked = 0 + if hasattr(curProvider, 'freeleech'): + curProvider.freeleech = config.checkbox_to_value(kwargs.get(curProvider.get_id('_freeleech'))) - if hasattr(curTorrentProvider, 'engrelease'): - try: - curTorrentProvider.engrelease = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_engrelease']) - except Exception: - curTorrentProvider.engrelease = 0 + if hasattr(curProvider, 'search_mode'): + curProvider.search_mode = str(kwargs.get(curProvider.get_id('_search_mode'), 'eponly')).strip() - if hasattr(curTorrentProvider, 'onlyspasearch'): - try: - curTorrentProvider.onlyspasearch = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_onlyspasearch']) - except Exception: - curTorrentProvider.onlyspasearch = 0 + if hasattr(curProvider, 'search_fallback'): + curProvider.search_fallback = config.checkbox_to_value(kwargs.get(curProvider.get_id('_search_fallback'))) - if hasattr(curTorrentProvider, 'sorting'): - try: - curTorrentProvider.sorting = str(kwargs[curTorrentProvider.get_id() + '_sorting']).strip() - except Exception: - curTorrentProvider.sorting = 'seeders' + if hasattr(curProvider, 'enable_daily'): + curProvider.enable_daily = curProvider.can_daily and config.checkbox_to_value(kwargs.get(curProvider.get_id('_enable_daily'))) - if hasattr(curTorrentProvider, 'freeleech'): - try: - curTorrentProvider.freeleech = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_freeleech']) - except Exception: - curTorrentProvider.freeleech = 0 + if hasattr(curProvider, 'enable_backlog'): + curProvider.enable_backlog = curProvider.can_backlog and config.checkbox_to_value(kwargs.get(curProvider.get_id('_enable_backlog'))) - if hasattr(curTorrentProvider, 'search_mode'): - try: - curTorrentProvider.search_mode = str(kwargs[curTorrentProvider.get_id() + '_search_mode']).strip() - except Exception: - curTorrentProvider.search_mode = 'eponly' - - if hasattr(curTorrentProvider, 'search_fallback'): - try: - curTorrentProvider.search_fallback = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_search_fallback']) - except Exception: - curTorrentProvider.search_fallback = 0 # these exceptions are catching unselected checkboxes - - if hasattr(curTorrentProvider, 'enable_daily'): - try: - curTorrentProvider.enable_daily = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_enable_daily']) - except Exception: - curTorrentProvider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes - - if hasattr(curTorrentProvider, 'enable_backlog'): - try: - curTorrentProvider.enable_backlog = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_enable_backlog']) - except Exception: - curTorrentProvider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes - - if hasattr(curTorrentProvider, 'cat'): - try: - curTorrentProvider.cat = int(str(kwargs[curTorrentProvider.get_id() + '_cat']).strip()) - except Exception: - curTorrentProvider.cat = 0 - - if hasattr(curTorrentProvider, 'subtitle'): - try: - curTorrentProvider.subtitle = config.checkbox_to_value( - kwargs[curTorrentProvider.get_id() + '_subtitle']) - except Exception: - curTorrentProvider.subtitle = 0 - - if curTorrentProvider.enable_cookies: - try: - curTorrentProvider.cookies = str(kwargs['{id}_cookies'.format(id=curTorrentProvider.get_id())]).strip() - except Exception: - pass # I don't want to configure a default value here, as it can also be configured intially as a custom rss torrent provider - - for curNzbProvider in [prov for prov in sickbeard.providers.sortedProviderList() if - prov.provider_type == GenericProvider.NZB]: - - if hasattr(curNzbProvider, 'api_key'): - try: - curNzbProvider.api_key = str(kwargs[curNzbProvider.get_id() + '_api_key']).strip() - except Exception: - curNzbProvider.api_key = None - - if hasattr(curNzbProvider, 'username'): - try: - curNzbProvider.username = str(kwargs[curNzbProvider.get_id() + '_username']).strip() - except Exception: - curNzbProvider.username = None - - if hasattr(curNzbProvider, 'search_mode'): - try: - curNzbProvider.search_mode = str(kwargs[curNzbProvider.get_id() + '_search_mode']).strip() - except Exception: - curNzbProvider.search_mode = 'eponly' + if hasattr(curProvider, 'cat'): + curProvider.cat = int(str(kwargs.get(curProvider.get_id('_cat'), 0)).strip()) - if hasattr(curNzbProvider, 'search_fallback'): - try: - curNzbProvider.search_fallback = config.checkbox_to_value( - kwargs[curNzbProvider.get_id() + '_search_fallback']) - except Exception: - curNzbProvider.search_fallback = 0 # these exceptions are actually catching unselected checkboxes + if hasattr(curProvider, 'subtitle'): + curProvider.subtitle = config.checkbox_to_value(kwargs.get(curProvider.get_id('_subtitle'))) - if hasattr(curNzbProvider, 'enable_daily'): - try: - curNzbProvider.enable_daily = config.checkbox_to_value( - kwargs[curNzbProvider.get_id() + '_enable_daily']) - except Exception: - curNzbProvider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes - - if hasattr(curNzbProvider, 'enable_backlog'): - try: - curNzbProvider.enable_backlog = config.checkbox_to_value( - kwargs[curNzbProvider.get_id() + '_enable_backlog']) - except Exception: - curNzbProvider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes + if curProvider.enable_cookies: + curProvider.cookies = str(kwargs.get(curProvider.get_id('_cookies'))).strip() sickbeard.NEWZNAB_DATA = '!!!'.join([x.configStr() for x in sickbeard.newznabProviderList]) sickbeard.PROVIDER_ORDER = enabled_provider_list + disabled_provider_list diff --git a/sickrage/providers/GenericProvider.py b/sickrage/providers/GenericProvider.py index c801b8e316a56070159e5abbb720b8cf0e9d6a2b..434f412a2fca80db9457441487cba5c32a437a35 100644 --- a/sickrage/providers/GenericProvider.py +++ b/sickrage/providers/GenericProvider.py @@ -38,7 +38,7 @@ from sickbeard.helpers import download_file, getURL, make_session, remove_file_f from sickbeard.name_parser.parser import InvalidNameException, InvalidShowException, NameParser from sickbeard.show_name_helpers import allPossibleShowNames from sickbeard.tvcache import TVCache -from sickrage.helper.common import replace_extension, sanitize_filename +from sickrage.helper.common import sanitize_filename from sickrage.helper.encoding import ek @@ -47,6 +47,18 @@ class GenericProvider(object): # pylint: disable=too-many-instance-attributes NZBDATA = 'nzbdata' TORRENT = 'torrent' + PROVIDER_BROKEN = 0 + PROVIDER_DAILY = 1 + PROVIDER_BACKLOG = 2 + PROVIDER_OK = 3 + + ProviderStatus = { + PROVIDER_BROKEN: _("Not working"), + PROVIDER_DAILY: _("Daily/RSS only"), + PROVIDER_BACKLOG: _("Backlog/Manual Search only"), + PROVIDER_OK: _("Daily/RSS and Backlog/Manual Searches working") + } + def __init__(self, name): self.name = name @@ -81,6 +93,9 @@ class GenericProvider(object): # pylint: disable=too-many-instance-attributes self.cookies = '' self.rss_cookies = '' + self.ability_status = self.PROVIDER_OK + + shuffle(self.bt_cache_urls) def download_result(self, result): @@ -328,8 +343,8 @@ class GenericProvider(object): # pylint: disable=too-many-instance-attributes return results - def get_id(self): - return GenericProvider.make_id(self.name) + def get_id(self, suffix=''): + return GenericProvider.make_id(self.name) + six.text_type(suffix) def get_quality(self, item, anime=False): (title, url_) = self._get_title_and_url(item) @@ -359,12 +374,25 @@ class GenericProvider(object): # pylint: disable=too-many-instance-attributes def image_name(self): return self.get_id() + '.png' + @property def is_active(self): # pylint: disable=no-self-use return False + @property def is_enabled(self): return bool(self.enabled) + @property + def can_daily(self): + return self.ability_status & self.PROVIDER_DAILY != 0 + + @property + def can_backlog(self): + return self.ability_status & self.PROVIDER_BACKLOG != 0 and self.supports_backlog + + def status(self): + return self.ProviderStatus.get(self.ability_status) + @staticmethod def make_id(name): if not name: diff --git a/sickrage/providers/__init__.py b/sickrage/providers/__init__.py index 02ec77aa8fd8c564bf3072f7bcbdd74379e1265a..705411070cacbd6a3b6b9b0b40029bd754e4b904 100644 --- a/sickrage/providers/__init__.py +++ b/sickrage/providers/__init__.py @@ -1,4 +1,2 @@ # coding=utf-8 from __future__ import unicode_literals - -__all__ = [] diff --git a/sickrage/providers/nzb/NZBProvider.py b/sickrage/providers/nzb/NZBProvider.py index d053e414a11fa3276a66faa7aa6c023119f96646..fc45e7c844d4e129a6ded8a0ac63e6a354e473ef 100644 --- a/sickrage/providers/nzb/NZBProvider.py +++ b/sickrage/providers/nzb/NZBProvider.py @@ -33,8 +33,9 @@ class NZBProvider(GenericProvider): self.provider_type = GenericProvider.NZB self.torznab = False + @property def is_active(self): - return bool(sickbeard.USE_NZBS) and self.is_enabled() + return bool(sickbeard.USE_NZBS) and self.is_enabled def _get_result(self, episodes): result = NZBSearchResult(episodes) diff --git a/sickrage/providers/torrent/TorrentProvider.py b/sickrage/providers/torrent/TorrentProvider.py index 72fbe729b31489d3e9ecfa6b6242b9f6b388a624..6ce21e4068a2a23c8e4e3a8fc93382402d886a70 100644 --- a/sickrage/providers/torrent/TorrentProvider.py +++ b/sickrage/providers/torrent/TorrentProvider.py @@ -70,8 +70,9 @@ class TorrentProvider(GenericProvider): return results + @property def is_active(self): - return bool(sickbeard.USE_TORRENTS) and self.is_enabled() + return bool(sickbeard.USE_TORRENTS) and self.is_enabled @property def _custom_trackers(self): diff --git a/tests/feedparser_tests.py b/tests/feedparser_tests.py index 530a18ce024f4242dbf342e822b6cb99de60e842..fa35eab1f6b8a16428d69438ec5d74ed7682e63f 100644 --- a/tests/feedparser_tests.py +++ b/tests/feedparser_tests.py @@ -1,43 +1,44 @@ -# coding=utf-8 - -""" -Test Feed Parser -""" - -import os.path -import sys -import unittest - -sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib'))) -sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) - -from sickbeard.providers.binsearch import provider as binsearch -import requests - - -class FeedParserTests(unittest.TestCase): - """ - Test feed parser - """ - @unittest.skipIf(not requests.head(binsearch.urls['rss'], timeout=30).ok, 'BinSearch is unavailable') - def test_binsearch(self): - """ - Test BinSearch - """ - result = binsearch.cache.get_rss_feed(binsearch.urls['rss'], params={'max': 50, 'g': 'alt.binaries.hdtv'}) - self.assertTrue('entries' in result) - self.assertTrue('feed' in result) - for item in result[b'entries'] or []: - title, url = binsearch._get_title_and_url(item) # pylint: disable=protected-access - self.assertTrue(title and url) - -if __name__ == "__main__": - print("==================") - print("STARTING - FEED PARSER TESTS") - print("==================") - print("######################################################################") - SUITE = unittest.TestLoader().loadTestsFromTestCase(FeedParserTests) - TEST_RESULTS = unittest.TextTestRunner(verbosity=2).run(SUITE) - - # Return 0 if successful, 1 if there was a failure - sys.exit(not TEST_RESULTS.wasSuccessful()) +# Disabled until a new feed provider is available +# # coding=utf-8 +# +# """ +# Test Feed Parser +# """ +# +# import os.path +# import sys +# import unittest +# +# sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib'))) +# sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +# +# from sickbeard.providers.binsearch import provider as binsearch +# import requests +# +# +# class FeedParserTests(unittest.TestCase): +# """ +# Test feed parser +# """ +# @unittest.skipIf(not requests.head(binsearch.urls['rss'], timeout=30).ok, 'BinSearch is unavailable') +# def test_binsearch(self): +# """ +# Test BinSearch +# """ +# result = binsearch.cache.get_rss_feed(binsearch.urls['rss'], params={'max': 50, 'g': 'alt.binaries.hdtv'}) +# self.assertTrue('entries' in result) +# self.assertTrue('feed' in result) +# for item in result[b'entries'] or []: +# title, url = binsearch._get_title_and_url(item) # pylint: disable=protected-access +# self.assertTrue(title and url) +# +# if __name__ == "__main__": +# print("==================") +# print("STARTING - FEED PARSER TESTS") +# print("==================") +# print("######################################################################") +# SUITE = unittest.TestLoader().loadTestsFromTestCase(FeedParserTests) +# TEST_RESULTS = unittest.TextTestRunner(verbosity=2).run(SUITE) +# +# # Return 0 if successful, 1 if there was a failure +# sys.exit(not TEST_RESULTS.wasSuccessful()) diff --git a/tests/sickrage_tests/providers/generic_provider_tests.py b/tests/sickrage_tests/providers/generic_provider_tests.py index 5d312ed1f558fcdc7bb03546194175f8845f83b1..2c6fefef969a402c678e832e8b0ba4e9a39922e5 100644 --- a/tests/sickrage_tests/providers/generic_provider_tests.py +++ b/tests/sickrage_tests/providers/generic_provider_tests.py @@ -169,13 +169,13 @@ class GenericProviderTests(unittest.TestCase): """ Test is_active """ - self.assertFalse(GenericProvider('Test Provider').is_active()) + self.assertFalse(GenericProvider('Test Provider').is_active) def test_is_enabled(self): """ Test is_enabled """ - self.assertFalse(GenericProvider('Test Provider').is_enabled()) + self.assertFalse(GenericProvider('Test Provider').is_enabled) def test_make_id(self): """ diff --git a/tests/sickrage_tests/providers/nzb_provider_tests.py b/tests/sickrage_tests/providers/nzb_provider_tests.py index 1d0804fcbf91726abb0ee47d33f2606be5555061..8b27ec4b8792ae4ec9b2b75609bacb7f0a0ad73c 100644 --- a/tests/sickrage_tests/providers/nzb_provider_tests.py +++ b/tests/sickrage_tests/providers/nzb_provider_tests.py @@ -71,7 +71,7 @@ class NZBProviderTests(GenericProviderTests): provider = NZBProvider('Test Provider') provider.enabled = enabled - self.assertEqual(provider.is_active(), result) + self.assertEqual(provider.is_active, result) def test__get_size(self): """ diff --git a/tests/sickrage_tests/providers/torrent/parsing_tests.py b/tests/sickrage_tests/providers/torrent/parsing_tests.py index 0b9e97427fd7fe2cffb2903ddc145c5da0ee4ddb..40a17f78167ba1ba297f9255aff6d3c3ce267d3e 100644 --- a/tests/sickrage_tests/providers/torrent/parsing_tests.py +++ b/tests/sickrage_tests/providers/torrent/parsing_tests.py @@ -209,7 +209,7 @@ def generate_test_cases(): """ for p in sickbeard.providers.__all__: provider = sickbeard.providers.getProviderModule(p).provider - if provider.supports_backlog and provider.provider_type == 'torrent' and provider.public: + if provider.can_backlog and provider.provider_type == 'torrent' and provider.public: generated_class = type(str(provider.name), (BaseParser.TestCase,), {'provider': provider}) globals()[generated_class.__name__] = generated_class del generated_class diff --git a/tests/sickrage_tests/providers/torrent_provider_tests.py b/tests/sickrage_tests/providers/torrent_provider_tests.py index d7106cc7d505a1134dcef26071e12138daa89b57..6fccbdbda3f60bb4a74d82cbb00b1af461db28b0 100644 --- a/tests/sickrage_tests/providers/torrent_provider_tests.py +++ b/tests/sickrage_tests/providers/torrent_provider_tests.py @@ -71,7 +71,7 @@ class TorrentProviderTests(GenericProviderTests): provider = TorrentProvider('Test Provider') provider.enabled = enabled - self.assertEqual(provider.is_active(), result) + self.assertEqual(provider.is_active, result) def test__get_size(self): """ diff --git a/tests/snatch_tests.py b/tests/snatch_tests.py index 551fdc8898bdfe8f9e6567b3a8127c00a3144b0d..25ed4cee7bba88b3bb50429d31feeb459981ea1c 100644 --- a/tests/snatch_tests.py +++ b/tests/snatch_tests.py @@ -81,8 +81,8 @@ class SearchTest(test.SickbeardTestDBCase): _ = url, headers return _create_fake_xml(search_items) - @staticmethod - def _fake_is_active(): + @property + def _fake_is_active(self): """ Fake is active """ @@ -98,7 +98,7 @@ class SearchTest(test.SickbeardTestDBCase): for provider in sickbeard.providers.sortedProviderList(): provider.get_url = self._fake_get_url - # provider.is_active = self._fake_is_active + provider.is_active = self._fake_is_active super(SearchTest, self).__init__(something)