Fixing FLAC OR MP3 combined searches and existing bug in handling torrents containing unicode names

This commit is contained in:
Aaron Cohen
2012-07-09 00:36:45 -07:00
parent af108d3914
commit cb57abc321
+3 -3
View File
@@ -711,7 +711,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
bitrate = "(Lossless)" bitrate = "(Lossless)"
maxsize = 10000000000 maxsize = 10000000000
elif headphones.PREFERRED_QUALITY: elif headphones.PREFERRED_QUALITY:
format = "(FLAC OR MP3)" format = "FLAC OR MP3"
maxsize = 10000000000 maxsize = 10000000000
else: else:
format = "MP3" format = "MP3"
@@ -719,7 +719,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
query_items = ['artist:"%s"' % artistterm, query_items = ['artist:"%s"' % artistterm,
'album:"%s"' % albumterm, 'album:"%s"' % albumterm,
'format:"%s"' % format, 'format:(%s)' % format,
'size:[0 TO %d]' % maxsize, 'size:[0 TO %d]' % maxsize,
'-seeders:0'] # cut out dead torrents '-seeders:0'] # cut out dead torrents
if bitrate: if bitrate:
@@ -998,7 +998,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
torrent_file = open(download_path, 'rb') torrent_file = open(download_path, 'rb')
torrent_info = bencode.bdecode(torrent_file.read()) torrent_info = bencode.bdecode(torrent_file.read())
torrent_file.close() torrent_file.close()
torrent_folder_name = torrent_info['info'].get('name','') torrent_folder_name = torrent_info['info'].get('name','').decode('utf-8')
logger.info('Torrent folder name: %s' % torrent_folder_name) logger.info('Torrent folder name: %s' % torrent_folder_name)
except Exception, e: except Exception, e:
logger.error('Couldn\'t get name from Torrent file: %s' % e) logger.error('Couldn\'t get name from Torrent file: %s' % e)