From 8ad84879f382351ce71165ef33487212f22ce586 Mon Sep 17 00:00:00 2001 From: doucheymcdoucherson Date: Sat, 8 Jun 2019 22:52:19 -0700 Subject: [PATCH 1/2] redacted - add album type to search filter --- headphones/searcher.py | 69 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 1e51dc58e..590f23002 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -50,7 +50,6 @@ # Persistent RED API object redobj = None - def fix_url(s, charset="utf-8"): """ Fix the URL so it is proper formatted and encoded. @@ -1206,6 +1205,37 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, reldate = album['ReleaseDate'] year = get_year_from_release_date(reldate) + + # Specify release types to filter by - used by Orpheus and Redacted + # Could be added to any Gazelle-based music tracker + album_type = "" + if album['Type'] == 'Album': + album_type = [gazellerelease_type.ALBUM] + if album['Type'] == 'Soundtrack': + album_type = [gazellerelease_type.SOUNDTRACK] + if album['Type'] == 'EP': + album_type = [gazellerelease_type.EP] + # No musicbrainz match for this type + # if album['Type'] == 'Anthology': + # album_type = [gazellerelease_type.ANTHOLOGY] + if album['Type'] == 'Compilation': + album_type = [gazellerelease_type.COMPILATION] + if album['Type'] == 'DJ-mix': + album_type = [gazellerelease_type.DJ_MIX] + if album['Type'] == 'Single': + album_type = [gazellerelease_type.SINGLE] + if album['Type'] == 'Live': + album_type = [gazellerelease_type.LIVE_ALBUM] + if album['Type'] == 'Remix': + album_type = [gazellerelease_type.REMIX] + if album['Type'] == 'Bootleg': + album_type = [gazellerelease_type.BOOTLEG] + if album['Type'] == 'Interview': + album_type = [gazellerelease_type.INTERVIEW] + if album['Type'] == 'Mixtape/Street': + album_type = [gazellerelease_type.MIXTAPE] + if album['Type'] == 'Other': + album_type = [gazellerelease_type.UNKNOWN] # MERGE THIS WITH THE TERM CLEANUP FROM searchNZB dic = {'...': '', ' & ': ' ', ' = ': ' ', '?': '', '$': 's', ' + ': ' ', '"': '', ',': ' ', @@ -1514,37 +1544,6 @@ def set_proxy(proxy_url): logger.info(u"Searching %s..." % provider) all_torrents = [] - album_type = "" - - # Specify release types to filter by - if album['Type'] == 'Album': - album_type = [gazellerelease_type.ALBUM] - if album['Type'] == 'Soundtrack': - album_type = [gazellerelease_type.SOUNDTRACK] - if album['Type'] == 'EP': - album_type = [gazellerelease_type.EP] - # No musicbrainz match for this type - # if album['Type'] == 'Anthology': - # album_type = [gazellerelease_type.ANTHOLOGY] - if album['Type'] == 'Compilation': - album_type = [gazellerelease_type.COMPILATION] - if album['Type'] == 'DJ-mix': - album_type = [gazellerelease_type.DJ_MIX] - if album['Type'] == 'Single': - album_type = [gazellerelease_type.SINGLE] - if album['Type'] == 'Live': - album_type = [gazellerelease_type.LIVE_ALBUM] - if album['Type'] == 'Remix': - album_type = [gazellerelease_type.REMIX] - if album['Type'] == 'Bootleg': - album_type = [gazellerelease_type.BOOTLEG] - if album['Type'] == 'Interview': - album_type = [gazellerelease_type.INTERVIEW] - if album['Type'] == 'Mixtape/Street': - album_type = [gazellerelease_type.MIXTAPE] - if album['Type'] == 'Other': - album_type = [gazellerelease_type.UNKNOWN] - for search_format in search_formats: if usersearchterm: all_torrents.extend( @@ -1644,16 +1643,18 @@ def set_proxy(proxy_url): if redobj and redobj.logged_in(): logger.info(u"Searching %s..." % provider) all_torrents = [] + for search_format in search_formats: if usersearchterm: all_torrents.extend( redobj.search_torrents(searchstr=usersearchterm, format=search_format, - encoding=bitrate_string)['results']) + encoding=bitrate_string, releasetype=album_type)['results']) else: all_torrents.extend(redobj.search_torrents(artistname=semi_clean_artist_term, groupname=semi_clean_album_term, format=search_format, - encoding=bitrate_string)['results']) + encoding=bitrate_string, + releasetype=album_type)['results']) # filter on format, size, and num seeders logger.info(u"Filtering torrents by format, maximum size, and minimum seeders...") From fd839347dff397a792a07ea3c6b416ae1ef6da7b Mon Sep 17 00:00:00 2001 From: doucheymcdoucherson Date: Sat, 8 Jun 2019 23:34:24 -0700 Subject: [PATCH 2/2] clean up whitespace --- headphones/searcher.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 590f23002..432999c58 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -50,6 +50,7 @@ # Persistent RED API object redobj = None + def fix_url(s, charset="utf-8"): """ Fix the URL so it is proper formatted and encoded. @@ -1205,7 +1206,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, reldate = album['ReleaseDate'] year = get_year_from_release_date(reldate) - + # Specify release types to filter by - used by Orpheus and Redacted # Could be added to any Gazelle-based music tracker album_type = ""