From 205126889179049dd33df8278ef967d845f06e4e Mon Sep 17 00:00:00 2001 From: JackDandy Date: Mon, 13 Jul 2015 10:39:20 +0100 Subject: [PATCH] Change refactor, PEP8, code convention cleanse for nzb/torrent code and remove newzbin remnants. --- .gitignore | 10 +- autoProcessTV/autoProcessTV.cfg.sample | 12 +- autoProcessTV/setup.py | 18 +- .../{GFTracker.png => gftracker.png} | Bin .../interfaces/default/config_providers.tmpl | 288 +++++------- gui/slick/interfaces/default/history.tmpl | 8 +- .../default/manage_failedDownloads.tmpl | 4 +- sickbeard/__init__.py | 437 ++++++++---------- sickbeard/clients/generic.py | 2 +- sickbeard/config.py | 2 +- sickbeard/exceptions.py | 4 - sickbeard/helpers.py | 2 +- sickbeard/nzbget.py | 2 +- sickbeard/properFinder.py | 9 +- sickbeard/providers/__init__.py | 4 +- sickbeard/providers/alpharatio.py | 12 +- sickbeard/providers/animenzb.py | 77 ++- sickbeard/providers/beyondhd.py | 11 +- sickbeard/providers/bitsoup.py | 12 +- sickbeard/providers/btn.py | 12 +- sickbeard/providers/freshontv.py | 12 +- sickbeard/providers/generic.py | 370 ++++++++------- sickbeard/providers/gftracker.py | 14 +- sickbeard/providers/hdbits.py | 14 +- sickbeard/providers/iptorrents.py | 12 +- sickbeard/providers/kat.py | 6 +- sickbeard/providers/morethan.py | 12 +- sickbeard/providers/newznab.py | 65 ++- sickbeard/providers/nyaatorrents.py | 103 ++--- sickbeard/providers/omgwtfnzbs.py | 262 +++++++---- sickbeard/providers/pisexy.py | 14 +- sickbeard/providers/rarbg.py | 12 +- sickbeard/providers/rsstorrent.py | 12 +- sickbeard/providers/scc.py | 12 +- sickbeard/providers/speedcd.py | 12 +- sickbeard/providers/strike.py | 11 +- sickbeard/providers/thepiratebay.py | 14 +- sickbeard/providers/tokyotoshokan.py | 148 ++---- sickbeard/providers/torrentbytes.py | 12 +- sickbeard/providers/torrentday.py | 12 +- sickbeard/providers/torrentleech.py | 12 +- sickbeard/providers/torrentshack.py | 12 +- sickbeard/providers/totv.py | 10 +- sickbeard/providers/womble.py | 2 +- sickbeard/rssfeeds.py | 25 +- sickbeard/sab.py | 13 +- sickbeard/search.py | 20 +- sickbeard/search_queue.py | 2 +- sickbeard/tvcache.py | 31 +- sickbeard/webserve.py | 90 ++-- tests/snatch_tests.py | 2 +- 51 files changed, 1083 insertions(+), 1191 deletions(-) rename gui/slick/images/providers/{GFTracker.png => gftracker.png} (100%) diff --git a/.gitignore b/.gitignore index 33ad38e9..59e5ad43 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/autoProcessTV/autoProcessTV.cfg.sample b/autoProcessTV/autoProcessTV.cfg.sample index 7a213d29..15dc900c 100644 --- a/autoProcessTV/autoProcessTV.cfg.sample +++ b/autoProcessTV/autoProcessTV.cfg.sample @@ -1,7 +1,7 @@ -[SickBeard] -host=localhost -port=8081 -username= -password= -web_root= +[SickBeard] +host=localhost +port=8081 +username= +password= +web_root= ssl=0 \ No newline at end of file diff --git a/autoProcessTV/setup.py b/autoProcessTV/setup.py index c79e4fd6..bede0efe 100755 --- a/autoProcessTV/setup.py +++ b/autoProcessTV/setup.py @@ -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', '.') diff --git a/gui/slick/images/providers/GFTracker.png b/gui/slick/images/providers/gftracker.png similarity index 100% rename from gui/slick/images/providers/GFTracker.png rename to gui/slick/images/providers/gftracker.png diff --git a/gui/slick/interfaces/default/config_providers.tmpl b/gui/slick/interfaces/default/config_providers.tmpl index 8e657dae..75f99d08 100644 --- a/gui/slick/interfaces/default/config_providers.tmpl +++ b/gui/slick/interfaces/default/config_providers.tmpl @@ -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 @@

At least one provider is required but two are recommended.

#if $methods_notused -
<%= '/'.join(x for x in methods_notused) %> providers can be enabled in Search Settings
+
<%= '/'.join(x for x in methods_notused) %> providers can be enabled in Search Settings
#else
#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()
  • - /> - $curProvider.name - $curProvider.name + /> + $curProvider.name + $curProvider.name <%= '*' if not curProvider.supportsBacklog else '' %>
  • @@ -124,7 +124,7 @@ ##

    !

    Provider is NOT WORKING

    - "/> +
    @@ -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 #for $cur_provider in $provider_config_list_enabled: - + #end for #end if #if $provider_config_list #for $cur_provider in $provider_config_list - + #end for #end if @@ -187,76 +187,71 @@
    - #for $curNewznabProvider in [$curProvider for $curProvider in $sickbeard.newznabProviderList] -
    +
    #if $curNewznabProvider.default and $curNewznabProvider.needs_auth
    -
    -
    #end if - - #if $hasattr($curNewznabProvider, 'enable_recentsearch'): + #if $hasattr($curNewznabProvider, 'enable_recentsearch') and $curNewznabProvider.supportsBacklog:
    -
    #end if - - #if $hasattr($curNewznabProvider, 'enable_backlog'): + #if $hasattr($curNewznabProvider, 'enable_backlog') and $curNewznabProvider.supportsBacklog:
    -
    #end if - - #if $hasattr($curNewznabProvider, 'search_mode'): + #if $hasattr($curNewznabProvider, 'search_mode') and $curNewznabProvider.supportsBacklog:
    Season search mode

    when searching for complete seasons, search for packs or collect single episodes

    #end if - - #if $hasattr($curNewznabProvider, 'search_fallback'): + #if $hasattr($curNewznabProvider, 'search_fallback') and $curNewznabProvider.supportsBacklog:
    -
    #end for +## +## #for $curNzbProvider in [$curProvider for $curProvider in $sickbeard.providers.sortedProviderList() if $curProvider.providerType == $GenericProvider.NZB and $curProvider not in $sickbeard.newznabProviderList]: -
    +
    #if $hasattr($curNzbProvider, 'username'):
    -
    #end if - #if $hasattr($curNzbProvider, 'api_key'):
    -
    #end if - - - #if $hasattr($curNzbProvider, 'enable_recentsearch'): + #if $hasattr($curNzbProvider, 'enable_recentsearch') and $curNzbProvider.supportsBacklog:
    -
    #end if - - #if $hasattr($curNzbProvider, 'enable_backlog'): + #if $hasattr($curNzbProvider, 'enable_backlog') and $curNzbProvider.supportsBacklog:
    -
    #end if - - #if $hasattr($curNzbProvider, 'search_fallback'): + #if $hasattr($curNzbProvider, 'search_mode') and $curNzbProvider.supportsBacklog:
    -
    + #end if + #if $hasattr($curNzbProvider, 'search_fallback') and $curNzbProvider.supportsBacklog: +
    +
    #end if - - #if $hasattr($curNzbProvider, 'search_mode'): + #if not $curNzbProvider.supportsBacklog:
    - - - + The latest releases are the focus of this provider, no backlog searching
    #end if -
    #end for +## +## #for $curTorrentProvider in [$curProvider for $curProvider in $sickbeard.providers.sortedProviderList() if $curProvider.providerType == $GenericProvider.TORRENT]: -
    +
    #if $hasattr($curTorrentProvider, 'api_key'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'digest'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'hash'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'username'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'password'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'passkey'):
    -
    #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'}
    -
    #end if - #if $hasattr($curTorrentProvider, 'minseed'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'minleech'):
    -
    #end if - #if $hasattr($curTorrentProvider, 'proxy'):
    -
    - #if $hasattr($curTorrentProvider.proxy, 'url'): -
    -