mirror of
https://github.com/rembo10/headphones.git
synced 2026-04-17 10:29:28 +01:00
Small tidy up
This commit is contained in:
@@ -822,39 +822,47 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
|
||||
if headphones.RUTRACKER and rulogin:
|
||||
|
||||
provider = "rutracker.org"
|
||||
bitrate = False
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
format = 'lossless'
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1:
|
||||
format = 'lossless+mp3'
|
||||
maxsize = 10000000000
|
||||
# Ignore if release date not specified, results too unpredictable
|
||||
|
||||
if not year:
|
||||
logger.info(u'Release date not specified, ignoring for rutracker.org')
|
||||
else:
|
||||
format = 'mp3'
|
||||
maxsize = 300000000
|
||||
if headphones.PREFERRED_QUALITY == 2 and headphones.PREFERRED_BITRATE:
|
||||
bitrate = True
|
||||
|
||||
bitrate = False
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
format = 'lossless'
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1:
|
||||
format = 'lossless+mp3'
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
format = 'mp3'
|
||||
maxsize = 300000000
|
||||
if headphones.PREFERRED_QUALITY == 2 and headphones.PREFERRED_BITRATE:
|
||||
bitrate = True
|
||||
|
||||
# build search url based on above
|
||||
# build search url based on above
|
||||
|
||||
searchURL = rutracker.searchurl(artistterm, albumterm, year, format)
|
||||
logger.info(u'Parsing results from <a href="%s">rutracker.org</a>' % searchURL)
|
||||
searchURL = rutracker.searchurl(artistterm, albumterm, year, format)
|
||||
logger.info(u'Parsing results from <a href="%s">rutracker.org</a>' % searchURL)
|
||||
|
||||
# parse results and get best match
|
||||
rulist = rutracker.search(searchURL, maxsize, minimumseeders, albumid, bitrate)
|
||||
# parse results and get best match
|
||||
|
||||
# add best match to overall results list
|
||||
rulist = rutracker.search(searchURL, maxsize, minimumseeders, albumid, bitrate)
|
||||
|
||||
if rulist:
|
||||
for ru in rulist:
|
||||
title = ru[0].decode('utf-8')
|
||||
size = ru[1]
|
||||
url = ru[2]
|
||||
resultlist.append((title, size, url, provider))
|
||||
logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
else:
|
||||
logger.info(u"No valid results found from %s" % (provider))
|
||||
# add best match to overall results list
|
||||
|
||||
if rulist:
|
||||
for ru in rulist:
|
||||
title = ru[0].decode('utf-8')
|
||||
size = ru[1]
|
||||
url = ru[2]
|
||||
resultlist.append((title, size, url, provider))
|
||||
logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
else:
|
||||
logger.info(u"No valid results found from %s" % (provider))
|
||||
|
||||
|
||||
if headphones.ISOHUNT:
|
||||
|
||||
@@ -161,15 +161,16 @@ class Rutracker():
|
||||
|
||||
for torrent in torrentlist:
|
||||
|
||||
title = torrent[0].encode('utf-8')
|
||||
returntitle = torrent[0].encode('utf-8')
|
||||
url = torrent[1]
|
||||
seeders = torrent[2]
|
||||
size = torrent[3]
|
||||
|
||||
# Attempt to filter out unwanted
|
||||
|
||||
if 'Promo' not in title and 'promo' not in title and 'Vinyl' not in title and 'vinyl' not in title \
|
||||
and 'ongbook' not in title and 'TVRip' not in title and 'HDTV' not in title and 'DVD' not in title \
|
||||
title = returntitle.lower()
|
||||
|
||||
if 'promo' not in title and 'vinyl' not in title and 'songbook' not in title and 'tvrip' not in title and 'hdtv' not in title and 'dvd' not in title \
|
||||
and int(size) <= maxsize and int(seeders) >= minseeders:
|
||||
|
||||
# Check torrent info
|
||||
@@ -251,13 +252,13 @@ class Rutracker():
|
||||
if trackcount == hptrackcount:
|
||||
valid = True
|
||||
elif trackcount > hptrackcount:
|
||||
if 'eluxe' in title or 'dition' in title or 'apanese' in title or 'elease' in title:
|
||||
if 'deluxe' in title or 'edition' in title or 'japanese' in title:
|
||||
valid = True
|
||||
|
||||
# return 1st valid torrent if not checking by bitrate, else add to list and return at end
|
||||
|
||||
if valid:
|
||||
rulist.append((title, size, topicurl))
|
||||
rulist.append((returntitle, size, topicurl))
|
||||
if not bitrate:
|
||||
return rulist
|
||||
|
||||
|
||||
Reference in New Issue
Block a user