Merge pull request #464 from JackDandy/feature/ChangeProvRefactorAndPEP8

Change refactor, PEP8, code convention cleanse for nzb/torrent code…
This commit is contained in:
JackDandy 2015-07-15 19:32:04 +01:00
commit 40bcc38c5b
51 changed files with 1083 additions and 1191 deletions

10
.gitignore vendored
View file

@ -1,5 +1,5 @@
# SB User Related #
######################
# SB User Related #
cache/*
cache.db*
config.ini*
@ -11,18 +11,18 @@ server.crt
server.key
restore/
# SB Test Related #
######################
# SB Test Related #
tests/Logs/*
tests/sickbeard.*
tests/cache.db
# Compiled source #
######################
# Compiled source #
*.py[co]
# IDE specific #
######################
# IDE specific #
*.bak
*.tmp
*.wpr
@ -35,8 +35,8 @@ tests/cache.db
Session.vim
.ropeproject/*
# OS generated files #
######################
# OS generated files #
.Spotlight-V100
.Trashes
.DS_Store

View file

@ -1,7 +1,7 @@
[SickBeard]
host=localhost
port=8081
username=
password=
web_root=
[SickBeard]
host=localhost
port=8081
username=
password=
web_root=
ssl=0

View file

@ -1,13 +1,17 @@
from distutils.core import setup
import py2exe, sys, shutil
import sys
import shutil
try:
import py2exe
except:
pass
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
# windows = [{'console': "sabToSickbeard.py"}],
zipfile = None,
console = ['sabToSickbeard.py'],
)
setup(options={'py2exe': {'bundle_files': 1}},
# windows = [{'console': "sabToSickbeard.py"}],
zipfile=None,
console=['sabToSickbeard.py']
)
shutil.copy('dist/sabToSickbeard.exe', '.')

View file

Before

Width:  |  Height:  |  Size: 886 B

After

Width:  |  Height:  |  Size: 886 B

View file

@ -3,8 +3,8 @@
#from sickbeard.providers import thepiratebay
#from sickbeard.helpers import anon_url, starify
##
#set global $title="Config - Providers"
#set global $header="Search Providers"
#set global $title = 'Config - Providers'
#set global $header = 'Search Providers'
#set global $sbPath = '../..'
#set global $topmenu = 'config'
##
@ -39,7 +39,7 @@
#for $curNewznabProvider in $sickbeard.newznabProviderList:
\$(this).addProvider('$curNewznabProvider.getID()', '$curNewznabProvider.name', '$curNewznabProvider.url', '<%= starify(curNewznabProvider.key) %>', '$curNewznabProvider.cat_ids', $int($curNewznabProvider.default), show_nzb_providers);
\$(this).addProvider('$curNewznabProvider.get_id()', '$curNewznabProvider.name', '$curNewznabProvider.url', '<%= starify(curNewznabProvider.key) %>', '$curNewznabProvider.cat_ids', $int($curNewznabProvider.default), show_nzb_providers);
#end for
@ -49,7 +49,7 @@
#for $curTorrentRssProvider in $sickbeard.torrentRssProviderList:
\$(this).addTorrentRssProvider('$curTorrentRssProvider.getID()', '$curTorrentRssProvider.name', '$curTorrentRssProvider.url', '<%= starify(curTorrentRssProvider.cookies) %>');
\$(this).addTorrentRssProvider('$curTorrentRssProvider.get_id()', '$curTorrentRssProvider.name', '$curTorrentRssProvider.url', '<%= starify(curTorrentRssProvider.cookies) %>');
#end for
@ -90,7 +90,7 @@
<p>At least one provider is required but two are recommended.</p>
#if $methods_notused
<blockquote style="margin: 20px 0"><%= '/'.join(x for x in methods_notused) %> providers can be enabled in <a href="$sbRoot/config/search/">Search Settings</a></blockquote>
<blockquote style="margin:20px 0"><%= '/'.join(x for x in methods_notused) %> providers can be enabled in <a href="$sbRoot/config/search/">Search Settings</a></blockquote>
#else
<br/>
#end if
@ -104,11 +104,11 @@
#elif $curProvider.providerType == $GenericProvider.TORRENT and not $sickbeard.USE_TORRENTS
#continue
#end if
#set $curName = $curProvider.getID()
#set $curName = $curProvider.get_id()
<li class="ui-state-default" id="$curName">
<input type="checkbox" id="enable_$curName" class="provider_enabler" <%= html_checked if curProvider.isEnabled() else '' %>/>
<a href="<%= anon_url(curProvider.url) %>" class="imgLink" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;"><img src="$sbRoot/images/providers/$curProvider.imageName()" alt="$curProvider.name" title="$curProvider.name" width="16" height="16" style="vertical-align:middle;"/></a>
<span style="vertical-align:middle;">$curProvider.name</span>
<input type="checkbox" id="enable_$curName" class="provider_enabler" <%= html_checked if curProvider.is_enabled() else '' %>/>
<a href="<%= anon_url(curProvider.url) %>" class="imgLink" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;"><img src="$sbRoot/images/providers/$curProvider.image_name()" alt="$curProvider.name" title="$curProvider.name" width="16" height="16" style="vertical-align:middle;"/></a>
<span style="vertical-align:middle">$curProvider.name</span>
<%= '*' if not curProvider.supportsBacklog else '' %>
<span class="ui-icon ui-icon-arrowthick-2-n-s pull-right" style="margin-top:3px"></span>
</li>
@ -124,7 +124,7 @@
##<h4 class="note">!</h4><p class="note">Provider is <b>NOT WORKING</b></p>
</div>
<input type="hidden" name="provider_order" id="provider_order" value="<%=" ".join([x.getID()+':'+str(int(x.isEnabled())) 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()])%>"/>
<div style="width: 300px; float: right">
<div style="margin: 0px auto; width: 101px">
<input type="submit" class="btn config_submitter" value="Save Changes" />
@ -156,7 +156,7 @@
#elif $curProvider.providerType == $GenericProvider.TORRENT and not $sickbeard.USE_TORRENTS
#continue
#end if
#if $curProvider.isEnabled()
#if $curProvider.is_enabled()
$provider_config_list_enabled.append($curProvider)
#else
$provider_config_list.append($curProvider)
@ -168,14 +168,14 @@
#if $provider_config_list_enabled
<optgroup label="Enabled...">
#for $cur_provider in $provider_config_list_enabled:
<option value="$cur_provider.getID()">$cur_provider.name</option>
<option value="$cur_provider.get_id()">$cur_provider.name</option>
#end for
</optgroup>
#end if
#if $provider_config_list
<optgroup label="Not Enabled...">
#for $cur_provider in $provider_config_list
<option value="$cur_provider.getID()">$cur_provider.name</option>
<option value="$cur_provider.get_id()">$cur_provider.name</option>
#end for
</optgroup>
#end if
@ -187,76 +187,71 @@
</label>
</div>
<!-- start div for editing providers //-->
#for $curNewznabProvider in [$curProvider for $curProvider in $sickbeard.newznabProviderList]
<div class="providerDiv" id="${curNewznabProvider.getID()}Div">
<div class="providerDiv" id="${curNewznabProvider.get_id()}Div">
#if $curNewznabProvider.default and $curNewznabProvider.needs_auth
<div class="field-pair">
<label for="${curNewznabProvider.getID()}_url">
<label for="${curNewznabProvider.get_id()}_url">
<span class="component-title">URL</span>
<span class="component-desc">
<input type="text" id="${curNewznabProvider.getID()}_url" value="$curNewznabProvider.url" class="form-control input-sm input350" disabled/>
<input type="text" id="${curNewznabProvider.get_id()}_url" value="$curNewznabProvider.url" class="form-control input-sm input350" disabled/>
</span>
</label>
</div>
<div class="field-pair">
<label for="${curNewznabProvider.getID()}_hash">
<label for="${curNewznabProvider.get_id()}_hash">
<span class="component-title">API key</span>
<span class="component-desc">
<input type="text" id="${curNewznabProvider.getID()}_hash" value="<%= starify(curNewznabProvider.key) %>" newznab_name="${curNewznabProvider.getID()}_hash" class="newznab_key form-control input-sm input350" />
<input type="text" id="${curNewznabProvider.get_id()}_hash" value="<%= starify(curNewznabProvider.key) %>" newznab_name="${curNewznabProvider.get_id()}_hash" class="newznab_key form-control input-sm input350" />
<div class="clear-left"><p>get API key from provider website</p></div>
</span>
</label>
</div>
#end if
#if $hasattr($curNewznabProvider, 'enable_recentsearch'):
#if $hasattr($curNewznabProvider, 'enable_recentsearch') and $curNewznabProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNewznabProvider.getID()}_enable_recentsearch">
<label for="${curNewznabProvider.get_id()}_enable_recentsearch">
<span class="component-title">Enable recent searches</span>
<span class="component-desc">
<input type="checkbox" name="${curNewznabProvider.getID()}_enable_recentsearch" id="${curNewznabProvider.getID()}_enable_recentsearch" <%= html_checked if curNewznabProvider.enable_recentsearch else '' %>/>
<input type="checkbox" name="${curNewznabProvider.get_id()}_enable_recentsearch" id="${curNewznabProvider.get_id()}_enable_recentsearch" <%= html_checked if curNewznabProvider.enable_recentsearch else '' %>/>
<p>perform recent searches at provider</p>
</span>
</label>
</div>
#end if
#if $hasattr($curNewznabProvider, 'enable_backlog'):
#if $hasattr($curNewznabProvider, 'enable_backlog') and $curNewznabProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNewznabProvider.getID()}_enable_backlog">
<label for="${curNewznabProvider.get_id()}_enable_backlog">
<span class="component-title">Enable backlog searches</span>
<span class="component-desc">
<input type="checkbox" name="${curNewznabProvider.getID()}_enable_backlog" id="${curNewznabProvider.getID()}_enable_backlog" <%= html_checked if curNewznabProvider.enable_backlog else '' %>/>
<input type="checkbox" name="${curNewznabProvider.get_id()}_enable_backlog" id="${curNewznabProvider.get_id()}_enable_backlog" <%= html_checked if curNewznabProvider.enable_backlog else '' %>/>
<p>perform backlog searches at provider</p>
</span>
</label>
</div>
#end if
#if $hasattr($curNewznabProvider, 'search_mode'):
#if $hasattr($curNewznabProvider, 'search_mode') and $curNewznabProvider.supportsBacklog:
<div class="field-pair">
<span class="component-title">Season search mode</span>
<span class="component-desc">
<label class="space-right">
<input type="radio" name="${curNewznabProvider.getID()}_search_mode" id="${curNewznabProvider.getID()}_search_mode_sponly" value="sponly" <%= html_checked if 'sponly' == curNewznabProvider.search_mode else '' %>/>season packs only
<input type="radio" name="${curNewznabProvider.get_id()}_search_mode" id="${curNewznabProvider.get_id()}_search_mode_sponly" value="sponly" <%= html_checked if 'sponly' == curNewznabProvider.search_mode else '' %>/>season packs only
</label>
<label>
<input type="radio" name="${curNewznabProvider.getID()}_search_mode" id="${curNewznabProvider.getID()}_search_mode_eponly" value="eponly" <%= html_checked if 'eponly' == curNewznabProvider.search_mode else '' %>/>episodes only
<input type="radio" name="${curNewznabProvider.get_id()}_search_mode" id="${curNewznabProvider.get_id()}_search_mode_eponly" value="eponly" <%= html_checked if 'eponly' == curNewznabProvider.search_mode else '' %>/>episodes only
</label>
<p>when searching for complete seasons, search for packs or collect single episodes</p>
</span>
</div>
#end if
#if $hasattr($curNewznabProvider, 'search_fallback'):
#if $hasattr($curNewznabProvider, 'search_fallback') and $curNewznabProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNewznabProvider.getID()}_search_fallback">
<label for="${curNewznabProvider.get_id()}_search_fallback">
<span class="component-title">Season search fallback</span>
<span class="component-desc">
<input type="checkbox" name="${curNewznabProvider.getID()}_search_fallback" id="${curNewznabProvider.getID()}_search_fallback" <%= html_checked if curNewznabProvider.search_fallback else '' %>/>
<input type="checkbox" name="${curNewznabProvider.get_id()}_search_fallback" id="${curNewznabProvider.get_id()}_search_fallback" <%= html_checked if curNewznabProvider.search_fallback else '' %>/>
<p>run the alternate season search mode when a complete season is not found</p>
</span>
</label>
@ -264,218 +259,205 @@
#end if
</div>
#end for
##
##
#for $curNzbProvider in [$curProvider for $curProvider in $sickbeard.providers.sortedProviderList() if $curProvider.providerType == $GenericProvider.NZB and $curProvider not in $sickbeard.newznabProviderList]:
<div class="providerDiv" id="${curNzbProvider.getID()}Div">
<div class="providerDiv" id="${curNzbProvider.get_id()}Div">
#if $hasattr($curNzbProvider, 'username'):
<div class="field-pair">
<label for="${curNzbProvider.getID()}_username">
<label for="${curNzbProvider.get_id()}_username">
<span class="component-title">Username</span>
<span class="component-desc">
<input type="text" name="${curNzbProvider.getID()}_username" value="$curNzbProvider.username" class="form-control input-sm input350" />
<input type="text" name="${curNzbProvider.get_id()}_username" value="$curNzbProvider.username" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curNzbProvider, 'api_key'):
<div class="field-pair">
<label for="${curNzbProvider.getID()}_api_key">
<label for="${curNzbProvider.get_id()}_api_key">
<span class="component-title">API key</span>
<span class="component-desc">
<input type="text" name="${curNzbProvider.getID()}_api_key" value="<%= starify(curNzbProvider.api_key) %>" class="form-control input-sm input350" />
#set $field_name = curNzbProvider.get_id() + '_api_key'
<input type="text" name="$field_name" value="<%= starify(curNzbProvider.api_key) %>" class="form-control input-sm input350" />
#if callable(getattr(curNzbProvider, 'ui_string'))
<div class="clear-left"><p>${curNzbProvider.ui_string($field_name)}</p></div>
#end if
</span>
</label>
</div>
#end if
#if $hasattr($curNzbProvider, 'enable_recentsearch'):
#if $hasattr($curNzbProvider, 'enable_recentsearch') and $curNzbProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNzbProvider.getID()}_enable_recentsearch">
<label for="${curNzbProvider.get_id()}_enable_recentsearch">
<span class="component-title">Enable recent searches</span>
<span class="component-desc">
<input type="checkbox" name="${curNzbProvider.getID()}_enable_recentsearch" id="${curNzbProvider.getID()}_enable_recentsearch" <%= html_checked if curNzbProvider.enable_recentsearch else '' %>/>
<input type="checkbox" name="${curNzbProvider.get_id()}_enable_recentsearch" id="${curNzbProvider.get_id()}_enable_recentsearch" <%= html_checked if curNzbProvider.enable_recentsearch else '' %>/>
<p>enable provider to perform recent searches.</p>
</span>
</label>
</div>
#end if
#if $hasattr($curNzbProvider, 'enable_backlog'):
#if $hasattr($curNzbProvider, 'enable_backlog') and $curNzbProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNzbProvider.getID()}_enable_backlog">
<label for="${curNzbProvider.get_id()}_enable_backlog">
<span class="component-title">Enable backlog searches</span>
<span class="component-desc">
<input type="checkbox" name="${curNzbProvider.getID()}_enable_backlog" id="${curNzbProvider.getID()}_enable_backlog" <%= html_checked if curNzbProvider.enable_backlog else '' %>/>
<input type="checkbox" name="${curNzbProvider.get_id()}_enable_backlog" id="${curNzbProvider.get_id()}_enable_backlog" <%= html_checked if curNzbProvider.enable_backlog else '' %>/>
<p>enable provider to perform backlog searches.</p>
</span>
</label>
</div>
#end if
#if $hasattr($curNzbProvider, 'search_fallback'):
#if $hasattr($curNzbProvider, 'search_mode') and $curNzbProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNzbProvider.getID()}_search_fallback">
<span class="component-title">Season search mode</span>
<span class="component-desc">
<label class="space-right">
<input type="radio" name="${curNzbProvider.get_id()}_search_mode" id="${curNzbProvider.get_id()}_search_mode_sponly" value="sponly" <%= html_checked if 'sponly' == curNzbProvider.search_mode else '' %>/>season packs only
</label>
<label>
<input type="radio" name="${curNzbProvider.get_id()}_search_mode" id="${curNzbProvider.get_id()}_search_mode_eponly" value="eponly" <%= html_checked if 'eponly' == curNzbProvider.search_mode else '' %>/>episodes only
</label>
<p>when searching for complete seasons, search for packs or collect single episodes</p>
</span>
</div>
#end if
#if $hasattr($curNzbProvider, 'search_fallback') and $curNzbProvider.supportsBacklog:
<div class="field-pair">
<label for="${curNzbProvider.get_id()}_search_fallback">
<span class="component-title">Season search fallback</span>
<span class="component-desc">
<input type="checkbox" name="${curNzbProvider.getID()}_search_fallback" id="${curNzbProvider.getID()}_search_fallback" <%= html_checked if curNzbProvider.search_fallback else '' %>/>
<p>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.</p>
<input type="checkbox" name="${curNzbProvider.get_id()}_search_fallback" id="${curNzbProvider.get_id()}_search_fallback" <%= html_checked if curNzbProvider.search_fallback else '' %>/>
<p>run the alternate season search mode when a complete season is not found</p>
</span>
</label>
</div>
#end if
#if $hasattr($curNzbProvider, 'search_mode'):
#if not $curNzbProvider.supportsBacklog:
<div class="field-pair">
<label>
<span class="component-title">Season search mode</span>
<span class="component-desc">
<p>when searching for complete seasons you can choose to have it look for season packs only, or choose to have it build a complete season from just single episodes.</p>
</span>
</label>
<label>
<span class="component-title"></span>
<span class="component-desc">
<input type="radio" name="${curNzbProvider.getID()}_search_mode" id="${curNzbProvider.getID()}_search_mode_sponly" value="sponly" <%= html_checked if 'sponly' == curNzbProvider.search_mode else '' %>/>season packs only.
</span>
</label>
<label>
<span class="component-title"></span>
<span class="component-desc">
<input type="radio" name="${curNzbProvider.getID()}_search_mode" id="${curNzbProvider.getID()}_search_mode_eponly" value="eponly" <%= html_checked if 'eponly' == curNzbProvider.search_mode else '' %>/>episodes only.
</span>
</label>
<span class="component-desc">The latest releases are the focus of this provider, no backlog searching</span>
</div>
#end if
</div>
#end for
##
##
#for $curTorrentProvider in [$curProvider for $curProvider in $sickbeard.providers.sortedProviderList() if $curProvider.providerType == $GenericProvider.TORRENT]:
<div class="providerDiv" id="${curTorrentProvider.getID()}Div">
<div class="providerDiv" id="${curTorrentProvider.get_id()}Div">
#if $hasattr($curTorrentProvider, 'api_key'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_api_key">
<label for="${curTorrentProvider.get_id()}_api_key">
<span class="component-title">Api key:</span>
<span class="component-desc">
<input type="text" name="${curTorrentProvider.getID()}_api_key" id="${curTorrentProvider.getID()}_api_key" value="<%= starify(curTorrentProvider.api_key) %>" class="form-control input-sm input350" />
<input type="text" name="${curTorrentProvider.get_id()}_api_key" id="${curTorrentProvider.get_id()}_api_key" value="<%= starify(curTorrentProvider.api_key) %>" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'digest'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_digest">
<label for="${curTorrentProvider.get_id()}_digest">
<span class="component-title">Digest:</span>
<span class="component-desc">
<input type="text" name="${curTorrentProvider.getID()}_digest" id="${curTorrentProvider.getID()}_digest" value="$curTorrentProvider.digest" class="form-control input-sm input350" />
<input type="text" name="${curTorrentProvider.get_id()}_digest" id="${curTorrentProvider.get_id()}_digest" value="$curTorrentProvider.digest" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'hash'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_hash">
<label for="${curTorrentProvider.get_id()}_hash">
<span class="component-title">Hash:</span>
<span class="component-desc">
<input type="text" name="${curTorrentProvider.getID()}_hash" id="${curTorrentProvider.getID()}_hash" value="$curTorrentProvider.hash" class="form-control input-sm input350" />
<input type="text" name="${curTorrentProvider.get_id()}_hash" id="${curTorrentProvider.get_id()}_hash" value="$curTorrentProvider.hash" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'username'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_username">
<label for="${curTorrentProvider.get_id()}_username">
<span class="component-title">Username:</span>
<span class="component-desc">
<input type="text" name="${curTorrentProvider.getID()}_username" id="${curTorrentProvider.getID()}_username" value="$curTorrentProvider.username" class="form-control input-sm input350" />
<input type="text" name="${curTorrentProvider.get_id()}_username" id="${curTorrentProvider.get_id()}_username" value="$curTorrentProvider.username" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'password'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_password">
<label for="${curTorrentProvider.get_id()}_password">
<span class="component-title">Password:</span>
<span class="component-desc">
<input type="password" name="${curTorrentProvider.getID()}_password" id="${curTorrentProvider.getID()}_password" value="#echo '*' * len($curTorrentProvider.password)#" class="form-control input-sm input350" />
<input type="password" name="${curTorrentProvider.get_id()}_password" id="${curTorrentProvider.get_id()}_password" value="#echo '*' * len($curTorrentProvider.password)#" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'passkey'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_passkey">
<label for="${curTorrentProvider.get_id()}_passkey">
<span class="component-title">Passkey:</span>
<span class="component-desc">
<input type="text" name="${curTorrentProvider.getID()}_passkey" id="${curTorrentProvider.getID()}_passkey" value="<%= starify(curTorrentProvider.passkey) %>" class="form-control input-sm input350" />
<input type="text" name="${curTorrentProvider.get_id()}_passkey" id="${curTorrentProvider.get_id()}_passkey" value="<%= starify(curTorrentProvider.passkey) %>" class="form-control input-sm input350" />
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'ratio'):
#if $hasattr($curTorrentProvider, '_seed_ratio') and 'blackhole' != $sickbeard.TORRENT_METHOD:
#set $torrent_method_text = {'blackhole': 'Black hole', 'utorrent': 'uTorrent', 'transmission': 'Transmission', 'deluge': 'Deluge', 'download_station': 'Synology DS', 'rtorrent': 'rTorrent'}
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_ratio">
<span class="component-title" id="${curTorrentProvider.getID()}_ratio_desc">Seed ratio:</span>
<label for="${curTorrentProvider.get_id()}_ratio">
<span class="component-title" id="${curTorrentProvider.get_id()}_ratio_desc">Seed until ratio (the goal)</span>
<span class="component-desc">
<input type="number" step="0.1" name="${curTorrentProvider.getID()}_ratio" id="${curTorrentProvider.getID()}_ratio" value="$curTorrentProvider.ratio" class="form-control input-sm input75" />
</span>
</label>
<label>
<span class="component-title">&nbsp;</span>
<span class="component-desc">
<p>stop transfer when ratio is reached<br>(-1 SickGear default to seed forever, or leave blank for downloader default)</p>
<input type="number" step="0.1" name="${curTorrentProvider.get_id()}_ratio" id="${curTorrentProvider.get_id()}_ratio" value="$curTorrentProvider._seed_ratio" class="form-control input-sm input75" />
<p>this ratio is requested of each download sent to $torrent_method_text[$sickbeard.TORRENT_METHOD]</p>
<div class="clear-left"><p>(set -1 to seed forever, or leave blank for the $torrent_method_text[$sickbeard.TORRENT_METHOD] default)</p></div>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'minseed'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_minseed">
<span class="component-title" id="${curTorrentProvider.getID()}_minseed_desc">Minimum seeders:</span>
<label for="${curTorrentProvider.get_id()}_minseed">
<span class="component-title" id="${curTorrentProvider.get_id()}_minseed_desc">Minimum seeders</span>
<span class="component-desc">
<input type="number" name="${curTorrentProvider.getID()}_minseed" id="${curTorrentProvider.getID()}_minseed" value="$curTorrentProvider.minseed" class="form-control input-sm input75" />
<input type="number" name="${curTorrentProvider.get_id()}_minseed" id="${curTorrentProvider.get_id()}_minseed" value="$curTorrentProvider.minseed" class="form-control input-sm input75" />
<p>a release must have to be snatch worthy</p>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'minleech'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_minleech">
<span class="component-title" id="${curTorrentProvider.getID()}_minleech_desc">Minimum leechers:</span>
<label for="${curTorrentProvider.get_id()}_minleech">
<span class="component-title" id="${curTorrentProvider.get_id()}_minleech_desc">Minimum leechers</span>
<span class="component-desc">
<input type="number" name="${curTorrentProvider.getID()}_minleech" id="${curTorrentProvider.getID()}_minleech" value="$curTorrentProvider.minleech" class="form-control input-sm input75" />
<input type="number" name="${curTorrentProvider.get_id()}_minleech" id="${curTorrentProvider.get_id()}_minleech" value="$curTorrentProvider.minleech" class="form-control input-sm input75" />
<p>a release must have to be snatch worthy</p>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'proxy'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_proxy">
<label for="${curTorrentProvider.get_id()}_proxy">
<span class="component-title">Access provider via proxy</span>
<span class="component-desc">
<input type="checkbox" class="enabler" name="${curTorrentProvider.getID()}_proxy" id="${curTorrentProvider.getID()}_proxy" <%= html_checked if curTorrentProvider.proxy.enabled else '' %>/>
<input type="checkbox" class="enabler" name="${curTorrentProvider.get_id()}_proxy" id="${curTorrentProvider.get_id()}_proxy" <%= html_checked if curTorrentProvider.proxy.enabled else '' %>/>
<p>to bypass country blocking mechanisms</p>
</span>
</label>
</div>
#if $hasattr($curTorrentProvider.proxy, 'url'):
<div class="field-pair content_${curTorrentProvider.getID()}_proxy" id="content_${curTorrentProvider.getID()}_proxy">
<label for="${curTorrentProvider.getID()}_proxy_url">
<div class="field-pair content_${curTorrentProvider.get_id()}_proxy" id="content_${curTorrentProvider.get_id()}_proxy">
<label for="${curTorrentProvider.get_id()}_proxy_url">
<span class="component-title">Proxy URL:</span>
<span class="component-desc">
<select name="${curTorrentProvider.getID()}_proxy_url" id="${curTorrentProvider.getID()}_proxy_url" class="form-control input-sm">
<select name="${curTorrentProvider.get_id()}_proxy_url" id="${curTorrentProvider.get_id()}_proxy_url" class="form-control input-sm">
#for $i in $curTorrentProvider.proxy.urls.keys():
<option value="$curTorrentProvider.proxy.urls[$i]" <%= html_selected if curTorrentProvider.proxy.url == curTorrentProvider.proxy.urls[i] else '' %>>$i</option>
#end for
@ -485,85 +467,71 @@
</div>
#end if
#end if
#if $hasattr($curTorrentProvider, 'confirmed'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_confirmed">
<label for="${curTorrentProvider.get_id()}_confirmed">
<span class="component-title">Confirmed download</span>
<span class="component-desc">
<input type="checkbox" name="${curTorrentProvider.getID()}_confirmed" id="${curTorrentProvider.getID()}_confirmed" <%= html_checked if curTorrentProvider.confirmed else '' %>/>
<input type="checkbox" name="${curTorrentProvider.get_id()}_confirmed" id="${curTorrentProvider.get_id()}_confirmed" <%= html_checked if curTorrentProvider.confirmed else '' %>/>
<p>only download torrents from trusted or verified uploaders ?</p>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'freeleech'):
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_freeleech">
<label for="${curTorrentProvider.get_id()}_freeleech">
<span class="component-title">Freeleech</span>
<span class="component-desc">
<input type="checkbox" name="${curTorrentProvider.getID()}_freeleech" id="${curTorrentProvider.getID()}_freeleech" <%= html_checked if curTorrentProvider.freeleech else '' %>/>
<input type="checkbox" name="${curTorrentProvider.get_id()}_freeleech" id="${curTorrentProvider.get_id()}_freeleech" <%= html_checked if curTorrentProvider.freeleech else '' %>/>
<p>only download <b>[FreeLeech]</b> torrents.</p>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'enable_recentsearch'):
#if $hasattr($curTorrentProvider, 'enable_recentsearch') and $curTorrentProvider.supportsBacklog:
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_enable_recentsearch">
<label for="${curTorrentProvider.get_id()}_enable_recentsearch">
<span class="component-title">Enable recent searches</span>
<span class="component-desc">
<input type="checkbox" name="${curTorrentProvider.getID()}_enable_recentsearch" id="${curTorrentProvider.getID()}_enable_recentsearch" <%= html_checked if curTorrentProvider.enable_recentsearch else '' %>/>
<input type="checkbox" name="${curTorrentProvider.get_id()}_enable_recentsearch" id="${curTorrentProvider.get_id()}_enable_recentsearch" <%= html_checked if curTorrentProvider.enable_recentsearch else '' %>/>
<p>enable provider to perform recent searches.</p>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'enable_backlog'):
#if $hasattr($curTorrentProvider, 'enable_backlog') and $curTorrentProvider.supportsBacklog:
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_enable_backlog">
<label for="${curTorrentProvider.get_id()}_enable_backlog">
<span class="component-title">Enable backlog searches</span>
<span class="component-desc">
<input type="checkbox" name="${curTorrentProvider.getID()}_enable_backlog" id="${curTorrentProvider.getID()}_enable_backlog" <%= html_checked if curTorrentProvider.enable_backlog else '' %>/>
<input type="checkbox" name="${curTorrentProvider.get_id()}_enable_backlog" id="${curTorrentProvider.get_id()}_enable_backlog" <%= html_checked if curTorrentProvider.enable_backlog else '' %>/>
<p>enable provider to perform backlog searches.</p>
</span>
</label>
</div>
#end if
#if $hasattr($curTorrentProvider, 'search_fallback'):
#if $hasattr($curTorrentProvider, 'search_mode') and $curTorrentProvider.supportsBacklog:
<div class="field-pair">
<label for="${curTorrentProvider.getID()}_search_fallback">
<span class="component-title">Season search fallback</span>
<span class="component-desc">
<input type="checkbox" name="${curTorrentProvider.getID()}_search_fallback" id="${curTorrentProvider.getID()}_search_fallback" <%= html_checked if curTorrentProvider.search_fallback else '' %>/>
<p>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.</p>
</span>
</label>
<span class="component-title">Season search mode</span>
<span class="component-desc">
<label class="space-right">
<input type="radio" name="${curTorrentProvider.get_id()}_search_mode" id="${curTorrentProvider.get_id()}_search_mode_sponly" value="sponly" <%= html_checked if 'sponly' == curTorrentProvider.search_mode else '' %>/>season packs only
</label>
<label>
<input type="radio" name="${curTorrentProvider.get_id()}_search_mode" id="${curTorrentProvider.get_id()}_search_mode_eponly" value="eponly" <%= html_checked if 'eponly' == curTorrentProvider.search_mode else '' %>/>episodes only
</label>
<p>when searching for complete seasons, search for packs or collect single episodes</p>
</span>
</div>
#end if
#if $hasattr($curTorrentProvider, 'search_mode'):
#if $hasattr($curTorrentProvider, 'search_fallback') and $curTorrentProvider.supportsBacklog:
<div class="field-pair">
<label>
<span class="component-title">Season search mode</span>
<label for="${curTorrentProvider.get_id()}_search_fallback">
<span class="component-title">Season search fallback</span>
<span class="component-desc">
<p>when searching for complete seasons you can choose to have it look for season packs only, or choose to have it build a complete season from just single episodes.</p>
</span>
</label>
<label>
<span class="component-title"></span>
<span class="component-desc">
<input type="radio" name="${curTorrentProvider.getID()}_search_mode" id="${curTorrentProvider.getID()}_search_mode_sponly" value="sponly" <%= html_checked if 'sponly' == curTorrentProvider.search_mode else '' %>/>season packs only.
</span>
</label>
<label>
<span class="component-title"></span>
<span class="component-desc">
<input type="radio" name="${curTorrentProvider.getID()}_search_mode" id="${curTorrentProvider.getID()}_search_mode_eponly" value="eponly" <%= html_checked if 'eponly' == curTorrentProvider.search_mode else '' %>/>episodes only.
<input type="checkbox" name="${curTorrentProvider.get_id()}_search_fallback" id="${curTorrentProvider.get_id()}_search_fallback" <%= html_checked if curTorrentProvider.search_fallback else '' %>/>
<p>run the alternate season search mode when a complete season is not found</p>
</span>
</label>
</div>

View file

@ -139,9 +139,9 @@
#else
#if 0 < $hItem['provider']
#if $curStatus in [SNATCHED, FAILED]
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($hItem['provider']))
#set $provider = $providers.getProviderClass($generic.GenericProvider.make_id($hItem['provider']))
#if None is not $provider
<img src="$sbRoot/images/providers/<%= provider.imageName() %>" width="16" height="16" /><span>$provider.name</span>
<img src="$sbRoot/images/providers/<%= provider.image_name() %>" width="16" height="16" /><span>$provider.name</span>
#else
<img src="$sbRoot/images/providers/missing.png" width="16" height="16" title="missing provider" /><span>Missing Provider</span>
#end if
@ -186,10 +186,10 @@
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($action['action']))
#set $basename = $os.path.basename($action['resource'])
#if $curStatus in [SNATCHED, FAILED]
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($action['provider']))
#set $provider = $providers.getProviderClass($generic.GenericProvider.make_id($action['provider']))
#if None is not $provider
#set $prov_list += ['<span%s><img class="help" src="%s/images/providers/%s" width="16" height="16" alt="%s" title="%s.. %s: %s" /></span>'\
% (('', ' class="fail"')[FAILED == $curStatus], $sbRoot, $provider.imageName(), $provider.name,
% (('', ' class="fail"')[FAILED == $curStatus], $sbRoot, $provider.image_name(), $provider.name,
('%s%s' % ($order, 'th' if $order in [11, 12, 13] or str($order)[-1] not in $ordinal_indicators else $ordinal_indicators[str($order)[-1]]), 'Snatch failed')[FAILED == $curStatus],
$provider.name, $basename)]
#set $order += (0, 1)[SNATCHED == $curStatus]

View file

@ -72,9 +72,9 @@
<tr>
<td class="text-nowrap text-left">#echo re.sub('"', '', $hItem['release'])#</td>
<td>#echo ($hItem['size'], '?')[-1 == $hItem['size']]#</td>
#set $provider = $providers.getProviderClass($generic.GenericProvider.makeID($hItem['provider']))
#set $provider = $providers.getProviderClass($generic.GenericProvider.make_id($hItem['provider']))
#if None is not $provider:
<td><img src="$sbRoot/images/providers/<%= provider.imageName() %>" width="16" height="16" alt="$provider.name" title="$provider.name" /></td>
<td><img src="$sbRoot/images/providers/<%= provider.image_name() %>" width="16" height="16" alt="$provider.name" title="$provider.name" /></td>
#else
<td><img src="$sbRoot/images/providers/missing.png" width="16" height="16" alt="missing provider" title="missing provider" /></td>
#end if

View file

@ -31,7 +31,6 @@ import sys
import os.path
import uuid
import base64
import sickbeard
sys.path.insert(1, os.path.abspath('../lib'))
from sickbeard import providers, metadata, config, webserveInit
from sickbeard.providers.generic import GenericProvider
@ -255,10 +254,6 @@ OMGWTFNZBS = False
OMGWTFNZBS_USERNAME = None
OMGWTFNZBS_APIKEY = None
NEWZBIN = False
NEWZBIN_USERNAME = None
NEWZBIN_PASSWORD = None
SAB_USERNAME = None
SAB_PASSWORD = None
SAB_APIKEY = None
@ -485,10 +480,12 @@ COOKIE_SECRET = base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes)
__INITIALIZED__ = False
def get_backlog_cycle_time():
cycletime = RECENTSEARCH_FREQUENCY * 2 + 7
return max([cycletime, 720])
def initialize(consoleLogging=True):
with INIT_LOCK:
@ -525,7 +522,7 @@ def initialize(consoleLogging=True):
USE_SYNOLOGYNOTIFIER, SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH, SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD, SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD, \
USE_EMAIL, EMAIL_HOST, EMAIL_PORT, EMAIL_TLS, EMAIL_USER, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_NOTIFY_ONSNATCH, EMAIL_NOTIFY_ONDOWNLOAD, EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD, EMAIL_LIST, \
USE_LISTVIEW, METADATA_XBMC, METADATA_XBMC_12PLUS, METADATA_MEDIABROWSER, METADATA_PS3, METADATA_KODI, metadata_provider_dict, \
NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, POSTPONE_IF_SYNC_FILES, recentSearchScheduler, NFO_RENAME, \
GIT_PATH, MOVE_ASSOCIATED_FILES, POSTPONE_IF_SYNC_FILES, recentSearchScheduler, NFO_RENAME, \
GUI_NAME, DEFAULT_HOME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, EPISODE_VIEW_LAYOUT, EPISODE_VIEW_SORT, EPISODE_VIEW_DISPLAY_PAUSED, EPISODE_VIEW_MISSED_RANGE, FUZZY_DATING, TRIM_ZERO, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, THEME_NAME, \
POSTER_SORTBY, POSTER_SORTDIR, \
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, REQUIRE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \
@ -542,7 +539,6 @@ def initialize(consoleLogging=True):
CheckSection(CFG, 'General')
CheckSection(CFG, 'Blackhole')
CheckSection(CFG, 'Newzbin')
CheckSection(CFG, 'SABnzbd')
CheckSection(CFG, 'NZBget')
CheckSection(CFG, 'XBMC')
@ -587,7 +583,7 @@ def initialize(consoleLogging=True):
CACHE_DIR = ACTUAL_CACHE_DIR
if not helpers.makeDir(CACHE_DIR):
logger.log(u"!!! Creating local cache dir failed, using system default", logger.ERROR)
logger.log(u'!!! Creating local cache dir failed, using system default', logger.ERROR)
CACHE_DIR = None
# clean cache folders
@ -604,7 +600,7 @@ def initialize(consoleLogging=True):
TRIM_ZERO = bool(check_setting_int(CFG, 'GUI', 'trim_zero', 0))
DATE_PRESET = check_setting_str(CFG, 'GUI', 'date_preset', '%x')
TIME_PRESET_W_SECONDS = check_setting_str(CFG, 'GUI', 'time_preset', '%I:%M:%S %p')
TIME_PRESET = TIME_PRESET_W_SECONDS.replace(u":%S", u"")
TIME_PRESET = TIME_PRESET_W_SECONDS.replace(u':%S', u'')
TIMEZONE_DISPLAY = check_setting_str(CFG, 'GUI', 'timezone_display', 'network')
DISPLAY_BACKGROUND = bool(check_setting_int(CFG, 'General', 'display_background', 0))
DISPLAY_BACKGROUND_TRANSPARENT = check_setting_str(CFG, 'General', 'display_background_transparent', 'transparent')
@ -618,7 +614,7 @@ def initialize(consoleLogging=True):
LOG_DIR = os.path.normpath(os.path.join(DATA_DIR, ACTUAL_LOG_DIR))
if not helpers.makeDir(LOG_DIR):
logger.log(u"!!! No log folder, logging to screen only!", logger.ERROR)
logger.log(u'!!! No log folder, logging to screen only!', logger.ERROR)
FILE_LOGGING_PRESET = check_setting_str(CFG, 'General', 'file_logging_preset', 'DB')
@ -635,7 +631,7 @@ def initialize(consoleLogging=True):
WEB_HOST = check_setting_str(CFG, 'General', 'web_host', '0.0.0.0')
WEB_IPV6 = bool(check_setting_int(CFG, 'General', 'web_ipv6', 0))
WEB_ROOT = check_setting_str(CFG, 'General', 'web_root', '').rstrip("/")
WEB_ROOT = check_setting_str(CFG, 'General', 'web_root', '').rstrip('/')
WEB_LOG = bool(check_setting_int(CFG, 'General', 'web_log', 0))
ENCRYPTION_VERSION = check_setting_int(CFG, 'General', 'encryption_version', 0)
WEB_USERNAME = check_setting_str(CFG, 'General', 'web_username', '')
@ -767,10 +763,6 @@ def initialize(consoleLogging=True):
NZBS_UID = check_setting_str(CFG, 'NZBs', 'nzbs_uid', '')
NZBS_HASH = check_setting_str(CFG, 'NZBs', 'nzbs_hash', '')
NEWZBIN = bool(check_setting_int(CFG, 'Newzbin', 'newzbin', 0))
NEWZBIN_USERNAME = check_setting_str(CFG, 'Newzbin', 'newzbin_username', '')
NEWZBIN_PASSWORD = check_setting_str(CFG, 'Newzbin', 'newzbin_password', '')
SAB_USERNAME = check_setting_str(CFG, 'SABnzbd', 'sab_username', '')
SAB_PASSWORD = check_setting_str(CFG, 'SABnzbd', 'sab_password', '')
SAB_APIKEY = check_setting_str(CFG, 'SABnzbd', 'sab_apikey', '')
@ -840,7 +832,7 @@ def initialize(consoleLogging=True):
PROWL_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Prowl', 'prowl_notify_ondownload', 0))
PROWL_NOTIFY_ONSUBTITLEDOWNLOAD = bool(check_setting_int(CFG, 'Prowl', 'prowl_notify_onsubtitledownload', 0))
PROWL_API = check_setting_str(CFG, 'Prowl', 'prowl_api', '')
PROWL_PRIORITY = check_setting_str(CFG, 'Prowl', 'prowl_priority', "0")
PROWL_PRIORITY = check_setting_str(CFG, 'Prowl', 'prowl_priority', '0')
USE_TWITTER = bool(check_setting_int(CFG, 'Twitter', 'use_twitter', 0))
TWITTER_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Twitter', 'twitter_notify_onsnatch', 0))
@ -924,7 +916,7 @@ def initialize(consoleLogging=True):
NMA_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'NMA', 'nma_notify_ondownload', 0))
NMA_NOTIFY_ONSUBTITLEDOWNLOAD = bool(check_setting_int(CFG, 'NMA', 'nma_notify_onsubtitledownload', 0))
NMA_API = check_setting_str(CFG, 'NMA', 'nma_api', '')
NMA_PRIORITY = check_setting_str(CFG, 'NMA', 'nma_priority', "0")
NMA_PRIORITY = check_setting_str(CFG, 'NMA', 'nma_priority', '0')
USE_PUSHALOT = bool(check_setting_int(CFG, 'Pushalot', 'use_pushalot', 0))
PUSHALOT_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Pushalot', 'pushalot_notify_onsnatch', 0))
@ -1019,119 +1011,91 @@ def initialize(consoleLogging=True):
torrentRssProviderList = providers.getTorrentRssProviderList(TORRENTRSS_DATA)
# dynamically load provider settings
for curTorrentProvider in [curProvider for curProvider in providers.sortedProviderList() if
curProvider.providerType == GenericProvider.TORRENT]:
curTorrentProvider.enabled = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID(), 0))
if hasattr(curTorrentProvider, 'api_key'):
curTorrentProvider.api_key = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_api_key', '')
if hasattr(curTorrentProvider, 'hash'):
curTorrentProvider.hash = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_hash', '')
if hasattr(curTorrentProvider, 'digest'):
curTorrentProvider.digest = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_digest', '')
if hasattr(curTorrentProvider, 'username'):
curTorrentProvider.username = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_username', '')
if hasattr(curTorrentProvider, 'password'):
curTorrentProvider.password = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_password', '')
if hasattr(curTorrentProvider, 'passkey'):
curTorrentProvider.passkey = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_passkey', '')
if hasattr(curTorrentProvider, 'proxy'):
curTorrentProvider.proxy.enabled = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_proxy', 0))
if hasattr(curTorrentProvider.proxy, 'url'):
curTorrentProvider.proxy.url = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_proxy_url', '')
if hasattr(curTorrentProvider, 'confirmed'):
curTorrentProvider.confirmed = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_confirmed', 0))
if hasattr(curTorrentProvider, 'options'):
curTorrentProvider.options = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_options', '')
if hasattr(curTorrentProvider, 'ratio'):
curTorrentProvider.ratio = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_ratio', '')
if hasattr(curTorrentProvider, 'minseed'):
curTorrentProvider.minseed = check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_minseed', 0)
if hasattr(curTorrentProvider, 'minleech'):
curTorrentProvider.minleech = check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_minleech', 0)
if hasattr(curTorrentProvider, 'freeleech'):
curTorrentProvider.freeleech = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_freeleech', 0))
if hasattr(curTorrentProvider, 'search_mode'):
curTorrentProvider.search_mode = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_search_mode',
'eponly')
if hasattr(curTorrentProvider, 'search_fallback'):
curTorrentProvider.search_fallback = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_search_fallback',
0))
for torrent_prov in [curProvider for curProvider in providers.sortedProviderList()
if GenericProvider.TORRENT == curProvider.providerType]:
prov_id = torrent_prov.get_id()
prov_id_uc = torrent_prov.get_id().upper()
torrent_prov.enabled = bool(check_setting_int(CFG, prov_id_uc, prov_id, 0))
if hasattr(torrent_prov, 'api_key'):
torrent_prov.api_key = check_setting_str(CFG, prov_id_uc, prov_id + '_api_key', '')
if hasattr(torrent_prov, 'hash'):
torrent_prov.hash = check_setting_str(CFG, prov_id_uc, prov_id + '_hash', '')
if hasattr(torrent_prov, 'digest'):
torrent_prov.digest = check_setting_str(CFG, prov_id_uc, prov_id + '_digest', '')
if hasattr(torrent_prov, 'username'):
torrent_prov.username = check_setting_str(CFG, prov_id_uc, prov_id + '_username', '')
if hasattr(torrent_prov, 'password'):
torrent_prov.password = check_setting_str(CFG, prov_id_uc, prov_id + '_password', '')
if hasattr(torrent_prov, 'passkey'):
torrent_prov.passkey = check_setting_str(CFG, prov_id_uc, prov_id + '_passkey', '')
if hasattr(torrent_prov, 'proxy'):
torrent_prov.proxy.enabled = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_proxy', 0))
if hasattr(torrent_prov.proxy, 'url'):
torrent_prov.proxy.url = check_setting_str(CFG, prov_id_uc, prov_id + '_proxy_url', '')
if hasattr(torrent_prov, 'confirmed'):
torrent_prov.confirmed = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_confirmed', 0))
if hasattr(torrent_prov, 'options'):
torrent_prov.options = check_setting_str(CFG, prov_id_uc, prov_id + '_options', '')
if hasattr(torrent_prov, 'ratio'):
torrent_prov.ratio = check_setting_str(CFG, prov_id_uc, prov_id + '_ratio', '')
if hasattr(torrent_prov, 'minseed'):
torrent_prov.minseed = check_setting_int(CFG, prov_id_uc, prov_id + '_minseed', 0)
if hasattr(torrent_prov, 'minleech'):
torrent_prov.minleech = check_setting_int(CFG, prov_id_uc, prov_id + '_minleech', 0)
if hasattr(torrent_prov, 'freeleech'):
torrent_prov.freeleech = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_freeleech', 0))
if hasattr(torrent_prov, 'search_mode'):
torrent_prov.search_mode = check_setting_str(CFG, prov_id_uc, prov_id + '_search_mode', 'eponly')
if hasattr(torrent_prov, 'search_fallback'):
torrent_prov.search_fallback = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_search_fallback', 0))
if hasattr(torrent_prov, 'enable_recentsearch'):
torrent_prov.enable_recentsearch = bool(check_setting_int(CFG, prov_id_uc,
prov_id + '_enable_recentsearch', 1))
if hasattr(torrent_prov, 'enable_backlog'):
torrent_prov.enable_backlog = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_enable_backlog', 1))
if hasattr(curTorrentProvider, 'enable_recentsearch'):
curTorrentProvider.enable_recentsearch = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() +
'_enable_recentsearch', 1))
if hasattr(curTorrentProvider, 'enable_backlog'):
curTorrentProvider.enable_backlog = bool(check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_enable_backlog',
1))
for curNzbProvider in [curProvider for curProvider in providers.sortedProviderList() if
curProvider.providerType == GenericProvider.NZB]:
curNzbProvider.enabled = bool(
check_setting_int(CFG, curNzbProvider.getID().upper(), curNzbProvider.getID(), 0))
if hasattr(curNzbProvider, 'api_key'):
curNzbProvider.api_key = check_setting_str(CFG, curNzbProvider.getID().upper(),
curNzbProvider.getID() + '_api_key', '')
if hasattr(curNzbProvider, 'username'):
curNzbProvider.username = check_setting_str(CFG, curNzbProvider.getID().upper(),
curNzbProvider.getID() + '_username', '')
if hasattr(curNzbProvider, 'search_mode'):
curNzbProvider.search_mode = check_setting_str(CFG, curNzbProvider.getID().upper(),
curNzbProvider.getID() + '_search_mode',
'eponly')
if hasattr(curNzbProvider, 'search_fallback'):
curNzbProvider.search_fallback = bool(check_setting_int(CFG, curNzbProvider.getID().upper(),
curNzbProvider.getID() + '_search_fallback',
0))
if hasattr(curNzbProvider, 'enable_recentsearch'):
curNzbProvider.enable_recentsearch = bool(check_setting_int(CFG, curNzbProvider.getID().upper(),
curNzbProvider.getID() + '_enable_recentsearch',
1))
if hasattr(curNzbProvider, 'enable_backlog'):
curNzbProvider.enable_backlog = bool(check_setting_int(CFG, curNzbProvider.getID().upper(),
curNzbProvider.getID() + '_enable_backlog',
1))
for nzb_prov in [curProvider for curProvider in providers.sortedProviderList()
if GenericProvider.NZB == curProvider.providerType]:
prov_id = nzb_prov.get_id()
prov_id_uc = nzb_prov.get_id().upper()
nzb_prov.enabled = bool(
check_setting_int(CFG, prov_id_uc, prov_id, 0))
if hasattr(nzb_prov, 'api_key'):
nzb_prov.api_key = check_setting_str(CFG, prov_id_uc, prov_id + '_api_key', '')
if hasattr(nzb_prov, 'username'):
nzb_prov.username = check_setting_str(CFG, prov_id_uc, prov_id + '_username', '')
if hasattr(nzb_prov, 'search_mode'):
nzb_prov.search_mode = check_setting_str(CFG, prov_id_uc, prov_id + '_search_mode', 'eponly')
if hasattr(nzb_prov, 'search_fallback'):
nzb_prov.search_fallback = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_search_fallback', 0))
if hasattr(nzb_prov, 'enable_recentsearch'):
nzb_prov.enable_recentsearch = bool(check_setting_int(CFG, prov_id_uc,
prov_id + '_enable_recentsearch', 1))
if hasattr(nzb_prov, 'enable_backlog'):
nzb_prov.enable_backlog = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_enable_backlog', 1))
if not os.path.isfile(CONFIG_FILE):
logger.log(u"Unable to find '" + CONFIG_FILE + "', all settings will be default!", logger.DEBUG)
logger.log(u'Unable to find \'' + CONFIG_FILE + '\', all settings will be default!', logger.DEBUG)
save_config()
# start up all the threads
logger.sb_log_instance.initLogging(consoleLogging=consoleLogging)
# initialize the main SB database
myDB = db.DBConnection()
db.MigrationCode(myDB)
my_db = db.DBConnection()
db.MigrationCode(my_db)
# initialize the cache database
myDB = db.DBConnection('cache.db')
db.upgradeDatabase(myDB, cache_db.InitialSchema)
my_db = db.DBConnection('cache.db')
db.upgradeDatabase(my_db, cache_db.InitialSchema)
# initialize the failed downloads database
myDB = db.DBConnection('failed.db')
db.upgradeDatabase(myDB, failed_db.InitialSchema)
my_db = db.DBConnection('failed.db')
db.upgradeDatabase(my_db, failed_db.InitialSchema)
# fix up any db problems
myDB = db.DBConnection()
db.sanityCheckDatabase(myDB, mainDB.MainSanityCheck)
my_db = db.DBConnection()
db.sanityCheckDatabase(my_db, mainDB.MainSanityCheck)
# migrate the config if it needs it
migrator = ConfigMigrator(CFG)
@ -1147,7 +1111,7 @@ def initialize(consoleLogging=True):
(METADATA_TIVO, metadata.tivo),
(METADATA_MEDE8ER, metadata.mede8er),
(METADATA_KODI, metadata.kodi),
]:
]:
(cur_metadata_config, cur_metadata_class) = cur_metadata_tuple
tmp_provider = cur_metadata_class.metadata_class()
tmp_provider.set_config(cur_metadata_config)
@ -1169,7 +1133,7 @@ def initialize(consoleLogging=True):
cycleTime=datetime.timedelta(hours=1),
threadName='SHOWUPDATER',
start_time=datetime.time(hour=SHOW_UPDATE_HOUR),
prevent_cycle_run=sickbeard.showQueueScheduler.action.isShowUpdateRunning) # 3 AM
prevent_cycle_run=showQueueScheduler.action.isShowUpdateRunning) # 3 AM
# searchers
searchQueueScheduler = scheduler.Scheduler(search_queue.SearchQueue(),
@ -1178,18 +1142,18 @@ def initialize(consoleLogging=True):
update_interval = datetime.timedelta(minutes=RECENTSEARCH_FREQUENCY)
recentSearchScheduler = scheduler.Scheduler(searchRecent.RecentSearcher(),
cycleTime=update_interval,
threadName='RECENTSEARCHER',
run_delay=update_now if RECENTSEARCH_STARTUP
else datetime.timedelta(minutes=5),
prevent_cycle_run=sickbeard.searchQueueScheduler.action.is_recentsearch_in_progress)
cycleTime=update_interval,
threadName='RECENTSEARCHER',
run_delay=update_now if RECENTSEARCH_STARTUP
else datetime.timedelta(minutes=5),
prevent_cycle_run=searchQueueScheduler.action.is_recentsearch_in_progress)
backlogSearchScheduler = searchBacklog.BacklogSearchScheduler(searchBacklog.BacklogSearcher(),
cycleTime=datetime.timedelta(minutes=get_backlog_cycle_time()),
threadName='BACKLOG',
run_delay=update_now if BACKLOG_STARTUP
else datetime.timedelta(minutes=10),
prevent_cycle_run=sickbeard.searchQueueScheduler.action.is_standard_backlog_in_progress)
prevent_cycle_run=searchQueueScheduler.action.is_standard_backlog_in_progress)
search_intervals = {'15m': 15, '45m': 45, '90m': 90, '4h': 4 * 60, 'daily': 24 * 60}
if CHECK_PROPERS_INTERVAL in search_intervals:
@ -1204,7 +1168,7 @@ def initialize(consoleLogging=True):
threadName='FINDPROPERS',
start_time=run_at,
run_delay=update_interval,
prevent_cycle_run=sickbeard.searchQueueScheduler.action.is_propersearch_in_progress)
prevent_cycle_run=searchQueueScheduler.action.is_propersearch_in_progress)
# processors
autoPostProcesserScheduler = scheduler.Scheduler(autoPostProcesser.PostProcesser(),
@ -1290,52 +1254,52 @@ def halt():
if __INITIALIZED__:
logger.log(u"Aborting all threads")
logger.log(u'Aborting all threads')
events.stop.set()
logger.log(u"Waiting for the EVENTS thread to exit")
logger.log(u'Waiting for the EVENTS thread to exit')
try:
events.join(10)
except:
pass
recentSearchScheduler.stop.set()
logger.log(u"Waiting for the RECENTSEARCH thread to exit")
logger.log(u'Waiting for the RECENTSEARCH thread to exit')
try:
recentSearchScheduler.join(10)
except:
pass
backlogSearchScheduler.stop.set()
logger.log(u"Waiting for the BACKLOG thread to exit")
logger.log(u'Waiting for the BACKLOG thread to exit')
try:
backlogSearchScheduler.join(10)
except:
pass
showUpdateScheduler.stop.set()
logger.log(u"Waiting for the SHOWUPDATER thread to exit")
logger.log(u'Waiting for the SHOWUPDATER thread to exit')
try:
showUpdateScheduler.join(10)
except:
pass
versionCheckScheduler.stop.set()
logger.log(u"Waiting for the VERSIONCHECKER thread to exit")
logger.log(u'Waiting for the VERSIONCHECKER thread to exit')
try:
versionCheckScheduler.join(10)
except:
pass
showQueueScheduler.stop.set()
logger.log(u"Waiting for the SHOWQUEUE thread to exit")
logger.log(u'Waiting for the SHOWQUEUE thread to exit')
try:
showQueueScheduler.join(10)
except:
pass
searchQueueScheduler.stop.set()
logger.log(u"Waiting for the SEARCHQUEUE thread to exit")
logger.log(u'Waiting for the SEARCHQUEUE thread to exit')
try:
searchQueueScheduler.join(10)
except:
@ -1343,7 +1307,7 @@ def halt():
if PROCESS_AUTOMATICALLY:
autoPostProcesserScheduler.stop.set()
logger.log(u"Waiting for the POSTPROCESSER thread to exit")
logger.log(u'Waiting for the POSTPROCESSER thread to exit')
try:
autoPostProcesserScheduler.join(10)
except:
@ -1351,7 +1315,7 @@ def halt():
if USE_TRAKT:
traktCheckerScheduler.stop.set()
logger.log(u"Waiting for the TRAKTCHECKER thread to exit")
logger.log(u'Waiting for the TRAKTCHECKER thread to exit')
try:
traktCheckerScheduler.join(10)
except:
@ -1359,7 +1323,7 @@ def halt():
if DOWNLOAD_PROPERS:
properFinderScheduler.stop.set()
logger.log(u"Waiting for the PROPERFINDER thread to exit")
logger.log(u'Waiting for the PROPERFINDER thread to exit')
try:
properFinderScheduler.join(10)
except:
@ -1367,7 +1331,7 @@ def halt():
if USE_SUBTITLES:
subtitlesFinderScheduler.stop.set()
logger.log(u"Waiting for the SUBTITLESFINDER thread to exit")
logger.log(u'Waiting for the SUBTITLESFINDER thread to exit')
try:
subtitlesFinderScheduler.join(10)
except:
@ -1375,7 +1339,7 @@ def halt():
if ADBA_CONNECTION:
ADBA_CONNECTION.logout()
logger.log(u"Waiting for the ANIDB CONNECTION thread to exit")
logger.log(u'Waiting for the ANIDB CONNECTION thread to exit')
try:
ADBA_CONNECTION.join(10)
except:
@ -1387,7 +1351,7 @@ def halt():
def sig_handler(signum=None, frame=None):
if type(signum) != type(None):
logger.log(u"Signal %i caught, saving and exiting..." % int(signum))
logger.log(u'Signal %i caught, saving and exiting...' % int(signum))
events.put(events.SystemEvent.SHUTDOWN)
@ -1395,12 +1359,12 @@ def saveAll():
global showList
# write all shows
logger.log(u"Saving all shows to the database")
logger.log(u'Saving all shows to the database')
for show in showList:
show.saveToDB()
# save config
logger.log(u"Saving config file to disk")
logger.log(u'Saving config file to disk')
save_config()
@ -1408,7 +1372,7 @@ def restart(soft=True):
if soft:
halt()
saveAll()
logger.log(u"Re-initializing all data")
logger.log(u'Re-initializing all data')
initialize()
else:
events.put(events.SystemEvent.RESTART)
@ -1517,7 +1481,7 @@ def save_config():
new_config['General']['keep_processed_dir'] = int(KEEP_PROCESSED_DIR)
new_config['General']['process_method'] = PROCESS_METHOD
new_config['General']['move_associated_files'] = int(MOVE_ASSOCIATED_FILES)
new_config['General']['postpone_if_sync_files'] = int (POSTPONE_IF_SYNC_FILES)
new_config['General']['postpone_if_sync_files'] = int(POSTPONE_IF_SYNC_FILES)
new_config['General']['nfo_rename'] = int(NFO_RENAME)
new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
new_config['General']['unpack'] = int(UNPACK)
@ -1537,99 +1501,74 @@ def save_config():
new_config['Blackhole']['torrent_dir'] = TORRENT_DIR
# dynamically save provider settings
for curTorrentProvider in [curProvider for curProvider in providers.sortedProviderList() if
curProvider.providerType == GenericProvider.TORRENT]:
new_config[curTorrentProvider.getID().upper()] = {}
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID()] = int(curTorrentProvider.enabled)
if hasattr(curTorrentProvider, 'digest'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_digest'] = curTorrentProvider.digest
if hasattr(curTorrentProvider, 'hash'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_hash'] = curTorrentProvider.hash
if hasattr(curTorrentProvider, 'api_key'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_api_key'] = curTorrentProvider.api_key
if hasattr(curTorrentProvider, 'username'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_username'] = curTorrentProvider.username
if hasattr(curTorrentProvider, 'password'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_password'] = helpers.encrypt(
curTorrentProvider.password, ENCRYPTION_VERSION)
if hasattr(curTorrentProvider, 'passkey'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_passkey'] = curTorrentProvider.passkey
if hasattr(curTorrentProvider, 'confirmed'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_confirmed'] = int(
curTorrentProvider.confirmed)
if hasattr(curTorrentProvider, 'ratio'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_ratio'] = curTorrentProvider.ratio
if hasattr(curTorrentProvider, 'minseed'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_minseed'] = int(
curTorrentProvider.minseed)
if hasattr(curTorrentProvider, 'minleech'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_minleech'] = int(
curTorrentProvider.minleech)
if hasattr(curTorrentProvider, 'options'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_options'] = curTorrentProvider.options
if hasattr(curTorrentProvider, 'proxy'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_proxy'] = int(
curTorrentProvider.proxy.enabled)
if hasattr(curTorrentProvider.proxy, 'url'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_proxy_url'] = curTorrentProvider.proxy.url
if hasattr(curTorrentProvider, 'freeleech'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_freeleech'] = int(
curTorrentProvider.freeleech)
if hasattr(curTorrentProvider, 'search_mode'):
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_search_mode'] = curTorrentProvider.search_mode
if hasattr(curTorrentProvider, 'search_fallback'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_search_fallback'] = int(
curTorrentProvider.search_fallback)
if hasattr(curTorrentProvider, 'enable_recentsearch'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_enable_recentsearch'] = int(
curTorrentProvider.enable_recentsearch)
if hasattr(curTorrentProvider, 'enable_backlog'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_enable_backlog'] = int(
curTorrentProvider.enable_backlog)
for torrent_prov in [curProvider for curProvider in providers.sortedProviderList()
if GenericProvider.TORRENT == curProvider.providerType]:
prov_id = torrent_prov.get_id()
prov_id_uc = torrent_prov.get_id().upper()
new_config[prov_id_uc] = {}
new_config[prov_id_uc][prov_id] = int(torrent_prov.enabled)
if hasattr(torrent_prov, 'digest'):
new_config[prov_id_uc][prov_id + '_digest'] = torrent_prov.digest
if hasattr(torrent_prov, 'hash'):
new_config[prov_id_uc][prov_id + '_hash'] = torrent_prov.hash
if hasattr(torrent_prov, 'api_key'):
new_config[prov_id_uc][prov_id + '_api_key'] = torrent_prov.api_key
if hasattr(torrent_prov, 'username'):
new_config[prov_id_uc][prov_id + '_username'] = torrent_prov.username
if hasattr(torrent_prov, 'password'):
new_config[prov_id_uc][prov_id + '_password'] = helpers.encrypt(torrent_prov.password, ENCRYPTION_VERSION)
if hasattr(torrent_prov, 'passkey'):
new_config[prov_id_uc][prov_id + '_passkey'] = torrent_prov.passkey
if hasattr(torrent_prov, 'confirmed'):
new_config[prov_id_uc][prov_id + '_confirmed'] = int(torrent_prov.confirmed)
if hasattr(torrent_prov, 'ratio'):
new_config[prov_id_uc][prov_id + '_ratio'] = torrent_prov.ratio
if hasattr(torrent_prov, 'minseed'):
new_config[prov_id_uc][prov_id + '_minseed'] = int(torrent_prov.minseed)
if hasattr(torrent_prov, 'minleech'):
new_config[prov_id_uc][prov_id + '_minleech'] = int(torrent_prov.minleech)
if hasattr(torrent_prov, 'options'):
new_config[prov_id_uc][prov_id + '_options'] = torrent_prov.options
if hasattr(torrent_prov, 'proxy'):
new_config[prov_id_uc][prov_id + '_proxy'] = int(torrent_prov.proxy.enabled)
if hasattr(torrent_prov.proxy, 'url'):
new_config[prov_id_uc][prov_id + '_proxy_url'] = torrent_prov.proxy.url
if hasattr(torrent_prov, 'freeleech'):
new_config[prov_id_uc][prov_id + '_freeleech'] = int(torrent_prov.freeleech)
if hasattr(torrent_prov, 'search_mode'):
new_config[prov_id_uc][prov_id + '_search_mode'] = torrent_prov.search_mode
if hasattr(torrent_prov, 'search_fallback'):
new_config[prov_id_uc][prov_id + '_search_fallback'] = int(torrent_prov.search_fallback)
if hasattr(torrent_prov, 'enable_recentsearch'):
new_config[prov_id_uc][prov_id + '_enable_recentsearch'] = int(torrent_prov.enable_recentsearch)
if hasattr(torrent_prov, 'enable_backlog'):
new_config[prov_id_uc][prov_id + '_enable_backlog'] = int(torrent_prov.enable_backlog)
for curNzbProvider in [curProvider for curProvider in providers.sortedProviderList() if
curProvider.providerType == GenericProvider.NZB]:
new_config[curNzbProvider.getID().upper()] = {}
new_config[curNzbProvider.getID().upper()][curNzbProvider.getID()] = int(curNzbProvider.enabled)
for nzb_prov in [curProvider for curProvider in providers.sortedProviderList()
if GenericProvider.NZB == curProvider.providerType]:
prov_id = nzb_prov.get_id()
prov_id_uc = nzb_prov.get_id().upper()
new_config[prov_id_uc] = {}
new_config[prov_id_uc][prov_id] = int(nzb_prov.enabled)
if hasattr(curNzbProvider, 'api_key'):
new_config[curNzbProvider.getID().upper()][
curNzbProvider.getID() + '_api_key'] = curNzbProvider.api_key
if hasattr(curNzbProvider, 'username'):
new_config[curNzbProvider.getID().upper()][
curNzbProvider.getID() + '_username'] = curNzbProvider.username
if hasattr(curNzbProvider, 'search_mode'):
new_config[curNzbProvider.getID().upper()][
curNzbProvider.getID() + '_search_mode'] = curNzbProvider.search_mode
if hasattr(curNzbProvider, 'search_fallback'):
new_config[curNzbProvider.getID().upper()][curNzbProvider.getID() + '_search_fallback'] = int(
curNzbProvider.search_fallback)
if hasattr(curNzbProvider, 'enable_recentsearch'):
new_config[curNzbProvider.getID().upper()][curNzbProvider.getID() + '_enable_recentsearch'] = int(
curNzbProvider.enable_recentsearch)
if hasattr(curNzbProvider, 'enable_backlog'):
new_config[curNzbProvider.getID().upper()][curNzbProvider.getID() + '_enable_backlog'] = int(
curNzbProvider.enable_backlog)
if hasattr(nzb_prov, 'api_key'):
new_config[prov_id_uc][prov_id + '_api_key'] = nzb_prov.api_key
if hasattr(nzb_prov, 'username'):
new_config[prov_id_uc][prov_id + '_username'] = nzb_prov.username
if hasattr(nzb_prov, 'search_mode'):
new_config[prov_id_uc][prov_id + '_search_mode'] = nzb_prov.search_mode
if hasattr(nzb_prov, 'search_fallback'):
new_config[prov_id_uc][prov_id + '_search_fallback'] = int(nzb_prov.search_fallback)
if hasattr(nzb_prov, 'enable_recentsearch'):
new_config[prov_id_uc][prov_id + '_enable_recentsearch'] = int(nzb_prov.enable_recentsearch)
if hasattr(nzb_prov, 'enable_backlog'):
new_config[prov_id_uc][prov_id + '_enable_backlog'] = int(nzb_prov.enable_backlog)
new_config['NZBs'] = {}
new_config['NZBs']['nzbs'] = int(NZBS)
new_config['NZBs']['nzbs_uid'] = NZBS_UID
new_config['NZBs']['nzbs_hash'] = NZBS_HASH
new_config['Newzbin'] = {}
new_config['Newzbin']['newzbin'] = int(NEWZBIN)
new_config['Newzbin']['newzbin_username'] = NEWZBIN_USERNAME
new_config['Newzbin']['newzbin_password'] = helpers.encrypt(NEWZBIN_PASSWORD, ENCRYPTION_VERSION)
new_config['SABnzbd'] = {}
new_config['SABnzbd']['sab_username'] = SAB_USERNAME
new_config['SABnzbd']['sab_password'] = helpers.encrypt(SAB_PASSWORD, ENCRYPTION_VERSION)
@ -1881,41 +1820,41 @@ def save_config():
new_config.write()
def launchBrowser(startPort=None):
if not startPort:
startPort = WEB_PORT
def launchBrowser(start_port=None):
if not start_port:
start_port = WEB_PORT
if ENABLE_HTTPS:
browserURL = 'https://localhost:%d%s' % (startPort, WEB_ROOT)
browser_url = 'https://localhost:%d%s' % (start_port, WEB_ROOT)
else:
browserURL = 'http://localhost:%d%s' % (startPort, WEB_ROOT)
browser_url = 'http://localhost:%d%s' % (start_port, WEB_ROOT)
try:
webbrowser.open(browserURL, 2, 1)
webbrowser.open(browser_url, 2, 1)
except:
try:
webbrowser.open(browserURL, 1, 1)
webbrowser.open(browser_url, 1, 1)
except:
logger.log(u"Unable to launch a browser", logger.ERROR)
logger.log(u'Unable to launch a browser', logger.ERROR)
def getEpList(epIDs, showid=None):
if epIDs == None or len(epIDs) == 0:
def getEpList(ep_ids, showid=None):
if None is ep_ids or 0 == len(ep_ids):
return []
query = "SELECT * FROM tv_episodes WHERE indexerid in (%s)" % (",".join(['?'] * len(epIDs)),)
params = epIDs
query = 'SELECT * FROM tv_episodes WHERE indexerid in (%s)' % (','.join(['?'] * len(ep_ids)),)
params = ep_ids
if showid != None:
query += " AND showid = ?"
if None is not showid:
query += ' AND showid = ?'
params.append(showid)
myDB = db.DBConnection()
sqlResults = myDB.select(query, params)
my_db = db.DBConnection()
sql_results = my_db.select(query, params)
epList = []
ep_list = []
for curEp in sqlResults:
curShowObj = helpers.findCertainShow(showList, int(curEp["showid"]))
curEpObj = curShowObj.getEpisode(int(curEp["season"]), int(curEp["episode"]))
epList.append(curEpObj)
for curEp in sql_results:
cur_show_obj = helpers.findCertainShow(showList, int(curEp['showid']))
cur_ep_obj = cur_show_obj.getEpisode(int(curEp['season']), int(curEp['episode']))
ep_list.append(cur_ep_obj)
return epList
return ep_list

View file

@ -168,7 +168,7 @@ class GenericClient(object):
try:
# Sets per provider seed ratio
result.ratio = result.provider.seedRatio()
result.ratio = result.provider.seed_ratio()
result = self._get_torrent_hash(result)

View file

@ -721,7 +721,7 @@ class ConfigMigrator():
for curProvider in providers.sortedProviderList():
if hasattr(curProvider, 'enable_recentsearch'):
curProvider.enable_recentsearch = bool(check_setting_int(
self.config_obj, curProvider.getID().upper(), curProvider.getID() + '_enable_dailysearch', 1))
self.config_obj, curProvider.get_id().upper(), curProvider.get_id() + '_enable_dailysearch', 1))
def _migrate_v7(self):
sickbeard.EPISODE_VIEW_LAYOUT = check_setting_str(self.config_obj, 'GUI', 'coming_eps_layout', 'banner')

View file

@ -100,10 +100,6 @@ class EpisodeNotFoundException(SickBeardException):
"The episode wasn't found on the Indexer"
class NewzbinAPIThrottled(SickBeardException):
"Newzbin has throttled us, deal with it"
class ShowDirNotFoundException(SickBeardException):
"The show dir doesn't exist"

View file

@ -1400,7 +1400,7 @@ def check_port(host, port, timeout=1.0):
def clear_unused_providers():
providers = [x.cache.providerID for x in sickbeard.providers.sortedProviderList() if x.isActive()]
providers = [x.cache.providerID for x in sickbeard.providers.sortedProviderList() if x.is_active()]
if providers:
myDB = db.DBConnection('cache.db')

View file

@ -104,7 +104,7 @@ def sendNZB(nzb, proper=False):
else:
if nzb.resultType == "nzb":
genProvider = GenericProvider("")
data = genProvider.getURL(nzb.url)
data = genProvider.get_url(nzb.url)
if (data == None):
return False
nzbcontent64 = standard_b64encode(data)

View file

@ -66,14 +66,14 @@ def _getProperList():
# for each provider get a list of the
origThreadName = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
providers = [x for x in sickbeard.providers.sortedProviderList() if x.is_active()]
for curProvider in providers:
threading.currentThread().name = origThreadName + ' :: [' + curProvider.name + ']'
logger.log(u'Searching for any new PROPER releases from ' + curProvider.name)
try:
curPropers = curProvider.findPropers(search_date)
curPropers = curProvider.find_propers(search_date)
except exceptions.AuthException as e:
logger.log(u'Authentication error: ' + ex(e), logger.ERROR)
continue
@ -243,8 +243,9 @@ def _downloadPropers(properList):
epObj = showObj.getEpisode(curProper.season, curProper.episode)
# make the result object
result = curProper.provider.getResult([epObj])
result.url = curProper.url
result = curProper.provider.get_result([epObj], curProper.url)
if None is result:
continue
result.name = curProper.name
result.quality = curProper.quality
result.version = curProper.version

View file

@ -53,7 +53,7 @@ from sickbeard import logger
def sortedProviderList():
initialList = sickbeard.providerList + sickbeard.newznabProviderList + sickbeard.torrentRssProviderList
providerDict = dict(zip([x.getID() for x in initialList], initialList))
providerDict = dict(zip([x.get_id() for x in initialList], initialList))
newList = []
@ -207,7 +207,7 @@ def getProviderModule(name):
def getProviderClass(id):
providerMatch = [x for x in
sickbeard.providerList + sickbeard.newznabProviderList + sickbeard.torrentRssProviderList if
x.getID() == id]
x.get_id() == id]
if len(providerMatch) != 1:
return None

View file

@ -47,13 +47,13 @@ class AlphaRatioProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = AlphaRatioCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'session' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'keeplogged': '1', 'login': 'Login'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -66,10 +66,10 @@ class AlphaRatioProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -82,7 +82,7 @@ class AlphaRatioProvider(generic.TorrentProvider):
search_string = unidecode(search_string)
search_url = self.urls['search'] % search_string
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -124,7 +124,7 @@ class AlphaRatioProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -16,73 +16,67 @@
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import urllib
import datetime
import urllib
import generic
from . import generic
from sickbeard import classes, show_name_helpers, logger, tvcache
class animenzb(generic.NZBProvider):
class AnimeNZBProvider(generic.NZBProvider):
def __init__(self):
generic.NZBProvider.__init__(self, 'animenzb', True, True)
self.cache = animenzbCache(self)
generic.NZBProvider.__init__(self, 'AnimeNZB', anime_only=True)
self.url = 'http://animenzb.com/'
self.cache = AnimeNZBCache(self)
def _get_season_search_strings(self, ep_obj):
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
def _get_episode_search_strings(self, ep_obj, add_string=''):
return [x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
def _doSearch(self, search_string, search_mode='eponly', epcount=0, age=0):
if self.show and not self.show.is_anime:
logger.log(u'%s is not an anime skipping ...' % self.show.name)
return []
def _do_search(self, search_string, search_mode='eponly', epcount=0, age=0):
params = {
'cat': 'anime',
'q': search_string.encode('utf-8'),
'max': '100'
}
results = []
if self.show and not self.show.is_anime:
return results
params = {'cat': 'anime',
'q': search_string.encode('utf-8'),
'max': '100'}
search_url = self.url + 'rss?' + urllib.urlencode(params)
logger.log(u'Search url: %s' % search_url, logger.DEBUG)
data = self.cache.getRSSFeed(search_url)
if not data:
return []
if 'entries' in data:
if data and 'entries' in data:
items = data.entries
results = []
for curItem in items:
(title, url) = self._get_title_and_url(curItem)
if title and url:
results.append(curItem)
else:
logger.log(
u'The data returned from %s is incomplete, this result is unusable' % self.name,
logger.DEBUG)
logger.log(u'The data returned from %s is incomplete, this result is unusable' % self.name,
logger.DEBUG)
return results
return results
return []
def findPropers(self, date=None):
def find_propers(self, date=None):
results = []
for item in self._doSearch('v2|v3|v4|v5'):
for item in self._do_search('v2|v3|v4|v5'):
(title, url) = self._get_title_and_url(item)
if item.has_key('published_parsed') and item['published_parsed']:
if 'published_parsed' in item and item['published_parsed']:
result_date = item.published_parsed
if result_date:
result_date = datetime.datetime(*result_date[0:6])
@ -97,32 +91,25 @@ class animenzb(generic.NZBProvider):
return results
class animenzbCache(tvcache.TVCache):
class AnimeNZBCache(tvcache.TVCache):
def __init__(self, provider):
def __init__(self, this_provider):
tvcache.TVCache.__init__(self, this_provider)
tvcache.TVCache.__init__(self, provider)
self.minTime = 20
self.minTime = 20 # cache update frequency
def _getRSSData(self):
params = {
'cat': 'anime'.encode('utf-8'),
'max': '100'.encode('utf-8')
}
params = {'cat': 'anime'.encode('utf-8'),
'max': '100'.encode('utf-8')}
rss_url = self.provider.url + 'rss?' + urllib.urlencode(params)
logger.log(u'%s cache update URL: %s' % (self.provider.name, rss_url), logger.DEBUG)
data = self.getRSSFeed(rss_url)
if data and 'entries' in data:
return data.entries
else:
return []
return []
provider = animenzb()
provider = AnimeNZBProvider()

View file

@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import re
import datetime
import time
@ -52,10 +53,10 @@ class BeyondHDProvider(generic.TorrentProvider):
logger.log(u'Incorrect authentication credentials for %s : %s' % (self.name, data_json['error']), logger.DEBUG)
raise AuthException('Authentication credentials for %s are incorrect, check your config' % self.name)
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._checkAuth():
if not self._check_auth():
return results
for mode in search_params.keys():
@ -72,9 +73,9 @@ class BeyondHDProvider(generic.TorrentProvider):
search_url = self.urls['cache'] % (self.passkey, self.categories[mode])
if 'Cache' != mode:
search_url += self.urls['search'] % search_string
search_url += self.urls['search'] % re.sub('[\.\s]+', ' ', search_string)
data_json = self.getURL(search_url, json=True)
data_json = self.get_url(search_url, json=True)
cnt = len(results)
if data_json and 'results' in data_json and self._check_auth_from_data(data_json):
@ -97,7 +98,7 @@ class BeyondHDProvider(generic.TorrentProvider):
return generic.TorrentProvider._get_episode_search_strings(self, ep_obj, add_string, scene=False, use_or=False)
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date, ['proper', 'repack'])

View file

@ -43,13 +43,13 @@ class BitSoupProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = BitSoupCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'ssl': 'yes'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -62,10 +62,10 @@ class BitSoupProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -78,7 +78,7 @@ class BitSoupProvider(generic.TorrentProvider):
search_string = unidecode(search_string)
search_url = self.urls['search'] % (search_string, self.categories)
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -121,7 +121,7 @@ class BitSoupProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -43,7 +43,7 @@ class BTNProvider(generic.TorrentProvider):
def _check_auth_from_data(self, data_json):
if data_json is None:
return self._checkAuth()
return self._check_auth()
if 'api-error' not in data_json:
return True
@ -52,9 +52,9 @@ class BTNProvider(generic.TorrentProvider):
logger.DEBUG)
raise AuthException('Your authentication credentials for %s are incorrect, check your config.' % self.name)
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
self._checkAuth()
self._check_auth()
params = {}
@ -236,14 +236,14 @@ class BTNProvider(generic.TorrentProvider):
return to_return
def findPropers(self, search_date=None):
def find_propers(self, search_date=None):
results = []
search_terms = ['%.proper.%', '%.repack.%']
for term in search_terms:
for item in self._doSearch({'release': term}, age=4 * 24 * 60 * 60):
for item in self._do_search({'release': term}, age=4 * 24 * 60 * 60):
if item['Time']:
try:
result_date = datetime.datetime.fromtimestamp(float(item['Time']))
@ -273,7 +273,7 @@ class BTNProvider(generic.TorrentProvider):
% self.name, logger.WARNING)
seconds_since_last_update = 86400
return self._doSearch(search_params=None, age=seconds_since_last_update)
return self._do_search(search_params=None, age=seconds_since_last_update)
class BTNCache(tvcache.TVCache):

View file

@ -42,13 +42,13 @@ class FreshOnTVProvider(generic.TorrentProvider):
self.freeleech = False
self.cache = FreshOnTVCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'login': 'Do it!'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -64,10 +64,10 @@ class FreshOnTVProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -83,7 +83,7 @@ class FreshOnTVProvider(generic.TorrentProvider):
# returns top 15 results by default, expandable in user profile to 100
search_url = self.urls['search'] % (freeleech, search_string)
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -129,7 +129,7 @@ class FreshOnTVProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -28,6 +28,7 @@ from base64 import b16encode, b32decode
import sickbeard
import requests
import requests.cookies
from sickbeard import helpers, classes, logger, db, tvcache, encodingKludge as ek
from sickbeard.common import Quality, MULTI_EP_RESULT, SEASON_RESULT, USER_AGENT
from sickbeard.exceptions import SickBeardException, AuthException, ex
@ -42,8 +43,8 @@ class HaltParseException(SickBeardException):
class GenericProvider:
NZB = "nzb"
TORRENT = "torrent"
NZB = 'nzb'
TORRENT = 'torrent'
def __init__(self, name, supports_backlog=False, anime_only=False):
# these need to be set in the subclass
@ -67,85 +68,86 @@ class GenericProvider:
self.headers = {
# Using USER_AGENT instead of Mozilla to keep same user agent along authentication and download phases,
#otherwise session might be broken and download fail, asking again for authentication
#'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'}
# otherwise session might be broken and download fail, asking again for authentication
# 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'}
'User-Agent': USER_AGENT}
def getID(self):
return GenericProvider.makeID(self.name)
def get_id(self):
return GenericProvider.make_id(self.name)
@staticmethod
def makeID(name):
return re.sub("[^\w\d_]", "_", name.strip().lower())
def make_id(name):
return re.sub('[^\w\d_]', '_', name.strip().lower())
def imageName(self, *default_name):
def image_name(self, *default_name):
for name in ['%s.%s' % (self.getID(), image_ext) for image_ext in ['png', 'gif', 'jpg']]:
for name in ['%s.%s' % (self.get_id(), image_ext) for image_ext in ['png', 'gif', 'jpg']]:
if ek.ek(os.path.isfile,
ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME, 'images', 'providers', name)):
return name
return '%s.png' % ('newznab', default_name[0])[any(default_name)]
def _checkAuth(self):
def _check_auth(self):
return True
def _doLogin(self):
def _do_login(self):
return True
def isActive(self):
if self.providerType == GenericProvider.NZB and sickbeard.USE_NZBS:
return self.isEnabled()
elif self.providerType == GenericProvider.TORRENT and sickbeard.USE_TORRENTS:
return self.isEnabled()
def is_active(self):
if GenericProvider.NZB == self.providerType and sickbeard.USE_NZBS:
return self.is_enabled()
elif GenericProvider.TORRENT == self.providerType and sickbeard.USE_TORRENTS:
return self.is_enabled()
else:
return False
def isEnabled(self):
def is_enabled(self):
"""
This should be overridden and should return the config setting eg. sickbeard.MYPROVIDER
"""
return self.enabled
def getResult(self, episodes):
def get_result(self, episodes, url):
"""
Returns a result of the correct type for this provider
"""
if self.providerType == GenericProvider.NZB:
if GenericProvider.NZB == self.providerType:
result = classes.NZBSearchResult(episodes)
elif self.providerType == GenericProvider.TORRENT:
elif GenericProvider.TORRENT == self.providerType:
result = classes.TorrentSearchResult(episodes)
else:
result = classes.SearchResult(episodes)
result.provider = self
result.url = url
return result
def getURL(self, url, post_data=None, params=None, timeout=30, json=False):
def get_url(self, url, post_data=None, params=None, timeout=30, json=False):
"""
By default this is just a simple urlopen call but this method should be overridden
for providers with special URL requirements (like cookies)
"""
# check for auth
if not self._doLogin():
if not self._do_login():
return
return helpers.getURL(url, post_data=post_data, params=params, headers=self.headers, timeout=timeout,
session=self.session, json=json)
def downloadResult(self, result):
def download_result(self, result):
"""
Save the result to disk.
"""
# check for auth
if not self._doLogin():
if not self._do_login():
return False
if self.providerType == GenericProvider.TORRENT:
if GenericProvider.TORRENT == self.providerType:
try:
torrent_hash = re.findall('urn:btih:([0-9a-f]{32,40})', result.url)[0].upper()
@ -153,7 +155,7 @@ class GenericProvider:
torrent_hash = b16encode(b32decode(torrent_hash)).lower()
if not torrent_hash:
logger.log("Unable to extract torrent hash from link: " + ex(result.url), logger.ERROR)
logger.log('Unable to extract torrent hash from link: ' + ex(result.url), logger.ERROR)
return False
urls = ['https://%s/%s.torrent' % (u, torrent_hash)
@ -163,7 +165,7 @@ class GenericProvider:
filename = ek.ek(os.path.join, sickbeard.TORRENT_DIR,
helpers.sanitizeFileName(result.name) + '.' + self.providerType)
elif self.providerType == GenericProvider.NZB:
elif GenericProvider.NZB == self.providerType:
urls = [result.url]
filename = ek.ek(os.path.join, sickbeard.NZB_DIR,
@ -173,19 +175,19 @@ class GenericProvider:
for url in urls:
if helpers.download_file(url, filename, session=self.session):
logger.log(u"Downloading a result from " + self.name + " at " + url)
logger.log(u'Downloading a result from ' + self.name + ' at ' + url)
if self.providerType == GenericProvider.TORRENT:
logger.log(u"Saved magnet link to " + filename, logger.MESSAGE)
if GenericProvider.TORRENT == self.providerType:
logger.log(u'Saved magnet link to ' + filename, logger.MESSAGE)
else:
logger.log(u"Saved result to " + filename, logger.MESSAGE)
logger.log(u'Saved result to ' + filename, logger.MESSAGE)
if self._verify_download(filename):
return True
elif ek.ek(os.path.isfile, filename):
ek.ek(os.remove, filename)
logger.log(u"Failed to download result", logger.ERROR)
logger.log(u'Failed to download result', logger.ERROR)
return False
def _verify_download(self, file_name=None):
@ -194,7 +196,7 @@ class GenericProvider:
"""
# primitive verification of torrents, just make sure we didn't get a text file or something
if self.providerType == GenericProvider.TORRENT:
if GenericProvider.TORRENT == self.providerType:
parser = createParser(file_name)
if parser:
mime_type = parser._getMimeType()
@ -202,18 +204,18 @@ class GenericProvider:
parser.stream._input.close()
except:
pass
if mime_type == 'application/x-bittorrent':
if 'application/x-bittorrent' == mime_type:
return True
logger.log(u"Result is not a valid torrent file", logger.WARNING)
logger.log(u'Result is not a valid torrent file', logger.WARNING)
return False
return True
def searchRSS(self, episodes):
def search_rss(self, episodes):
return self.cache.findNeededEpisodes(episodes)
def getQuality(self, item, anime=False):
def get_quality(self, item, anime=False):
"""
Figures out the quality of the given RSS item node
@ -225,13 +227,13 @@ class GenericProvider:
quality = Quality.sceneQuality(title, anime)
return quality
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
return []
def _get_season_search_strings(self, episode):
return []
def _get_episode_search_strings(self, eb_obj, add_string=''):
def _get_episode_search_strings(self, *args, **kwargs):
return []
def _get_title_and_url(self, item):
@ -259,223 +261,216 @@ class GenericProvider:
pass
if title:
title = re.sub(r'\s+', '.', u'' + title)
title = re.sub(r'\s+', '.', u'%s' % title)
if url:
url = url.replace('&amp;', '&')
url = str(url).replace('&amp;', '&')
return title, url
def findSearchResults(self, show, episodes, search_mode, manualSearch=False):
def find_search_results(self, show, episodes, search_mode, manual_search=False):
self._checkAuth()
self._check_auth()
self.show = show
results = {}
itemList = []
item_list = []
searched_scene_season = None
for epObj in episodes:
for ep_obj in episodes:
# search cache for episode result
cacheResult = self.cache.searchCache(epObj, manualSearch)
if cacheResult:
if epObj.episode not in results:
results[epObj.episode] = cacheResult
cache_result = self.cache.searchCache(ep_obj, manual_search)
if cache_result:
if ep_obj.episode not in results:
results[ep_obj.episode] = cache_result
else:
results[epObj.episode].extend(cacheResult)
results[ep_obj.episode].extend(cache_result)
# found result, search next episode
continue
# skip if season already searched
if len(episodes) > 1 and searched_scene_season == epObj.scene_season:
if 1 < len(episodes) and ep_obj.scene_season == searched_scene_season:
continue
# mark season searched for season pack searches so we can skip later on
searched_scene_season = epObj.scene_season
searched_scene_season = ep_obj.scene_season
if 'sponly' == search_mode:
# get season search results
for curString in self._get_season_search_strings(epObj):
itemList += self._doSearch(curString, search_mode, len(episodes))
for curString in self._get_season_search_strings(ep_obj):
item_list += self._do_search(curString, search_mode, len(episodes))
else:
# get single episode search results
for curString in self._get_episode_search_strings(epObj):
itemList += self._doSearch(curString, 'eponly', len(episodes))
for curString in self._get_episode_search_strings(ep_obj):
item_list += self._do_search(curString, 'eponly', len(episodes))
# if we found what we needed already from cache then return results and exit
if len(results) == len(episodes):
return results
# sort list by quality
if len(itemList):
if len(item_list):
items = {}
itemsUnknown = []
for item in itemList:
quality = self.getQuality(item, anime=show.is_anime)
if quality == Quality.UNKNOWN:
itemsUnknown += [item]
items_unknown = []
for item in item_list:
quality = self.get_quality(item, anime=show.is_anime)
if Quality.UNKNOWN == quality:
items_unknown += [item]
else:
if quality not in items:
items[quality] = [item]
else:
items[quality].append(item)
itemList = list(itertools.chain(*[v for (k, v) in sorted(items.items(), reverse=True)]))
itemList += itemsUnknown if itemsUnknown else []
item_list = list(itertools.chain(*[v for (k, v) in sorted(items.items(), reverse=True)]))
item_list += items_unknown if items_unknown else []
# filter results
cl = []
for item in itemList:
for item in item_list:
(title, url) = self._get_title_and_url(item)
# parse the file name
try:
myParser = NameParser(False, convert=True)
parse_result = myParser.parse(title)
parser = NameParser(False, convert=True)
parse_result = parser.parse(title)
except InvalidNameException:
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.DEBUG)
logger.log(u'Unable to parse the filename ' + title + ' into a valid episode', logger.DEBUG)
continue
except InvalidShowException:
logger.log(u'No show name or scene exception matched the parsed filename ' + title, logger.DEBUG)
continue
showObj = parse_result.show
show_obj = parse_result.show
quality = parse_result.quality
release_group = parse_result.release_group
version = parse_result.version
addCacheEntry = False
if not (showObj.air_by_date or showObj.sports):
if search_mode == 'sponly':
add_cache_entry = False
if not (show_obj.air_by_date or show_obj.sports):
if 'sponly' == search_mode:
if len(parse_result.episode_numbers):
logger.log(
u"This is supposed to be a season pack search but the result " + title + " is not a valid season pack, skipping it",
logger.DEBUG)
addCacheEntry = True
if len(parse_result.episode_numbers) and (
parse_result.season_number not in set([ep.season for ep in episodes]) or not [ep for ep in episodes if
ep.scene_episode in parse_result.episode_numbers]):
logger.log(
u"The result " + title + " doesn't seem to be a valid episode that we are trying to snatch, ignoring",
logger.DEBUG)
addCacheEntry = True
logger.log(u'This is supposed to be a season pack search but the result ' + title
+ u' is not a valid season pack, skipping it', logger.DEBUG)
add_cache_entry = True
if len(parse_result.episode_numbers)\
and (parse_result.season_number not in set([ep.season for ep in episodes])
or not [ep for ep in episodes if ep.scene_episode in parse_result.episode_numbers]):
logger.log(u'The result ' + title + u' doesn\'t seem to be a valid episode that we are trying'
+ u' to snatch, ignoring', logger.DEBUG)
add_cache_entry = True
else:
if not len(parse_result.episode_numbers) and parse_result.season_number and not [ep for ep in
episodes if
ep.season == parse_result.season_number and ep.episode in parse_result.episode_numbers]:
logger.log(
u"The result " + title + " doesn't seem to be a valid season that we are trying to snatch, ignoring",
logger.DEBUG)
addCacheEntry = True
if not len(parse_result.episode_numbers)\
and parse_result.season_number\
and not [ep for ep in episodes
if ep.season == parse_result.season_number
and ep.episode in parse_result.episode_numbers]:
logger.log(u'The result ' + title + u' doesn\'t seem to be a valid season that we are trying'
+ u' to snatch, ignoring', logger.DEBUG)
add_cache_entry = True
elif len(parse_result.episode_numbers) and not [ep for ep in episodes if
ep.season == parse_result.season_number and ep.episode in parse_result.episode_numbers]:
logger.log(
u"The result " + title + " doesn't seem to be a valid episode that we are trying to snatch, ignoring",
logger.DEBUG)
addCacheEntry = True
logger.log(u'The result ' + title + ' doesn\'t seem to be a valid episode that we are trying'
+ u' to snatch, ignoring', logger.DEBUG)
add_cache_entry = True
if not addCacheEntry:
if not add_cache_entry:
# we just use the existing info for normal searches
actual_season = parse_result.season_number
actual_episodes = parse_result.episode_numbers
else:
if not (parse_result.is_air_by_date):
logger.log(
u"This is supposed to be a date search but the result " + title + " didn't parse as one, skipping it",
logger.DEBUG)
addCacheEntry = True
if not parse_result.is_air_by_date:
logger.log(u'This is supposed to be a date search but the result ' + title
+ u' didn\'t parse as one, skipping it', logger.DEBUG)
add_cache_entry = True
else:
airdate = parse_result.air_date.toordinal()
myDB = db.DBConnection()
sql_results = myDB.select(
"SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
[showObj.indexerid, airdate])
my_db = db.DBConnection()
sql_results = my_db.select('SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?',
[show_obj.indexerid, airdate])
if len(sql_results) != 1:
logger.log(
u"Tried to look up the date for the episode " + title + " but the database didn't give proper results, skipping it",
logger.WARNING)
addCacheEntry = True
if 1 != len(sql_results):
logger.log(u'Tried to look up the date for the episode ' + title + ' but the database didn\'t'
+ u' give proper results, skipping it', logger.WARNING)
add_cache_entry = True
if not addCacheEntry:
actual_season = int(sql_results[0]["season"])
actual_episodes = [int(sql_results[0]["episode"])]
if not add_cache_entry:
actual_season = int(sql_results[0]['season'])
actual_episodes = [int(sql_results[0]['episode'])]
# add parsed result to cache for usage later on
if addCacheEntry:
logger.log(u"Adding item from search to cache: " + title, logger.DEBUG)
ci = self.cache._addCacheEntry(title, url, parse_result=parse_result)
if ci is not None:
if add_cache_entry:
logger.log(u'Adding item from search to cache: ' + title, logger.DEBUG)
ci = self.cache.add_cache_entry(title, url, parse_result=parse_result)
if None is not ci:
cl.append(ci)
continue
# make sure we want the episode
wantEp = True
want_ep = True
for epNo in actual_episodes:
if not showObj.wantEpisode(actual_season, epNo, quality, manualSearch):
wantEp = False
if not show_obj.wantEpisode(actual_season, epNo, quality, manual_search):
want_ep = False
break
if not wantEp:
logger.log(
u"Ignoring result " + title + " because we don't want an episode that is " +
Quality.qualityStrings[
quality], logger.DEBUG)
if not want_ep:
logger.log(u'Ignoring result %s because we don\'t want an episode that is %s'
% (title, Quality.qualityStrings[quality]), logger.DEBUG)
continue
logger.log(u"Found result " + title + " at " + url, logger.DEBUG)
logger.log(u'Found result %s at %s' % (title, url), logger.DEBUG)
# make a result object
epObj = []
ep_obj = []
for curEp in actual_episodes:
epObj.append(showObj.getEpisode(actual_season, curEp))
ep_obj.append(show_obj.getEpisode(actual_season, curEp))
result = self.getResult(epObj)
result.show = showObj
result.url = url
result = self.get_result(ep_obj, url)
if None is result:
continue
result.show = show_obj
result.name = title
result.quality = quality
result.release_group = release_group
result.content = None
result.version = version
if len(epObj) == 1:
epNum = epObj[0].episode
logger.log(u"Single episode result.", logger.DEBUG)
elif len(epObj) > 1:
epNum = MULTI_EP_RESULT
logger.log(u"Separating multi-episode result to check for later - result contains episodes: " + str(
parse_result.episode_numbers), logger.DEBUG)
elif len(epObj) == 0:
epNum = SEASON_RESULT
logger.log(u"Separating full season result to check for later", logger.DEBUG)
if 1 == len(ep_obj):
ep_num = ep_obj[0].episode
logger.log(u'Single episode result.', logger.DEBUG)
elif 1 < len(ep_obj):
ep_num = MULTI_EP_RESULT
logger.log(u'Separating multi-episode result to check for later - result contains episodes: '
+ str(parse_result.episode_numbers), logger.DEBUG)
elif 0 == len(ep_obj):
ep_num = SEASON_RESULT
logger.log(u'Separating full season result to check for later', logger.DEBUG)
if epNum not in results:
results[epNum] = [result]
if ep_num not in results:
results[ep_num] = [result]
else:
results[epNum].append(result)
results[ep_num].append(result)
# check if we have items to add to cache
if len(cl) > 0:
myDB = self.cache._getDB()
myDB.mass_action(cl)
if 0 < len(cl):
my_db = self.cache.get_db()
my_db.mass_action(cl)
return results
def findPropers(self, search_date=None):
def find_propers(self, search_date=None):
results = self.cache.listPropers(search_date)
return [classes.Proper(x['name'], x['url'], datetime.datetime.fromtimestamp(x['time']), self.show) for x in
results]
def seedRatio(self):
'''
def seed_ratio(self):
"""
Provider should override this value if custom seed ratio enabled
It should return the value of the provider seed ratio
'''
"""
return ''
@staticmethod
@ -489,6 +484,30 @@ class GenericProvider:
logger.log(u'%s in response from %s' % (('No %s items' % mode,
'%s %s item%s' % (count, mode, maybe_plural(count)))[0 < count], url))
def check_auth_cookie(self):
if hasattr(self, 'cookies'):
cookies = self.cookies
if not re.match('^(\w+=\w+[;\s]*)+$', cookies):
return False
cj = requests.utils.add_dict_to_cookiejar(self.session.cookies,
dict([x.strip().split('=') for x in cookies.split(';')
if x != ''])),
for item in cj:
if not isinstance(item, requests.cookies.RequestsCookieJar):
return False
return True
def _check_cookie(self):
if self.check_auth_cookie():
return True, None
return False, 'Cookies not correctly formatted key=value pairs e.g. uid=xx;pass=yy)'
class NZBProvider(GenericProvider):
@ -497,9 +516,30 @@ class NZBProvider(GenericProvider):
self.providerType = GenericProvider.NZB
def imageName(self):
def image_name(self):
return GenericProvider.imageName(self, 'newznab')
return GenericProvider.image_name(self, 'newznab')
def maybe_apikey(self):
if hasattr(self, 'needs_auth'):
if hasattr(self, 'key') and 0 < len(self.key):
return self.key
if hasattr(self, 'api_key') and 0 < len(self.api_key):
return self.api_key
return None
return False
def _check_auth(self):
has_key = self.maybe_apikey()
if has_key:
return has_key
if None is has_key:
raise AuthException('%s for %s is empty in config provider options'
% ('API key' + ('', ' and/or Username')[hasattr(self, 'username')], self.name))
return GenericProvider._check_auth(self)
def _find_propers(self, search_date=None):
@ -508,7 +548,7 @@ class NZBProvider(GenericProvider):
cache_results]
index = 0
alt_search = ('nzbs_org' == self.getID())
alt_search = ('nzbs_org' == self.get_id())
term_items_found = False
do_search_alt = False
@ -534,7 +574,7 @@ class NZBProvider(GenericProvider):
else:
index += 1
for item in self._doSearch(search_params, age=4):
for item in self._do_search(search_params, age=4):
(title, url) = self._get_title_and_url(item)
@ -549,7 +589,7 @@ class NZBProvider(GenericProvider):
logger.log(u'Unable to figure out the date for entry %s, skipping it', title)
continue
if not search_date or result_date > search_date:
if not search_date or search_date < result_date:
search_result = classes.Proper(title, url, result_date, self.show)
results.append(search_result)
term_items_found = True
@ -569,15 +609,15 @@ class TorrentProvider(GenericProvider):
self._seed_ratio = None
def imageName(self):
def image_name(self):
return GenericProvider.imageName(self, 'torrent')
return GenericProvider.image_name(self, 'torrent')
def seedRatio(self):
def seed_ratio(self):
return self._seed_ratio
def getQuality(self, item, anime=False):
def get_quality(self, item, anime=False):
if isinstance(item, tuple):
name = item[0]
@ -655,7 +695,7 @@ class TorrentProvider(GenericProvider):
search_params += [crop.sub(r'\1', '%s %s' % (name, detail) + ('', ' ' + x)[any(x)]) for x in append]
return search_params
def _checkAuth(self):
def _check_auth(self):
if hasattr(self, 'username') and hasattr(self, 'password'):
if self.username and self.password:
@ -674,7 +714,7 @@ class TorrentProvider(GenericProvider):
return True
setting = 'Passkey'
else:
return GenericProvider._checkAuth(self)
return GenericProvider._check_auth(self)
raise AuthException('%s for %s is empty in config provider options' % (setting, self.name))
@ -720,7 +760,7 @@ class TorrentProvider(GenericProvider):
proper_check = re.compile(r'(?i)(?:%s)' % clean_term.sub('', proper_term))
search_string = self._get_episode_search_strings(cur_ep, add_string=proper_term)
for item in self._doSearch(search_string[0]):
for item in self._do_search(search_string[0]):
title, url = self._get_title_and_url(item)
if not proper_check.search(title):
continue
@ -741,4 +781,4 @@ class TorrentProvider(GenericProvider):
def get_cache_data(self, *args, **kwargs):
search_params = {'Cache': ['']}
return self._doSearch(search_params)
return self._do_search(search_params)

View file

@ -44,13 +44,13 @@ class GFTrackerProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = GFTrackerCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'gft_uid' in self.session.cookies and 'gft_pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
helpers.getURL(self.urls['login_get'], session=self.session)
login_params = {'username': self.username, 'password': self.password}
response = helpers.getURL(self.urls['login_post'], post_data=login_params, session=self.session)
@ -61,16 +61,16 @@ class GFTrackerProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {'info': 'details', 'get': 'download',
'seeders': '(^\d+)', 'leechers': '(\d+)$'}.items())
'seeders': r'(^\d+)', 'leechers': r'(\d+)$'}.items())
for mode in search_params.keys():
for search_string in search_params[mode]:
@ -81,7 +81,7 @@ class GFTrackerProvider(generic.TorrentProvider):
if 'Cache' != mode:
search_url += self.urls['search'] % search_string
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -126,7 +126,7 @@ class GFTrackerProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -73,27 +73,27 @@ class HDBitsProvider(generic.TorrentProvider):
return title, url
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
self._checkAuth()
self._check_auth()
logger.log(u'Search url: %s search_params: %s' % (self.urls['search'], search_params), logger.DEBUG)
response_json = self.getURL(self.urls['search'], post_data=search_params, json=True)
response_json = self.get_url(self.urls['search'], post_data=search_params, json=True)
if response_json and 'data' in response_json and self.check_auth_from_data(response_json):
return response_json['data']
logger.log(u'Resulting JSON from %s isn\'t correct, not parsing it' % self.name, logger.ERROR)
return []
def findPropers(self, search_date=None):
def find_propers(self, search_date=None):
results = []
search_terms = [' proper ', ' repack ']
for term in search_terms:
for item in self._doSearch(self._build_search_strings(search_term=term)):
for item in self._do_search(self._build_search_strings(search_term=term)):
if item['utadded']:
try:
result_date = datetime.datetime.fromtimestamp(int(item['utadded']))
@ -142,9 +142,9 @@ class HDBitsProvider(generic.TorrentProvider):
def get_cache_data(self):
self._checkAuth()
self._check_auth()
response_json = self.getURL(self.urls['search'], post_data=self._build_search_strings(), json=True)
response_json = self.get_url(self.urls['search'], post_data=self._build_search_strings(), json=True)
if response_json and 'data' in response_json and self.check_auth_from_data(response_json):
return response_json['data']

View file

@ -42,13 +42,13 @@ class IPTorrentsProvider(generic.TorrentProvider):
self.freeleech = False
self.cache = IPTorrentsCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'login': 'submit'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -58,10 +58,10 @@ class IPTorrentsProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -76,7 +76,7 @@ class IPTorrentsProvider(generic.TorrentProvider):
search_string = unidecode(search_string)
search_url = '%s%s' % (self.urls['search'] % (freeleech, search_string),
(';o=seeders', '')['Cache' == mode])
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -120,7 +120,7 @@ class IPTorrentsProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date, '')

View file

@ -55,7 +55,7 @@ class KATProvider(generic.TorrentProvider):
file_name = None
data = self.getURL(torrent_link)
data = self.get_url(torrent_link)
if not data:
return None
@ -144,7 +144,7 @@ class KATProvider(generic.TorrentProvider):
return [{'Episode': self._build_search_strings(ep_detail, append=(add_string, '')[self.show.anime])}]
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -216,7 +216,7 @@ class KATProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date, '')

View file

@ -44,13 +44,13 @@ class MoreThanProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = MoreThanCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'session' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'login': 'submit'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -63,10 +63,10 @@ class MoreThanProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -82,7 +82,7 @@ class MoreThanProvider(generic.TorrentProvider):
search_url = self.urls['search'] % search_string
# fetches 15 results by default, and up to 100 if allowed in user profile
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
if not html or self._has_no_results(html):
@ -133,7 +133,7 @@ class MoreThanProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -43,18 +43,10 @@ class NewznabProvider(generic.NZBProvider):
self.default = False
self.cache = NewznabCache(self)
def _checkAuth(self):
if self.needs_auth and not self.key:
logger.log(u'Incorrect authentication credentials for %s : API key is missing' % self.name, logger.DEBUG)
raise AuthException('Your authentication credentials for %s are missing, check your config.' % self.name)
return True
def check_auth_from_data(self, data):
if data is None:
return self._checkAuth()
return self._check_auth()
if 'error' in data.feed:
code = data.feed['error']['code']
@ -84,22 +76,20 @@ class NewznabProvider(generic.NZBProvider):
"""
return_categories = []
self._checkAuth()
api_key = self._check_auth()
params = {'t': 'caps'}
if self.needs_auth and self.key:
params['apikey'] = self.key
if isinstance(api_key, basestring):
params['apikey'] = api_key
try:
categories = self.getURL('%s/api' % self.url, params=params, timeout=10)
except:
logger.log(u'Error getting html for [%s]' %
('%s/api?%s' % (self.url, '&'.join('%s=%s' % (x, y) for x, y in params.items()))), logger.DEBUG)
categories = self.get_url('%s/api' % self.url, params=params, timeout=10)
if not categories:
logger.log(u'Error getting html for [%s/api?%s]' %
(self.url, '&'.join('%s=%s' % (x, y) for x, y in params.items())), logger.DEBUG)
return (False, return_categories, 'Error getting html for [%s]' %
('%s/api?%s' % (self.url, '&'.join('%s=%s' % (x, y) for x, y in params.items()))))
xml_categories = helpers.parse_xml(categories)
if not xml_categories:
logger.log(u'Error parsing xml for [%s]' % self.name, logger.DEBUG)
return False, return_categories, 'Error parsing xml for [%s]' % self.name
@ -117,7 +107,7 @@ class NewznabProvider(generic.NZBProvider):
def config_str(self):
return '%s|%s|%s|%s|%i|%s|%i|%i|%i' \
% (self.name or '', self.url or '', self.key or '', self.cat_ids or '', self.enabled,
% (self.name or '', self.url or '', self.maybe_apikey() or '', self.cat_ids or '', self.enabled,
self.search_mode or '', self.search_fallback, self.enable_recentsearch, self.enable_backlog)
def _get_season_search_strings(self, ep_obj):
@ -154,7 +144,7 @@ class NewznabProvider(generic.NZBProvider):
return to_return
def _get_episode_search_strings(self, ep_obj, add_string=''):
def _get_episode_search_strings(self, ep_obj):
to_return = []
params = {}
@ -169,8 +159,7 @@ class NewznabProvider(generic.NZBProvider):
params['ep'] = '%i' % int(
ep_obj.scene_absolute_number if int(ep_obj.scene_absolute_number) > 0 else ep_obj.scene_episode)
else:
params['season'] = ep_obj.scene_season
params['ep'] = ep_obj.scene_episode
params['season'], params['ep'] = ep_obj.scene_season, ep_obj.scene_episode
# search
rid = helpers.mapIndexersToShow(ep_obj.show)[2]
@ -203,9 +192,9 @@ class NewznabProvider(generic.NZBProvider):
return to_return
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
self._checkAuth()
api_key = self._check_auth()
if 'rid' not in search_params and 'q' not in search_params:
logger.log('Error no rid or search term given.')
@ -233,8 +222,8 @@ class NewznabProvider(generic.NZBProvider):
if search_params:
params.update(search_params)
if self.needs_auth and self.key:
params['apikey'] = self.key
if isinstance(api_key, basestring):
params['apikey'] = api_key
results = []
offset = total = 0
@ -288,7 +277,7 @@ class NewznabProvider(generic.NZBProvider):
% (items, helpers.maybe_plural(items), params['limit']), logger.DEBUG)
return results
def findPropers(self, search_date=None):
def find_propers(self, search_date=None):
return self._find_propers(search_date)
@ -305,8 +294,9 @@ class NewznabCache(tvcache.TVCache):
'cat': self.provider.cat_ids + ',5060,5070',
'attrs': 'rageid'}
if self.provider.needs_auth and self.provider.key:
params['apikey'] = self.provider.key
has_apikey = self.provider.maybe_apikey()
if has_apikey:
params['apikey'] = has_apikey
rss_url = '%sapi?%s' % (self.provider.url, urllib.urlencode(params))
@ -314,13 +304,14 @@ class NewznabCache(tvcache.TVCache):
return self.getRSSFeed(rss_url)
def _checkAuth(self, *data):
return self.provider.check_auth_from_data(data[0])
def updateCache(self):
if self.shouldUpdate() and self._checkAuth(None):
if self.shouldUpdate():
try:
self._checkAuth()
except Exception:
return []
data = self._getRSSData()
# as long as the http request worked we count this as an update
@ -332,7 +323,7 @@ class NewznabCache(tvcache.TVCache):
self.setLastUpdate()
if self._checkAuth(data):
if self.provider.check_auth_from_data(data):
items = data.entries
cl = []
for item in items:
@ -341,7 +332,7 @@ class NewznabCache(tvcache.TVCache):
cl.append(ci)
if 0 < len(cl):
my_db = self._getDB()
my_db = self.get_db()
my_db.mass_action(cl)
else:
@ -376,4 +367,4 @@ class NewznabCache(tvcache.TVCache):
url = self._translateLinkURL(url)
logger.log(u'Attempting to add item from RSS to cache: ' + title, logger.DEBUG)
return self._addCacheEntry(title, url, indexer_id=tvrageid)
return self.add_cache_entry(title, url, indexer_id=tvrageid)

View file

@ -17,113 +17,82 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import urllib
import re
import generic
from . import generic
from sickbeard import logger, tvcache, show_name_helpers
from sickbeard.common import Quality
class NyaaProvider(generic.TorrentProvider):
def __init__(self):
generic.TorrentProvider.__init__(self, 'NyaaTorrents', True, True)
self.ratio = None
self.cache = NyaaCache(self)
generic.TorrentProvider.__init__(self, 'NyaaTorrents', anime_only=True)
self.url = 'http://www.nyaa.se/'
def getQuality(self, item, anime=False):
title = item.title
quality = Quality.sceneQuality(title, anime)
return quality
self.cache = NyaaCache(self)
def findSearchResults(self, show, episodes, search_mode, manualSearch=False):
return generic.TorrentProvider.findSearchResults(self, show, episodes, search_mode, manualSearch)
def _do_search(self, search_string, search_mode='eponly', epcount=0, age=0):
def _get_season_search_strings(self, ep_obj):
return show_name_helpers.makeSceneShowSearchStrings(self.show)
def _get_episode_search_strings(self, ep_obj, add_string=''):
return self._get_season_search_strings(ep_obj)
def _doSearch(self, search_string, search_mode='eponly', epcount=0, age=0):
results = []
if self.show and not self.show.is_anime:
logger.log(u"" + str(self.show.name) + " is not an anime skipping " + str(self.name))
return []
return results
params = {
"term": search_string.encode('utf-8'),
"cats": '1_37', # Limit to English-translated Anime (for now)
"sort": '2', # Sort Descending By Seeders
}
params = {'term': search_string.encode('utf-8'),
'cats': '1_37', # Limit to English-translated Anime (for now)
# 'sort': '2', # Sort Descending By Seeders
}
searchURL = self.url + '?page=rss&' + urllib.urlencode(params)
search_url = self.url + '?page=rss&' + urllib.urlencode(params)
logger.log(u"Search string: " + searchURL, logger.DEBUG)
logger.log(u'Search string: ' + search_url, logger.DEBUG)
data = self.cache.getRSSFeed(searchURL)
if not data:
return []
if 'entries' in data:
data = self.cache.getRSSFeed(search_url)
if data and 'entries' in data:
items = data.entries
results = []
for curItem in items:
(title, url) = self._get_title_and_url(curItem)
title, url = self._get_title_and_url(curItem)
if title and url:
results.append(curItem)
else:
logger.log(
u"The data returned from " + self.name + " is incomplete, this result is unusable",
logger.DEBUG)
logger.log(u'The data returned from ' + self.name + ' is incomplete, this result is unusable',
logger.DEBUG)
return results
return results
return []
def find_search_results(self, show, episodes, search_mode, manual_search=False):
def _get_title_and_url(self, item):
return generic.TorrentProvider.find_search_results(self, show, episodes, search_mode, manual_search)
return generic.TorrentProvider._get_title_and_url(self, item)
def _get_season_search_strings(self, ep_obj, **kwargs):
def _extract_name_from_filename(self, filename):
name_regex = '(.*?)\.?(\[.*]|\d+\.TPB)\.torrent$'
logger.log(u"Comparing " + name_regex + " against " + filename, logger.DEBUG)
match = re.match(name_regex, filename, re.I)
if match:
return match.group(1)
return None
return show_name_helpers.makeSceneShowSearchStrings(self.show)
def seedRatio(self):
return self.ratio
def _get_episode_search_strings(self, ep_obj, **kwargs):
return self._get_season_search_strings(ep_obj)
class NyaaCache(tvcache.TVCache):
def __init__(self, provider):
tvcache.TVCache.__init__(self, provider)
# only poll NyaaTorrents every 15 minutes max
self.minTime = 15
def __init__(self, this_provider):
tvcache.TVCache.__init__(self, this_provider)
self.minTime = 15 # cache update frequency
def _getRSSData(self):
params = {
"page": 'rss', # Use RSS page
"order": '1', # Sort Descending By Date
"cats": '1_37', # Limit to English-translated Anime (for now)
}
params = {'page': 'rss', # Use RSS page
'order': '1', # Sort Descending By Date
'cats': '1_37'} # Limit to English-translated Anime (for now)
url = self.provider.url + '?' + urllib.urlencode(params)
logger.log(u"NyaaTorrents cache update URL: " + url, logger.DEBUG)
logger.log(u'NyaaTorrents cache update URL: ' + url, logger.DEBUG)
data = self.getRSSFeed(url)
if data and 'entries' in data:
return data.entries
else:
return []
return []
provider = NyaaProvider()

View file

@ -16,117 +16,202 @@
# You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import urllib
import re
from datetime import datetime
import time
import traceback
import generic
import sickbeard
import urllib
from sickbeard import tvcache, classes, logger, show_name_helpers
from sickbeard.exceptions import AuthException
try:
import xml.etree.cElementTree as etree
except ImportError:
import elementtree.ElementTree as etree
try:
import json
except ImportError:
from lib import simplejson as json
from sickbeard.rssfeeds import RSSFeeds
from sickbeard.bs4_parser import BS4Parser
class OmgwtfnzbsProvider(generic.NZBProvider):
def __init__(self):
generic.NZBProvider.__init__(self, 'omgwtfnzbs', True, False)
self.username = None
self.api_key = None
self.cache = OmgwtfnzbsCache(self)
generic.NZBProvider.__init__(self, 'omgwtfnzbs')
self.url = 'https://omgwtfnzbs.org/'
def _checkAuth(self):
self.url_base = 'https://omgwtfnzbs.org/'
self.urls = {'config_provider_home_uri': self.url_base,
'cache': 'https://rss.omgwtfnzbs.org/rss-download.php?%s',
'search': self.url_base + 'json/?%s',
'get': self.url_base + '%s',
'cache_html': self.url_base + 'browse.php?cat=tv%s',
'search_html': self.url_base + 'browse.php?cat=tv&search=%s'}
if not self.username or not self.api_key:
raise AuthException("Your authentication credentials for " + self.name + " are missing, check your config.")
self.url = self.urls['config_provider_home_uri']
return True
self.needs_auth = True
self.username, self.api_key, self.cookies = 3 * [None]
self.cache = OmgwtfnzbsCache(self)
def _checkAuthFromData(self, parsed_data, is_XML=True):
def _check_auth_from_data(self, parsed_data, is_xml=True):
if parsed_data is None:
return self._checkAuth()
return self._check_auth()
if is_XML:
if is_xml:
# provider doesn't return xml on error
return True
else:
parsedJSON = parsed_data
data_json = parsed_data
if 'notice' in parsedJSON:
description_text = parsedJSON.get('notice')
if 'notice' in data_json:
description_text = data_json.get('notice')
if 'information is incorrect' in parsedJSON.get('notice'):
logger.log(u"Incorrect authentication credentials for " + self.name + " : " + str(description_text),
if 'information is incorrect' in data_json.get('notice'):
logger.log(u'Incorrect authentication credentials for ' + self.name + ' : ' + str(description_text),
logger.DEBUG)
raise AuthException(
"Your authentication credentials for " + self.name + " are incorrect, check your config.")
'Your authentication credentials for ' + self.name + ' are incorrect, check your config.')
elif '0 results matched your terms' in parsedJSON.get('notice'):
elif '0 results matched your terms' in data_json.get('notice'):
return True
else:
logger.log(u"Unknown error given from " + self.name + " : " + str(description_text), logger.DEBUG)
logger.log(u'Unknown error given from ' + self.name + ' : ' + str(description_text), logger.DEBUG)
return False
return True
def _get_season_search_strings(self, ep_obj):
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
def _get_episode_search_strings(self, ep_obj, add_string=''):
def _get_episode_search_strings(self, ep_obj):
return [x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
def _get_title_and_url(self, item):
return (item['release'], item['getnzb'])
def _doSearch(self, search, search_mode='eponly', epcount=0, retention=0):
return item['release'], item['getnzb']
self._checkAuth()
def get_result(self, episodes, url):
params = {'user': self.username,
'api': self.api_key,
'eng': 1,
'catid': '19,20', # SD,HD
'retention': sickbeard.USENET_RETENTION,
'search': search}
result = None
if url and False is self._init_api():
data = self.get_url(url)
if data:
if '</nzb>' not in data or 'seem to be logged in' in data:
logger.log(u'Failed nzb data response: %s' % data, logger.DEBUG)
return result
result = classes.NZBDataSearchResult(episodes)
result.extraInfo += [data]
if retention or not params['retention']:
params['retention'] = retention
if None is result:
result = classes.NZBSearchResult(episodes)
result.url = url
search_url = 'https://api.omgwtfnzbs.org/json/?' + urllib.urlencode(params)
logger.log(u"Search url: " + search_url, logger.DEBUG)
result.provider = self
parsedJSON = self.getURL(search_url, json=True)
if not parsedJSON:
return []
return result
if self._checkAuthFromData(parsedJSON, is_XML=False):
results = []
def get_cache_data(self):
for item in parsedJSON:
if 'release' in item and 'getnzb' in item:
results.append(item)
api_key = self._init_api()
if False is api_key:
return self.search_html()
if None is not api_key:
params = {'user': self.username,
'api': api_key,
'eng': 1,
'catid': '19,20'} # SD,HD
return results
rss_url = self.urls['cache'] % urllib.urlencode(params)
logger.log(self.name + u' cache update URL: ' + rss_url, logger.DEBUG)
data = RSSFeeds(self).get_feed(rss_url)
if data and 'entries' in data:
return data.entries
return []
def findPropers(self, search_date=None):
def _do_search(self, search, search_mode='eponly', epcount=0, retention=0):
api_key = self._init_api()
if False is api_key:
return self.search_html(search)
results = []
if None is not api_key:
params = {'user': self.username,
'api': api_key,
'eng': 1,
'catid': '19,20', # SD,HD
'retention': (sickbeard.USENET_RETENTION, retention)[retention or not sickbeard.USENET_RETENTION],
'search': search}
search_url = self.urls['search'] % urllib.urlencode(params)
logger.log(u'Search url: ' + search_url, logger.DEBUG)
data_json = self.get_url(search_url, json=True)
if data_json and self._check_auth_from_data(data_json, is_xml=False):
for item in data_json:
if 'release' in item and 'getnzb' in item:
results.append(item)
return results
def search_html(self, search=''):
results = []
if None is self.cookies:
return results
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {'info': 'detail', 'get': r'send\?', 'nuked': r'\bnuked',
'cat': 'cat=(?:19|20)'}.items())
mode = ('search', 'cache')['' == search]
search_url = self.urls[mode + '_html'] % search
html = self.get_url(search_url)
cnt = len(results)
try:
if not html:
raise generic.HaltParseException
with BS4Parser(html, features=['html5lib', 'permissive']) as soup:
torrent_table = soup.find('table', attrs={'id': 'table_table'})
torrent_rows = []
if torrent_table:
torrent_rows = torrent_table.find('tbody').find_all('tr')
if 1 > len(torrent_rows):
raise generic.HaltParseException
for tr in torrent_rows:
try:
if tr.find('img', src=rc['nuked']) or not tr.find('a', href=rc['cat']):
continue
title = tr.find('a', href=rc['info'])['title']
download_url = tr.find('a', href=rc['get'])
age = tr.find_all('td')[-1]['data-sort']
except (AttributeError, TypeError):
continue
if title and download_url and age:
results.append({'release': title, 'getnzb': self.urls['get'] % download_url['href'].lstrip('/'),
'usenetage': int(age.strip())})
except generic.HaltParseException:
time.sleep(1.1)
pass
except Exception:
logger.log(u'Failed to parse. Traceback: %s' % traceback.format_exc(), logger.ERROR)
self._log_result(mode, len(results) - cnt, search_url)
return results
def find_propers(self, search_date=None):
search_terms = ['.PROPER.', '.REPACK.']
results = []
for term in search_terms:
for item in self._doSearch(term, retention=4):
for item in self._do_search(term, retention=4):
if 'usenetage' in item:
title, url = self._get_title_and_url(item)
@ -140,47 +225,40 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
return results
def _init_api(self):
try:
api_key = self._check_auth()
if not api_key.startswith('cookie:'):
return api_key
except Exception:
return None
self.cookies = re.sub(r'(?i)([\s\']+|cookie\s*:)', '', api_key)
success, msg = self._check_cookie()
if not success:
logger.log(u'%s: %s' % (msg, self.cookies), logger.WARNING)
self.cookies = None
return None
return False
@staticmethod
def ui_string(key):
result = ''
if 'omgwtfnzbs_api_key' == key:
result = 'Or use... \'cookie: cookname=xx; cookpass=yy\''
return result
class OmgwtfnzbsCache(tvcache.TVCache):
def __init__(self, provider):
tvcache.TVCache.__init__(self, provider)
def __init__(self, this_provider):
tvcache.TVCache.__init__(self, this_provider)
self.minTime = 20
def _get_title_and_url(self, item):
"""
Retrieves the title and URL data from the item XML node
item: An elementtree.ElementTree element representing the <item> tag of the RSS feed
Returns: A tuple containing two strings representing title and URL respectively
"""
title = item.title if item.title else None
if title:
title = u'' + title
title = title.replace(' ', '.')
url = item.link if item.link else None
if url:
url = url.replace('&amp;', '&')
return (title, url)
def _getRSSData(self):
params = {'user': provider.username,
'api': provider.api_key,
'eng': 1,
'catid': '19,20'} # SD,HD
rss_url = 'https://rss.omgwtfnzbs.org/rss-download.php?' + urllib.urlencode(params)
logger.log(self.provider.name + u" cache update URL: " + rss_url, logger.DEBUG)
data = self.getRSSFeed(rss_url)
if data and 'entries' in data:
return data.entries
else:
return []
return self.provider.get_cache_data()
provider = OmgwtfnzbsProvider()

View file

@ -39,14 +39,14 @@ class PiSexyProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = PiSexyCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies and\
'pcode' in self.session.cookies and 'pisexy' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -59,24 +59,24 @@ class PiSexyProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
rc = dict((k, re.compile('(?i)' + v))
for (k, v) in {'info': 'download', 'get': 'download', 'valid_cat': 'cat=(?:0|50[12])',
'title': 'Download\s([^\s]+).*', 'seeders': '(^\d+)', 'leechers': '(\d+)$'}.items())
'title': r'Download\s([^\s]+).*', 'seeders': r'(^\d+)', 'leechers': r'(\d+)$'}.items())
for mode in search_params.keys():
for search_string in search_params[mode]:
if isinstance(search_string, unicode):
search_string = unidecode(search_string)
search_url = self.urls['search'] % search_string
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -129,7 +129,7 @@ class PiSexyProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -55,7 +55,7 @@ class RarbgProvider(generic.TorrentProvider):
self.request_throttle = datetime.datetime.now()
self.cache = RarbgCache(self)
def _doLogin(self, reset=False):
def _do_login(self, reset=False):
if not reset and self.token and self.token_expiry and datetime.datetime.now() < self.token_expiry:
return True
@ -69,10 +69,10 @@ class RarbgProvider(generic.TorrentProvider):
logger.log(u'No usable API token returned from: %s' % self.urls['api_token'], logger.ERROR)
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin(reset=True):
if not self._do_login(reset=True):
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -122,7 +122,7 @@ class RarbgProvider(generic.TorrentProvider):
time_out += 1
time.sleep(1)
data = self.getURL(search_url % {'ranked': int(self.confirmed), 'token': self.token}, json=True)
data = self.get_url(search_url % {'ranked': int(self.confirmed), 'token': self.token}, json=True)
self.token_expiry = datetime.datetime.now() + datetime.timedelta(minutes=14)
self.request_throttle = datetime.datetime.now() + datetime.timedelta(seconds=3)
@ -131,7 +131,7 @@ class RarbgProvider(generic.TorrentProvider):
continue
elif 2 == data['error_code']: # Invalid token set
if self._doLogin(reset=True):
if self._do_login(reset=True):
continue
self._log_result(mode_base, len(items[mode_base]) - cnt, search_url)
return results
@ -160,7 +160,7 @@ class RarbgProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date, '{{.proper.|.repack.}}')

View file

@ -41,9 +41,9 @@ class TorrentRssProvider(generic.TorrentProvider):
self.feeder = RSSFeeds(self)
self.cache = TorrentRssCache(self)
def imageName(self):
def image_name(self):
return generic.GenericProvider.imageName(self, 'torrentrss')
return generic.GenericProvider.image_name(self, 'torrentrss')
def config_str(self):
return '%s|%s|%s|%d|%s|%d|%d|%d' % (self.name or '',
@ -81,9 +81,9 @@ class TorrentRssProvider(generic.TorrentProvider):
def validate_feed(self):
succ, err_msg = self.feeder.check_cookie()
if not succ:
return succ, err_msg
success, err_msg = self._check_cookie()
if not success:
return success, err_msg
try:
items = self.get_cache_data()
@ -96,7 +96,7 @@ class TorrentRssProvider(generic.TorrentProvider):
if re.search('urn:btih:([0-9a-f]{32,40})', url):
break
else:
torrent_file = self.getURL(url)
torrent_file = self.get_url(url)
try:
bdecode(torrent_file)
break

View file

@ -44,13 +44,13 @@ class SCCProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = SCCCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'submit': 'come on in'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
@ -61,12 +61,12 @@ class SCCProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
items = {'Season': [], 'Episode': [], 'Cache': []}
if not self._doLogin():
if not self._do_login():
return results
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {'info': 'detail', 'get': 'download'}.items())
@ -83,7 +83,7 @@ class SCCProvider(generic.TorrentProvider):
self.urls['nonscene'] % search_string]
for search_url in searches:
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -128,7 +128,7 @@ class SCCProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -44,13 +44,13 @@ class SpeedCDProvider(generic.TorrentProvider):
self.freeleech = False
self.cache = SpeedCDCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'inSpeed_speedian' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -63,10 +63,10 @@ class SpeedCDProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -78,7 +78,7 @@ class SpeedCDProvider(generic.TorrentProvider):
post_data = dict({'/browse.php?': None, 'cata': 'yes', 'jxt': 4, 'jxw': 'b', 'search': search_string},
**self.categories[mode])
data_json = self.getURL(self.urls['search'], post_data=post_data, json=True)
data_json = self.get_url(self.urls['search'], post_data=post_data, json=True)
cnt = len(items[mode])
try:
if not data_json:
@ -111,7 +111,7 @@ class SpeedCDProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import re
import datetime
from . import generic
@ -33,17 +34,17 @@ class StrikeProvider(generic.TorrentProvider):
self.minseed, self.minleech = 2 * [None]
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._checkAuth():
if not self._check_auth():
return results
for mode in search_params.keys():
for search_string in search_params[mode]:
search_url = self.urls['search'] % search_string.replace(' ', '+')
data_json = self.getURL(search_url, json=True)
search_url = self.urls['search'] % re.sub('[\.\s]+', ' ', search_string)
data_json = self.get_url(search_url, json=True)
cnt = len(results)
try:
@ -66,7 +67,7 @@ class StrikeProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -36,8 +36,8 @@ class ThePirateBayProvider(generic.TorrentProvider):
def __init__(self):
generic.TorrentProvider.__init__(self, 'The Pirate Bay')
self.urls = {'config_provider_home_uri': ['https://thepiratebay.gd/', 'https://thepiratebay.mn/',
'https://thepiratebay.am/', 'https://thepiratebay.vg/',
self.urls = {'config_provider_home_uri': ['https://thepiratebay.se/', 'https://thepiratebay.gd/',
'https://thepiratebay.mn/', 'https://thepiratebay.vg/',
'https://thepiratebay.la/'],
'search': 'search/%s/0/7/200',
'cache': 'tv/latest/'} # order by seed
@ -57,7 +57,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
has_signature = False
details_url = '/ajax_details_filelist.php?id=%s' % torrent_id
for idx, url in enumerate(self.urls['config_provider_home_uri']):
data = self.getURL(url + details_url)
data = self.get_url(url + details_url)
if data and re.search(r'<title>The\sPirate\sBay', data[33:200:]):
has_signature = True
break
@ -144,13 +144,13 @@ class ThePirateBayProvider(generic.TorrentProvider):
return [{'Episode': self._build_search_strings(ep_detail, append=(add_string, '')[self.show.anime])}]
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
items = {'Season': [], 'Episode': [], 'Cache': []}
rc = dict((k, re.compile('(?i)' + v))
for (k, v) in {'info': 'detail', 'get': 'download[^"]+magnet', 'tid': '.*/(\d{5,}).*',
for (k, v) in {'info': 'detail', 'get': 'download[^"]+magnet', 'tid': r'.*/(\d{5,}).*',
'verify': '(?:helper|moderator|trusted|vip)'}.items())
has_signature = False
for mode in search_params.keys():
@ -165,7 +165,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
log_url = u'(%s/%s): %s' % (idx + 1, len(self.urls['config_provider_home_uri']), search_url)
html = self.getURL(search_url)
html = self.get_url(search_url)
if html and re.search(r'Pirate\sBay', html[33:7632:]):
has_signature = True
break
@ -227,7 +227,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date, '')

View file

@ -16,140 +16,86 @@
# You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import urllib
import traceback
import urllib
import generic
from . import generic
from sickbeard import logger, tvcache, show_name_helpers
from sickbeard.common import Quality
from sickbeard.bs4_parser import BS4Parser
class TokyoToshokanProvider(generic.TorrentProvider):
def __init__(self):
generic.TorrentProvider.__init__(self, 'TokyoToshokan', True, True)
self.ratio = None
self.cache = TokyoToshokanCache(self)
generic.TorrentProvider.__init__(self, 'TokyoToshokan', anime_only=True)
self.url = 'http://tokyotosho.info/'
def _get_title_and_url(self, item):
self.cache = TokyoToshokanCache(self)
title, url = item
if title:
title = u'' + title
title = title.replace(' ', '.')
if url:
url = url.replace('&amp;', '&')
return (title, url)
def seedRatio(self):
return self.ratio
def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime)
return quality
def findSearchResults(self, show, episodes, search_mode, manualSearch=False):
return generic.TorrentProvider.findSearchResults(self, show, episodes, search_mode, manualSearch)
def _get_season_search_strings(self, ep_obj):
return [x.replace('.', ' ') for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
def _get_episode_search_strings(self, ep_obj, add_string=''):
return [x.replace('.', ' ') for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
def _doSearch(self, search_string, search_mode='eponly', epcount=0, age=0):
if self.show and not self.show.is_anime:
logger.log(u"" + str(self.show.name) + " is not an anime skipping " + str(self.name))
return []
params = {
"terms": search_string.encode('utf-8'),
"type": 1, # get anime types
}
searchURL = self.url + 'search.php?' + urllib.urlencode(params)
data = self.getURL(searchURL)
logger.log(u"Search string: " + searchURL, logger.DEBUG)
if not data:
return []
def _do_search(self, search_string, search_mode='eponly', epcount=0, age=0):
results = []
try:
with BS4Parser(data, features=["html5lib", "permissive"]) as soup:
torrent_table = soup.find('table', attrs={'class': 'listing'})
torrent_rows = torrent_table.find_all('tr') if torrent_table else []
if torrent_rows:
if torrent_rows[0].find('td', attrs={'class': 'centertext'}):
a = 1
else:
a = 0
if self.show and not self.show.is_anime:
return results
for top, bottom in zip(torrent_rows[a::2], torrent_rows[a::2]):
title = top.find('td', attrs={'class': 'desc-top'}).text
url = top.find('td', attrs={'class': 'desc-top'}).find('a')['href']
params = {'terms': search_string.encode('utf-8'),
'type': 1} # get anime types
if not title or not url:
continue
search_url = self.url + 'search.php?' + urllib.urlencode(params)
logger.log(u'Search string: ' + search_url, logger.DEBUG)
item = title.lstrip(), url
results.append(item)
html = self.get_url(search_url)
if html:
try:
with BS4Parser(html, features=['html5lib', 'permissive']) as soup:
torrent_table = soup.find('table', attrs={'class': 'listing'})
torrent_rows = torrent_table.find_all('tr') if torrent_table else []
if torrent_rows:
a = (0, 1)[torrent_rows[0].find('td', attrs={'class': 'centertext'})]
except Exception as e:
logger.log(u"Failed to parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR)
for top, bottom in zip(torrent_rows[a::2], torrent_rows[a::2]):
title = top.find('td', attrs={'class': 'desc-top'}).text
url = top.find('td', attrs={'class': 'desc-top'}).find('a')['href']
if title and url:
results.append((title.lstrip(), url))
except Exception:
logger.log(u'Failed to parsing ' + self.name + ' Traceback: ' + traceback.format_exc(), logger.ERROR)
return results
def find_search_results(self, show, episodes, search_mode, manual_search=False):
return generic.TorrentProvider.find_search_results(self, show, episodes, search_mode, manual_search)
def _get_season_search_strings(self, ep_obj, **kwargs):
return [x.replace('.', ' ') for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
def _get_episode_search_strings(self, ep_obj, **kwargs):
return [x.replace('.', ' ') for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
class TokyoToshokanCache(tvcache.TVCache):
def __init__(self, provider):
tvcache.TVCache.__init__(self, provider)
# only poll NyaaTorrents every 15 minutes max
self.minTime = 15
def __init__(self, this_provider):
tvcache.TVCache.__init__(self, this_provider)
def _get_title_and_url(self, item):
"""
Retrieves the title and URL data from the item XML node
item: An elementtree.ElementTree element representing the <item> tag of the RSS feed
Returns: A tuple containing two strings representing title and URL respectively
"""
title = item.title if item.title else None
if title:
title = u'' + title
title = title.replace(' ', '.')
url = item.link if item.link else None
if url:
url = url.replace('&amp;', '&')
return (title, url)
self.minTime = 15 # cache update frequency
def _getRSSData(self):
params = {
"filter": '1',
}
params = {'filter': '1'}
url = self.provider.url + 'rss.php?' + urllib.urlencode(params)
logger.log(u"TokyoToshokan cache update URL: " + url, logger.DEBUG)
logger.log(u'TokyoToshokan cache update URL: ' + url, logger.DEBUG)
data = self.getRSSFeed(url)
if data and 'entries' in data:
return data.entries
else:
return []
return []
provider = TokyoToshokanProvider()

View file

@ -43,13 +43,13 @@ class TorrentBytesProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = TorrentBytesCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'login': 'Log in!'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -62,10 +62,10 @@ class TorrentBytesProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -77,7 +77,7 @@ class TorrentBytesProvider(generic.TorrentProvider):
search_string = unidecode(search_string)
search_url = self.urls['search'] % (search_string, self.categories)
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -121,7 +121,7 @@ class TorrentBytesProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -44,13 +44,13 @@ class TorrentDayProvider(generic.TorrentProvider):
self.freeleech = False
self.cache = TorrentDayCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'uid' in self.session.cookies and 'pass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'submit.x': 0, 'submit.y': 0}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -63,10 +63,10 @@ class TorrentDayProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -80,7 +80,7 @@ class TorrentDayProvider(generic.TorrentProvider):
if self.freeleech:
post_data.update({'free': 'on'})
data_json = self.getURL(self.urls['search'], post_data=post_data, json=True)
data_json = self.get_url(self.urls['search'], post_data=post_data, json=True)
cnt = len(items[mode])
try:
if not data_json:
@ -111,7 +111,7 @@ class TorrentDayProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date, '')

View file

@ -44,13 +44,13 @@ class TorrentLeechProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = TorrentLeechCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'tluid' in self.session.cookies and 'tlpass' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'remember_me': 'on', 'login': 'submit'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -60,10 +60,10 @@ class TorrentLeechProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -80,7 +80,7 @@ class TorrentLeechProvider(generic.TorrentProvider):
else:
search_url = self.urls['search'] % (search_string, self.categories)
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -123,7 +123,7 @@ class TorrentLeechProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -46,13 +46,13 @@ class TorrentShackProvider(generic.TorrentProvider):
self.username, self.password, self.minseed, self.minleech = 4 * [None]
self.cache = TorrentShackCache(self)
def _doLogin(self):
def _do_login(self):
logged_in = lambda: 'session' in self.session.cookies
if logged_in():
return True
if self._checkAuth():
if self._check_auth():
login_params = {'username': self.username, 'password': self.password, 'keeplogged': '1', 'login': 'Login'}
response = helpers.getURL(self.urls['login'], post_data=login_params, session=self.session)
if response and logged_in():
@ -65,10 +65,10 @@ class TorrentShackProvider(generic.TorrentProvider):
return False
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, search_mode='eponly', epcount=0, age=0):
results = []
if not self._doLogin():
if not self._do_login():
return results
items = {'Season': [], 'Episode': [], 'Cache': []}
@ -83,7 +83,7 @@ class TorrentShackProvider(generic.TorrentProvider):
# fetch 15 results by default, and up to 100 if allowed in user profile
search_url = self.urls['search'] % search_string
html = self.getURL(search_url)
html = self.get_url(search_url)
cnt = len(items[mode])
try:
@ -128,7 +128,7 @@ class TorrentShackProvider(generic.TorrentProvider):
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)

View file

@ -48,9 +48,9 @@ class ToTVProvider(generic.TorrentProvider):
logger.DEBUG)
raise AuthException('Your authentication credentials for %s are incorrect, check your config.' % self.name)
def _doSearch(self, search_params, mode='eponly', epcount=0, age=0):
def _do_search(self, search_params, mode='eponly', epcount=0, age=0):
self._checkAuth()
self._check_auth()
self.headers.update({'X-Authorization': self.api_key})
results = []
params = {'limit': 100}
@ -62,7 +62,7 @@ class ToTVProvider(generic.TorrentProvider):
search_url = self.urls['search'] % urllib.urlencode(params)
data_json = self.getURL(search_url, json=True)
data_json = self.get_url(search_url, json=True)
cnt = len(results)
if data_json and 'results' in data_json and self._check_auth_from_data(data_json):
@ -82,7 +82,7 @@ class ToTVProvider(generic.TorrentProvider):
self._log_result(mode, len(results) - cnt, search_url)
return results
def findPropers(self, search_date=datetime.datetime.today()):
def find_propers(self, search_date=datetime.datetime.today()):
return self._find_propers(search_date)
@ -113,7 +113,7 @@ class ToTVProvider(generic.TorrentProvider):
def get_cache_data(self, *args, **kwargs):
return self._doSearch({})
return self._do_search({})
class ToTVCache(tvcache.TVCache):

View file

@ -66,7 +66,7 @@ class WombleCache(tvcache.TVCache):
cl.append(ci)
if 0 < len(cl):
my_db = self._getDB()
my_db = self.get_db()
my_db.mass_action(cl)
# set last updated

View file

@ -3,9 +3,6 @@
# This file is part of SickGear.
#
import re
import requests
import requests.cookies
from feedparser import feedparser
from sickbeard import helpers, logger
@ -20,28 +17,10 @@ class RSSFeeds:
def _check_auth_cookie(self):
if self.provider and hasattr(self.provider, 'cookies'):
cookies = self.provider.cookies
if not re.match('^(\w+=\w+[;\s]*)+$', cookies):
return False
cj = requests.utils.add_dict_to_cookiejar(self.provider.session.cookies,
dict([x.strip().split('=') for x in cookies.split(';')
if x != ''])),
for item in cj:
if not isinstance(item, requests.cookies.RequestsCookieJar):
return False
if self.provider:
return self.provider.check_auth_cookie()
return True
def check_cookie(self):
if self._check_auth_cookie():
return True, None
return False, 'Cookies not correctly formatted key=value pairs e.g. uid=xx;pass=yy): ' + self.provider.cookies
def get_feed(self, url, request_headers=None):
if not self._check_auth_cookie():

View file

@ -59,17 +59,8 @@ def sendNZB(nzb):
# if it's a normal result we just pass SAB the URL
if nzb.resultType == "nzb":
# for newzbin results send the ID to sab specifically
if nzb.provider.getID() == 'newzbin':
id = nzb.provider.getIDFromURL(nzb.url)
if not id:
logger.log("Unable to send NZB to SABnzbd, can't find ID in URL " + str(nzb.url), logger.ERROR)
return False
params['mode'] = 'addid'
params['name'] = id
else:
params['mode'] = 'addurl'
params['name'] = nzb.url
params['mode'] = 'addurl'
params['name'] = nzb.url
# if we get a raw data result we want to upload it to SAB
elif nzb.resultType == "nzbdata":

View file

@ -60,7 +60,7 @@ def _downloadResult(result):
# nzbs with an URL can just be downloaded from the provider
if result.resultType == "nzb":
newResult = resProvider.downloadResult(result)
newResult = resProvider.download_result(result)
# if it's an nzb data result
elif result.resultType == "nzbdata":
@ -82,7 +82,7 @@ def _downloadResult(result):
logger.log(u"Error trying to save NZB to black hole: " + ex(e), logger.ERROR)
newResult = False
elif resProvider.providerType == "torrent":
newResult = resProvider.downloadResult(result)
newResult = resProvider.download_result(result)
else:
logger.log(u"Invalid provider type - this is a coding error, report it please", logger.ERROR)
newResult = False
@ -134,7 +134,7 @@ def snatchEpisode(result, endStatus=SNATCHED):
else:
# make sure we have the torrent file content
if not result.content and not result.url.startswith('magnet'):
result.content = result.provider.getURL(result.url)
result.content = result.provider.get_url(result.url)
if not result.content:
logger.log(u'Torrent content failed to download from ' + result.url, logger.ERROR)
return False
@ -401,12 +401,12 @@ def searchForNeededEpisodes(episodes):
origThreadName = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and x.enable_recentsearch]
providers = [x for x in sickbeard.providers.sortedProviderList() if x.is_active() and x.enable_recentsearch]
for curProvider in providers:
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
curFoundResults = curProvider.searchRSS(episodes)
curFoundResults = curProvider.search_rss(episodes)
didSearch = True
@ -435,7 +435,7 @@ def searchForNeededEpisodes(episodes):
if bestResult.resultType == "torrent" and sickbeard.TORRENT_METHOD != "blackhole":
bestResult.content = None
if not bestResult.url.startswith('magnet'):
bestResult.content = bestResult.provider.getURL(bestResult.url)
bestResult.content = bestResult.provider.get_url(bestResult.url)
if not bestResult.content:
continue
@ -451,7 +451,7 @@ def searchForNeededEpisodes(episodes):
return foundResults.values()
def searchProviders(show, episodes, manualSearch=False):
def searchProviders(show, episodes, manual_search=False):
foundResults = {}
finalResults = []
@ -459,7 +459,7 @@ def searchProviders(show, episodes, manualSearch=False):
origThreadName = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and x.enable_backlog]
providers = [x for x in sickbeard.providers.sortedProviderList() if x.is_active() and x.enable_backlog]
for providerNum, curProvider in enumerate(providers):
if curProvider.anime_only and not show.is_anime:
logger.log(u"" + str(show.name) + " is not an anime, skipping", logger.DEBUG)
@ -482,7 +482,7 @@ def searchProviders(show, episodes, manualSearch=False):
try:
curProvider.cache._clearCache()
searchResults = curProvider.findSearchResults(show, episodes, search_mode, manualSearch)
searchResults = curProvider.find_search_results(show, episodes, search_mode, manual_search)
except exceptions.AuthException as e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
break
@ -703,7 +703,7 @@ def searchProviders(show, episodes, manualSearch=False):
if bestResult.resultType == "torrent" and sickbeard.TORRENT_METHOD != "blackhole":
bestResult.content = None
if not bestResult.url.startswith('magnet'):
bestResult.content = bestResult.provider.getURL(bestResult.url)
bestResult.content = bestResult.provider.get_url(bestResult.url)
if not bestResult.content:
continue

View file

@ -291,7 +291,7 @@ class RecentSearchQueueItem(generic_queue.QueueItem):
logger.log('Updating provider caches with recent upload data')
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and x.enable_recentsearch]
providers = [x for x in sickbeard.providers.sortedProviderList() if x.is_active() and x.enable_recentsearch]
for curProvider in providers:
# spawn separate threads for each provider so we don't need to wait for providers with slow network operation
threads.append(threading.Thread(target=curProvider.cache.updateCache, name=origThreadName +

View file

@ -48,16 +48,16 @@ class TVCache:
def __init__(self, provider):
self.provider = provider
self.providerID = self.provider.getID()
self.providerID = self.provider.get_id()
self.providerDB = None
self.minTime = 10
def _getDB(self):
def get_db(self):
return CacheDBConnection(self.providerID)
def _clearCache(self):
if self.shouldClearCache():
myDB = self._getDB()
myDB = self.get_db()
myDB.action('DELETE FROM provider_cache WHERE provider = ?', [self.providerID])
def _get_title_and_url(self, item):
@ -69,7 +69,7 @@ class TVCache:
return data
def _checkAuth(self):
return self.provider._checkAuth()
return self.provider._check_auth()
def _checkItemAuth(self, title, url):
return True
@ -102,7 +102,7 @@ class TVCache:
cl.append(ci)
if len(cl) > 0:
myDB = self._getDB()
myDB = self.get_db()
myDB.mass_action(cl)
return []
@ -125,7 +125,7 @@ class TVCache:
url = self._translateLinkURL(url)
logger.log(u'Attempting to add item to cache: ' + title, logger.DEBUG)
return self._addCacheEntry(title, url)
return self.add_cache_entry(title, url)
else:
logger.log(
@ -134,7 +134,7 @@ class TVCache:
return None
def _getLastUpdate(self):
myDB = self._getDB()
myDB = self.get_db()
sqlResults = myDB.select('SELECT time FROM lastUpdate WHERE provider = ?', [self.providerID])
if sqlResults:
@ -147,7 +147,7 @@ class TVCache:
return datetime.datetime.fromtimestamp(lastTime)
def _getLastSearch(self):
myDB = self._getDB()
myDB = self.get_db()
sqlResults = myDB.select('SELECT time FROM lastSearch WHERE provider = ?', [self.providerID])
if sqlResults:
@ -163,7 +163,7 @@ class TVCache:
if not toDate:
toDate = datetime.datetime.today()
myDB = self._getDB()
myDB = self.get_db()
myDB.upsert('lastUpdate',
{'time': int(time.mktime(toDate.timetuple()))},
{'provider': self.providerID})
@ -172,7 +172,7 @@ class TVCache:
if not toDate:
toDate = datetime.datetime.today()
myDB = self._getDB()
myDB = self.get_db()
myDB.upsert('lastSearch',
{'time': int(time.mktime(toDate.timetuple()))},
{'provider': self.providerID})
@ -196,7 +196,7 @@ class TVCache:
return True
def _addCacheEntry(self, name, url, parse_result=None, indexer_id=0):
def add_cache_entry(self, name, url, parse_result=None, indexer_id=0):
# check if we passed in a parsed result or should we try and create one
if not parse_result:
@ -256,7 +256,7 @@ class TVCache:
return []
def listPropers(self, date=None, delimiter='.'):
myDB = self._getDB()
myDB = self.get_db()
sql = "SELECT * FROM provider_cache WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%' AND provider = ?"
if date != None:
@ -268,7 +268,7 @@ class TVCache:
neededEps = {}
cl = []
myDB = self._getDB()
myDB = self.get_db()
if type(episode) != list:
sqlResults = myDB.select(
'SELECT * FROM provider_cache WHERE provider = ? AND indexerid = ? AND season = ? AND episodes LIKE ?',
@ -331,9 +331,10 @@ class TVCache:
logger.log(u'Found result ' + title + ' at ' + url)
result = self.provider.getResult([epObj])
result = self.provider.get_result([epObj], url)
if None is result:
continue
result.show = showObj
result.url = url
result.name = title
result.quality = curQuality
result.release_group = curReleaseGroup

View file

@ -3914,14 +3914,14 @@ class ConfigProviders(Config):
if not name:
return json.dumps({'error': 'No Provider Name specified'})
providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
providerDict = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
tempProvider = newznab.NewznabProvider(name, '')
if tempProvider.getID() in providerDict:
return json.dumps({'error': 'Provider Name already exists as ' + providerDict[tempProvider.getID()].name})
if tempProvider.get_id() in providerDict:
return json.dumps({'error': 'Provider Name already exists as ' + providerDict[tempProvider.get_id()].name})
else:
return json.dumps({'success': tempProvider.getID()})
return json.dumps({'success': tempProvider.get_id()})
def saveNewznabProvider(self, name, url, key=''):
@ -3942,12 +3942,12 @@ class ConfigProviders(Config):
else:
providerDict[name].needs_auth = True
return providerDict[name].getID() + '|' + providerDict[name].config_str()
return providerDict[name].get_id() + '|' + providerDict[name].config_str()
else:
newProvider = newznab.NewznabProvider(name, url, key=key)
sickbeard.newznabProviderList.append(newProvider)
return newProvider.getID() + '|' + newProvider.config_str()
return newProvider.get_id() + '|' + newProvider.config_str()
def getNewznabCategories(self, name, url, key):
'''
@ -3969,7 +3969,7 @@ class ConfigProviders(Config):
return json.dumps({'success' : False, 'error': error})
#Get list with Newznabproviders
#providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
#providerDict = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
#Get newznabprovider obj with provided name
tempProvider= newznab.NewznabProvider(name, url, key)
@ -3980,7 +3980,7 @@ class ConfigProviders(Config):
def deleteNewznabProvider(self, nnid):
providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
providerDict = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
if nnid not in providerDict or providerDict[nnid].default:
return '0'
@ -3999,16 +3999,16 @@ class ConfigProviders(Config):
return json.dumps({'error': 'Invalid name specified'})
providerDict = dict(
zip([x.getID() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList))
zip([x.get_id() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList))
tempProvider = rsstorrent.TorrentRssProvider(name, url, cookies)
if tempProvider.getID() in providerDict:
return json.dumps({'error': 'Exists as ' + providerDict[tempProvider.getID()].name})
if tempProvider.get_id() in providerDict:
return json.dumps({'error': 'Exists as ' + providerDict[tempProvider.get_id()].name})
else:
(succ, errMsg) = tempProvider.validate_feed()
if succ:
return json.dumps({'success': tempProvider.getID()})
return json.dumps({'success': tempProvider.get_id()})
else:
return json.dumps({'error': errMsg})
@ -4024,17 +4024,17 @@ class ConfigProviders(Config):
providerDict[name].url = config.clean_url(url)
providerDict[name].cookies = cookies
return providerDict[name].getID() + '|' + providerDict[name].config_str()
return providerDict[name].get_id() + '|' + providerDict[name].config_str()
else:
newProvider = rsstorrent.TorrentRssProvider(name, url, cookies)
sickbeard.torrentRssProviderList.append(newProvider)
return newProvider.getID() + '|' + newProvider.config_str()
return newProvider.get_id() + '|' + newProvider.config_str()
def deleteTorrentRssProvider(self, id):
providerDict = dict(
zip([x.getID() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList))
zip([x.get_id() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList))
if id not in providerDict:
return '0'
@ -4055,7 +4055,7 @@ class ConfigProviders(Config):
provider_list = []
newznabProviderDict = dict(
zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
finishedNames = []
@ -4074,7 +4074,7 @@ class ConfigProviders(Config):
newProvider = newznab.NewznabProvider(cur_name, cur_url, key=cur_key)
cur_id = newProvider.getID()
cur_id = newProvider.get_id()
# if it already exists then update it
if cur_id in newznabProviderDict:
@ -4118,11 +4118,11 @@ class ConfigProviders(Config):
# delete anything that is missing
for curProvider in sickbeard.newznabProviderList:
if curProvider.getID() not in finishedNames:
if curProvider.get_id() not in finishedNames:
sickbeard.newznabProviderList.remove(curProvider)
torrentRssProviderDict = dict(
zip([x.getID() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList))
zip([x.get_id() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList))
finishedNames = []
if torrentrss_string:
@ -4139,7 +4139,7 @@ class ConfigProviders(Config):
newProvider = rsstorrent.TorrentRssProvider(curName, curURL, curCookies)
curID = newProvider.getID()
curID = newProvider.get_id()
# if it already exists then update it
if curID in torrentRssProviderDict:
@ -4154,7 +4154,7 @@ class ConfigProviders(Config):
# delete anything that is missing
for curProvider in sickbeard.torrentRssProviderList:
if curProvider.getID() not in finishedNames:
if curProvider.get_id() not in finishedNames:
sickbeard.torrentRssProviderList.remove(curProvider)
# do the enable/disable
@ -4163,7 +4163,7 @@ class ConfigProviders(Config):
curEnabled = config.to_int(curEnabled)
curProvObj = [x for x in sickbeard.providers.sortedProviderList() if
x.getID() == curProvider and hasattr(x, 'enabled')]
x.get_id() == curProvider and hasattr(x, 'enabled')]
if curProvObj:
curProvObj[0].enabled = bool(curEnabled)
@ -4179,31 +4179,31 @@ class ConfigProviders(Config):
if hasattr(curTorrentProvider, 'minseed'):
try:
curTorrentProvider.minseed = int(str(kwargs[curTorrentProvider.getID() + '_minseed']).strip())
curTorrentProvider.minseed = int(str(kwargs[curTorrentProvider.get_id() + '_minseed']).strip())
except:
curTorrentProvider.minseed = 0
if hasattr(curTorrentProvider, 'minleech'):
try:
curTorrentProvider.minleech = int(str(kwargs[curTorrentProvider.getID() + '_minleech']).strip())
curTorrentProvider.minleech = int(str(kwargs[curTorrentProvider.get_id() + '_minleech']).strip())
except:
curTorrentProvider.minleech = 0
if hasattr(curTorrentProvider, 'ratio'):
try:
curTorrentProvider.ratio = str(kwargs[curTorrentProvider.getID() + '_ratio']).strip()
curTorrentProvider.ratio = str(kwargs[curTorrentProvider.get_id() + '_ratio']).strip()
except:
curTorrentProvider.ratio = None
if hasattr(curTorrentProvider, 'digest'):
try:
curTorrentProvider.digest = str(kwargs[curTorrentProvider.getID() + '_digest']).strip()
curTorrentProvider.digest = str(kwargs[curTorrentProvider.get_id() + '_digest']).strip()
except:
curTorrentProvider.digest = None
if hasattr(curTorrentProvider, 'hash'):
try:
key = str(kwargs[curTorrentProvider.getID() + '_hash']).strip()
key = str(kwargs[curTorrentProvider.get_id() + '_hash']).strip()
if not starify(key, True):
curTorrentProvider.hash = key
except:
@ -4211,7 +4211,7 @@ class ConfigProviders(Config):
if hasattr(curTorrentProvider, 'api_key'):
try:
key = str(kwargs[curTorrentProvider.getID() + '_api_key']).strip()
key = str(kwargs[curTorrentProvider.get_id() + '_api_key']).strip()
if not starify(key, True):
curTorrentProvider.api_key = key
except:
@ -4219,13 +4219,13 @@ class ConfigProviders(Config):
if hasattr(curTorrentProvider, 'username'):
try:
curTorrentProvider.username = str(kwargs[curTorrentProvider.getID() + '_username']).strip()
curTorrentProvider.username = str(kwargs[curTorrentProvider.get_id() + '_username']).strip()
except:
curTorrentProvider.username = None
if hasattr(curTorrentProvider, 'password'):
try:
key = str(kwargs[curTorrentProvider.getID() + '_password']).strip()
key = str(kwargs[curTorrentProvider.get_id() + '_password']).strip()
if set('*') != set(key):
curTorrentProvider.password = key
except:
@ -4233,7 +4233,7 @@ class ConfigProviders(Config):
if hasattr(curTorrentProvider, 'passkey'):
try:
key = str(kwargs[curTorrentProvider.getID() + '_passkey']).strip()
key = str(kwargs[curTorrentProvider.get_id() + '_passkey']).strip()
if not starify(key, True):
curTorrentProvider.passkey = key
except:
@ -4242,54 +4242,54 @@ class ConfigProviders(Config):
if hasattr(curTorrentProvider, 'confirmed'):
try:
curTorrentProvider.confirmed = config.checkbox_to_value(
kwargs[curTorrentProvider.getID() + '_confirmed'])
kwargs[curTorrentProvider.get_id() + '_confirmed'])
except:
curTorrentProvider.confirmed = 0
if hasattr(curTorrentProvider, 'proxy'):
try:
curTorrentProvider.proxy.enabled = config.checkbox_to_value(
kwargs[curTorrentProvider.getID() + '_proxy'])
kwargs[curTorrentProvider.get_id() + '_proxy'])
except:
curTorrentProvider.proxy.enabled = 0
if hasattr(curTorrentProvider.proxy, 'url'):
try:
curTorrentProvider.proxy.url = str(kwargs[curTorrentProvider.getID() + '_proxy_url']).strip()
curTorrentProvider.proxy.url = str(kwargs[curTorrentProvider.get_id() + '_proxy_url']).strip()
except:
curTorrentProvider.proxy.url = None
if hasattr(curTorrentProvider, 'freeleech'):
try:
curTorrentProvider.freeleech = config.checkbox_to_value(
kwargs[curTorrentProvider.getID() + '_freeleech'])
kwargs[curTorrentProvider.get_id() + '_freeleech'])
except:
curTorrentProvider.freeleech = 0
if hasattr(curTorrentProvider, 'search_mode'):
try:
curTorrentProvider.search_mode = str(kwargs[curTorrentProvider.getID() + '_search_mode']).strip()
curTorrentProvider.search_mode = str(kwargs[curTorrentProvider.get_id() + '_search_mode']).strip()
except:
curTorrentProvider.search_mode = 'eponly'
if hasattr(curTorrentProvider, 'search_fallback'):
try:
curTorrentProvider.search_fallback = config.checkbox_to_value(
kwargs[curTorrentProvider.getID() + '_search_fallback'])
kwargs[curTorrentProvider.get_id() + '_search_fallback'])
except:
curTorrentProvider.search_fallback = 0 # these exceptions are catching unselected checkboxes
if hasattr(curTorrentProvider, 'enable_recentsearch'):
try:
curTorrentProvider.enable_recentsearch = config.checkbox_to_value(
kwargs[curTorrentProvider.getID() + '_enable_recentsearch'])
kwargs[curTorrentProvider.get_id() + '_enable_recentsearch'])
except:
curTorrentProvider.enable_recentsearch = 0 # these exceptions are actually catching unselected checkboxes
if hasattr(curTorrentProvider, 'enable_backlog'):
try:
curTorrentProvider.enable_backlog = config.checkbox_to_value(
kwargs[curTorrentProvider.getID() + '_enable_backlog'])
kwargs[curTorrentProvider.get_id() + '_enable_backlog'])
except:
curTorrentProvider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes
@ -4298,7 +4298,7 @@ class ConfigProviders(Config):
if hasattr(curNzbProvider, 'api_key'):
try:
key = str(kwargs[curNzbProvider.getID() + '_api_key']).strip()
key = str(kwargs[curNzbProvider.get_id() + '_api_key']).strip()
if not starify(key, True):
curNzbProvider.api_key = key
except:
@ -4306,34 +4306,34 @@ class ConfigProviders(Config):
if hasattr(curNzbProvider, 'username'):
try:
curNzbProvider.username = str(kwargs[curNzbProvider.getID() + '_username']).strip()
curNzbProvider.username = str(kwargs[curNzbProvider.get_id() + '_username']).strip()
except:
curNzbProvider.username = None
if hasattr(curNzbProvider, 'search_mode'):
try:
curNzbProvider.search_mode = str(kwargs[curNzbProvider.getID() + '_search_mode']).strip()
curNzbProvider.search_mode = str(kwargs[curNzbProvider.get_id() + '_search_mode']).strip()
except:
curNzbProvider.search_mode = 'eponly'
if hasattr(curNzbProvider, 'search_fallback'):
try:
curNzbProvider.search_fallback = config.checkbox_to_value(
kwargs[curNzbProvider.getID() + '_search_fallback'])
kwargs[curNzbProvider.get_id() + '_search_fallback'])
except:
curNzbProvider.search_fallback = 0 # these exceptions are actually catching unselected checkboxes
if hasattr(curNzbProvider, 'enable_recentsearch'):
try:
curNzbProvider.enable_recentsearch = config.checkbox_to_value(
kwargs[curNzbProvider.getID() + '_enable_recentsearch'])
kwargs[curNzbProvider.get_id() + '_enable_recentsearch'])
except:
curNzbProvider.enable_recentsearch = 0 # these exceptions are actually catching unselected checkboxes
if hasattr(curNzbProvider, 'enable_backlog'):
try:
curNzbProvider.enable_backlog = config.checkbox_to_value(
kwargs[curNzbProvider.getID() + '_enable_backlog'])
kwargs[curNzbProvider.get_id() + '_enable_backlog'])
except:
curNzbProvider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes

View file

@ -59,7 +59,7 @@ class SearchTest(test.SickbeardTestDBCase):
def __init__(self, something):
for provider in sickbeard.providers.sortedProviderList():
provider.getURL = self._fake_getURL
provider.get_url = self._fake_getURL
#provider.isActive = self._fake_isActive
super(SearchTest, self).__init__(something)