From bb71b3d3d9daa4095ba736dadc0de1f206659e34 Mon Sep 17 00:00:00 2001 From: Ade Date: Fri, 4 Sep 2015 21:09:22 +1200 Subject: [PATCH] Strike provider --- data/interfaces/default/config.html | 151 +++++++++++++++------------- headphones/config.py | 2 + headphones/searcher.py | 55 +++++++++- headphones/webserve.py | 4 +- 4 files changed, 141 insertions(+), 71 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index b51214e9..5688ce6d 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -516,59 +516,6 @@
Torrents -
-
- -
-
-
-
- - - e.g. http://localhost:9117/torznab/iptorrents -
-
- - -
-
- -
-
- <% - torznab_number = 2 - %> - %for torznab in config['extra_torznabs']: - <% - if torznab[2] == '1' or torznab[2] == 1: - torznab_enabled = "checked" - else: - torznab_enabled = "" - %> -
-
- - -
-
- - -
-
- -
-
- -
-
- <% - torznab_number += 1 - %> - %endfor - -
-
-
@@ -586,22 +533,6 @@
-
-
- -
-
-
- - -
-
- - -
-
-
-
@@ -679,6 +610,87 @@
+
+
+ +
+
+
+ + +
+
+
+ +
+
+ +
+
+
+
+ + + e.g. http://localhost:9117/torznab/iptorrents +
+
+ + +
+
+ +
+
+ <% + torznab_number = 2 + %> + %for torznab in config['extra_torznabs']: + <% + if torznab[2] == '1' or torznab[2] == 1: + torznab_enabled = "checked" + else: + torznab_enabled = "" + %> +
+
+ + +
+
+ + +
+
+ +
+
+ +
+
+ <% + torznab_number += 1 + %> + %endfor + +
+
+ +
+
+ +
+
+
+ + +
+
+ + +
+
+
+
@@ -2292,6 +2304,7 @@ initConfigCheckbox("#use_waffles"); initConfigCheckbox("#use_rutracker"); initConfigCheckbox("#use_whatcd"); + initConfigCheckbox("#use_strike"); initConfigCheckbox("#api_enabled"); initConfigCheckbox("#enable_https"); initConfigCheckbox("#customauth"); diff --git a/headphones/config.py b/headphones/config.py index 60ccf8fe..e2a122e2 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -221,6 +221,8 @@ _CONFIG_DEFINITIONS = { 'SONGKICK_ENABLED': (int, 'Songkick', 1), 'SONGKICK_FILTER_ENABLED': (int, 'Songkick', 0), 'SONGKICK_LOCATION': (str, 'Songkick', ''), + 'STRIKE': (int, 'Strike', 0), + 'STRIKE_RATIO': (str, 'Strike', ''), 'SUBSONIC_ENABLED': (int, 'Subsonic', 0), 'SUBSONIC_HOST': (str, 'Subsonic', ''), 'SUBSONIC_PASSWORD': (str, 'Subsonic', ''), diff --git a/headphones/searcher.py b/headphones/searcher.py index dbfab875..42ffb800 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -164,6 +164,8 @@ def get_seed_ratio(provider): seed_ratio = headphones.CONFIG.WAFFLES_RATIO elif provider == 'Mininova': seed_ratio = headphones.CONFIG.MININOVA_RATIO + elif provider == 'Strike': + seed_ratio = headphones.CONFIG.STRIKE_RATIO else: seed_ratio = None @@ -228,7 +230,7 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False): NZB_PROVIDERS = (headphones.CONFIG.HEADPHONES_INDEXER or headphones.CONFIG.NEWZNAB or headphones.CONFIG.NZBSORG or headphones.CONFIG.OMGWTFNZBS) NZB_DOWNLOADERS = (headphones.CONFIG.SAB_HOST or headphones.CONFIG.BLACKHOLE_DIR or headphones.CONFIG.NZBGET_HOST) - TORRENT_PROVIDERS = (headphones.CONFIG.TORZNAB or headphones.CONFIG.KAT or headphones.CONFIG.PIRATEBAY or headphones.CONFIG.OLDPIRATEBAY or headphones.CONFIG.MININOVA or headphones.CONFIG.WAFFLES or headphones.CONFIG.RUTRACKER or headphones.CONFIG.WHATCD) + TORRENT_PROVIDERS = (headphones.CONFIG.TORZNAB or headphones.CONFIG.KAT or headphones.CONFIG.PIRATEBAY or headphones.CONFIG.OLDPIRATEBAY or headphones.CONFIG.MININOVA or headphones.CONFIG.WAFFLES or headphones.CONFIG.RUTRACKER or headphones.CONFIG.WHATCD or headphones.CONFIG.STRIKE) results = [] myDB = db.DBConnection() @@ -1522,6 +1524,57 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, choose except Exception as e: logger.error(u"An unknown error occurred in the Old Pirate Bay parser: %s" % e) + # Strike + if headphones.CONFIG.STRIKE: + provider = "Strike" + s_term = term.replace("!", "") + providerurl = fix_url("https://getstrike.net/api/v2/torrents/search/?phrase=") + + providerurl = providerurl + s_term + "&category=Music" + + if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly: + format = "2" + providerurl = providerurl + "&subcategory=Lossless" + maxsize = 10000000000 + elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless: + format = "10" # MP3 and FLAC + maxsize = 10000000000 + else: + format = "8" # MP3 only + maxsize = 300000000 + + logger.info("Searching %s using term: %s" % (provider, s_term)) + data = request.request_json(url=providerurl) + + if not data or not data.get('torrents'): + logger.info("No results found on %s using search term: %s" % (provider, s_term)) + else: + for item in data['torrents']: + try: + rightformat = True + title = item['torrent_title'] + seeders = item['seeds'] + url = item['magnet_uri'] + size = int(item['size']) + subcategory = item['sub_category'] + + if format == 2: + if subcategory != "Lossless": + rightformat = False + + if rightformat and size < maxsize and minimumseeders < int(seeders): + match = True + logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) + else: + match = False + logger.info( + '%s is larger than the maxsize, the wrong format or has too little seeders for this category, skipping. (Size: %i bytes, Seeders: %d, Format: %s)', + title, size, int(seeders), rightformat) + + resultlist.append((title, size, url, provider, 'torrent', match)) + except Exception as e: + logger.exception("Unhandled exception in the Strike parser") + # Mininova if headphones.CONFIG.MININOVA: provider = "Mininova" diff --git a/headphones/webserve.py b/headphones/webserve.py index ecd26502..121e8667 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1106,6 +1106,8 @@ class WebInterface(object): "whatcd_username": headphones.CONFIG.WHATCD_USERNAME, "whatcd_password": headphones.CONFIG.WHATCD_PASSWORD, "whatcd_ratio": headphones.CONFIG.WHATCD_RATIO, + "use_strike": checked(headphones.CONFIG.STRIKE), + "strike_ratio": headphones.CONFIG.STRIKE_RATIO, "pref_qual_0": radio(headphones.CONFIG.PREFERRED_QUALITY, 0), "pref_qual_1": radio(headphones.CONFIG.PREFERRED_QUALITY, 1), "pref_qual_2": radio(headphones.CONFIG.PREFERRED_QUALITY, 2), @@ -1286,7 +1288,7 @@ class WebInterface(object): checked_configs = [ "launch_browser", "enable_https", "api_enabled", "use_blackhole", "headphones_indexer", "use_newznab", "newznab_enabled", "use_torznab", "torznab_enabled", "use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_oldpiratebay", "use_mininova", "use_waffles", "use_rutracker", - "use_whatcd", "preferred_bitrate_allow_lossless", "detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files", + "use_whatcd", "use_strike", "preferred_bitrate_allow_lossless", "detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files", "rename_files", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art", "embed_album_art", "embed_lyrics", "replace_existing_folders", "keep_original_folder", "file_underscores", "include_extras", "official_releases_only", "wait_until_release_date", "autowant_upcoming", "autowant_all", "autowant_manually_added", "do_not_process_unmatched", "keep_torrent_files", "music_encoder",