From 5d81811db37ed7eaab37f422033e1ddd73002eb2 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 27 Jun 2012 19:35:45 +0530 Subject: [PATCH 01/14] Added a ' 'Last Updated' column to manageartists --- data/interfaces/default/css/style.css | 6 ++++-- data/interfaces/default/manageartists.html | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/data/interfaces/default/css/style.css b/data/interfaces/default/css/style.css index 8bfb9acf..acdcc96f 100644 --- a/data/interfaces/default/css/style.css +++ b/data/interfaces/default/css/style.css @@ -866,7 +866,8 @@ div#artistheader h2 a { text-align: left; } #artist_table th#status, -#artist_table th#albumart { +#artist_table th#albumart, +#artist_table th#lastupdated { min-width: 50px; text-align: left; } @@ -878,7 +879,8 @@ div#artistheader h2 a { text-align: left; vertical-align: middle; } -#artist_table td#status { +#artist_table td#status, +#artist_table td#lastupdated { min-width: 50px; text-align: left; vertical-align: middle; diff --git a/data/interfaces/default/manageartists.html b/data/interfaces/default/manageartists.html index 58f7f32b..7945d8ed 100644 --- a/data/interfaces/default/manageartists.html +++ b/data/interfaces/default/manageartists.html @@ -35,6 +35,7 @@ Artist Name Status Latest Album + Last Updated @@ -56,13 +57,20 @@ else: releasedate = '' albumdisplay = 'None' + + if not artist['LastUpdated']: + lastupdated = "Never" + else: + lastupdated = artist['LastUpdated'] + %> -
- ${artist['ArtistName']} +
+ ${artist['ArtistName']} ${artist['Status']} ${albumdisplay} + ${lastupdated} %endfor @@ -79,9 +87,9 @@ - \ No newline at end of file + diff --git a/data/interfaces/default/managealbums.html b/data/interfaces/default/managealbums.html new file mode 100644 index 00000000..a30dde6a --- /dev/null +++ b/data/interfaces/default/managealbums.html @@ -0,0 +1,148 @@ +<%inherit file="base.html" /> +<%! + from headphones import db + import headphones +%> + +<%def name="headerIncludes()"> +
+   +
+ « Back to manage overview + + + +<%def name="body()"> +
+
+

manageManage Albums

+
+
+
Mark selected albums as + + +
+ + + + + + + + + + + + + + + + %for album in albums: + <% + if album['Status'] == 'Skipped': + grade = 'Z' + elif album['Status'] == 'Wanted': + grade = 'X' + elif album['Status'] == 'Snatched': + grade = 'C' + else: + grade = 'A' + + myDB = db.DBConnection() + totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=?', [album['AlbumID']])) + havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=? AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle LIKE ?', [album['ArtistName'], album['AlbumTitle']])) + + try: + percent = (havetracks*100.0)/totaltracks + if percent > 100: + percent = 100 + except (ZeroDivisionError, TypeError): + percent = 0 + totaltracks = '?' + + avgbitrate = myDB.action("SELECT AVG(BitRate) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0] + if avgbitrate: + bitrate = str(int(avgbitrate)/1000) + ' kbps' + else: + bitrate = '' + + albumformatcount = myDB.action("SELECT COUNT(DISTINCT Format) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0] + if albumformatcount == 1: + albumformat = myDB.action("SELECT DISTINCT Format FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0] + elif albumformatcount > 1: + albumformat = 'Mixed' + else: + albumformat = '' + + lossy_formats = [str.upper(fmt) for fmt in headphones.LOSSY_MEDIA_FORMATS] + + %> + + + + + + + + + + + + %endfor + +
AlbumArtistDateTypeStatusHaveBitrateFormat
${album['AlbumTitle']}${album['ArtistName']}${album['ReleaseDate']}${album['Type']}${album['Status']}
${havetracks}/${totaltracks}
${bitrate}${albumformat}
+
+
+ + +<%def name="headIncludes()"> + + + +<%def name="javascriptIncludes()"> + + + + diff --git a/headphones/webserve.py b/headphones/webserve.py index 34052a2f..dcdb3ad7 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -148,7 +148,7 @@ class WebInterface(object): def markAlbums(self, ArtistID=None, action=None, **args): myDB = db.DBConnection() - if action == 'WantedNew': + if action == 'WantedNew' or 'WantedLossless': newaction = 'Wanted' else: newaction = action @@ -160,6 +160,8 @@ class WebInterface(object): searcher.searchforalbum(mbid, new=False) if action == 'WantedNew': searcher.searchforalbum(mbid, new=True) + if action == 'WantedLossless': + searcher.searchforalbum(mbid, lossless=True) if ArtistID: raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) else: @@ -229,7 +231,7 @@ class WebInterface(object): myDB = db.DBConnection() albums = myDB.select('SELECT * from albums') return serve_template(templatename="managealbums.html", title="Manage Albums", albums=albums) - manageArtists.exposed = True + manageAlbums.exposed = True def manageNew(self): return serve_template(templatename="managenew.html", title="Manage New Artists") From 64ae0a5db68673bdaab6d3bb20969c435f341d46 Mon Sep 17 00:00:00 2001 From: xbmc Date: Fri, 29 Jun 2012 11:15:59 +0100 Subject: [PATCH 04/14] Added some debug code on test for existing dest file --- headphones/postprocessor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 3a1e64c2..13af012a 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -418,9 +418,12 @@ def moveFiles(albumpath, release, tracks): except Exception, e: logger.warn('Error renaming %s: %s' % (files, e)) break + else: + logger.info('Destination file doesnt exist: %s' % files) + try: shutil.move(os.path.join(r, files), os.path.join(destination_path, files)) - except shutil.Error, e: + except Exception, e: logger.warn('Error moving file %s: %s' % (files, e)) # Chmod the directories using the folder_format (script courtesy of premiso!) From 1b00a7d94ec5fc0af4cb9179032e9f7a44c8370d Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 1 Jul 2012 12:05:20 +0530 Subject: [PATCH 05/14] Added a blacklist table to the database, modified webserve to put artistids on the blacklist if they're manually deleted, modified importer to skip blacklisted artistids if automatic import, if manually adding artist, delete from blacklist --- headphones/__init__.py | 1 + headphones/importer.py | 15 ++++++++++++--- headphones/webserve.py | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 3ec235d0..42acc958 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -679,6 +679,7 @@ def dbcheck(): c.execute('CREATE TABLE IF NOT EXISTS have (ArtistName TEXT, AlbumTitle TEXT, TrackNumber TEXT, TrackTitle TEXT, TrackLength TEXT, BitRate TEXT, Genre TEXT, Date TEXT, TrackID TEXT, Location TEXT, CleanName TEXT, Format TEXT)') c.execute('CREATE TABLE IF NOT EXISTS lastfmcloud (ArtistName TEXT, ArtistID TEXT, Count INTEGER)') c.execute('CREATE TABLE IF NOT EXISTS descriptions (ArtistID TEXT, ReleaseGroupID TEXT, ReleaseID TEXT, Summary TEXT, Content TEXT, LastUpdated TEXT)') + c.execute('CREATE TABLE IF NOT EXISTS blacklist (ArtistID TEXT UNIQUE)') c.execute('CREATE TABLE IF NOT EXISTS releases (ReleaseID TEXT, ReleaseGroupID TEXT, UNIQUE(ReleaseID, ReleaseGroupID))') c.execute('CREATE INDEX IF NOT EXISTS tracks_albumid ON tracks(AlbumID ASC)') c.execute('CREATE INDEX IF NOT EXISTS album_artistid_reldate ON albums(ArtistID ASC, ReleaseDate DESC)') diff --git a/headphones/importer.py b/headphones/importer.py index 73ececfd..fc0c1f56 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -56,14 +56,20 @@ def artistlist_to_mbids(artistlist, forced=False): except IndexError: logger.info('MusicBrainz query turned up no matches for: %s' % artist) continue + + # Check if it's blacklisted/various artists + myDB = db.DBConnection() + bl_artist = myDB.action('SELECT * FROM blacklist WHERE ArtistID=?', [artistid]).fetchone() + if bl_artist or artistid == various_artists_mbid: + logger.info("Artist ID for '%s' is either blacklisted or Various Artists. Not Adding: %s (to add artist, you must do it manually)" % (name, artistid)) + continue # Add to database if it doesn't exist - if artistid != various_artists_mbid and not is_exists(artistid): + if not is_exists(artistid): addArtisttoDB(artistid) # Just update the tracks if it does else: - myDB = db.DBConnection() havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=?', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist])) myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [havetracks, artistid]) @@ -82,7 +88,7 @@ def addArtistIDListToDB(artistidlist): def addArtisttoDB(artistid, extrasonly=False): - # Putting this here to get around the circular import + # Putting this here to get around the circular import. We're using this to update thumbnails for artist/albums from headphones import cache # Can't add various artists - throws an error from MB @@ -91,6 +97,9 @@ def addArtisttoDB(artistid, extrasonly=False): return myDB = db.DBConnection() + + # Delete from blacklist if it's on there + myDB.action('DELETE from blacklist WHERE ArtistID=?', [ArtistID]) # We need the current minimal info in the database instantly # so we don't throw a 500 error when we redirect to the artistPage diff --git a/headphones/webserve.py b/headphones/webserve.py index dcdb3ad7..40638337 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -138,6 +138,7 @@ class WebInterface(object): myDB.action('DELETE from artists WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from albums WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from tracks WHERE ArtistID=?', [ArtistID]) + myDB.action('INSERT OR REPLACE into blacklist VALUES (?)', [ArtistID]) raise cherrypy.HTTPRedirect("home") deleteArtist.exposed = True @@ -245,6 +246,7 @@ class WebInterface(object): myDB.action('DELETE from artists WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from albums WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from tracks WHERE ArtistID=?', [ArtistID]) + myDB.action('INSERT OR REPLACE into blacklist VALUES (?)', [ArtistID]) elif action == 'pause': controlValueDict = {'ArtistID': ArtistID} newValueDict = {'Status': 'Paused'} From 23682bc9d176ae0c889703f60a320d0e5dd3f540 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 1 Jul 2012 21:25:25 +0530 Subject: [PATCH 06/14] Fixed ArtistID->artistid typo --- headphones/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index fc0c1f56..284e2fff 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -99,7 +99,7 @@ def addArtisttoDB(artistid, extrasonly=False): myDB = db.DBConnection() # Delete from blacklist if it's on there - myDB.action('DELETE from blacklist WHERE ArtistID=?', [ArtistID]) + myDB.action('DELETE from blacklist WHERE ArtistID=?', [artistid]) # We need the current minimal info in the database instantly # so we don't throw a 500 error when we redirect to the artistPage From 5a00e9769c55d19386d40c5ffb34367ca6423181 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 3 Jul 2012 14:04:34 +0530 Subject: [PATCH 07/14] Removed log message if the destination file doesn't exist --- headphones/postprocessor.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 13af012a..70b19288 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -418,8 +418,6 @@ def moveFiles(albumpath, release, tracks): except Exception, e: logger.warn('Error renaming %s: %s' % (files, e)) break - else: - logger.info('Destination file doesnt exist: %s' % files) try: shutil.move(os.path.join(r, files), os.path.join(destination_path, files)) From c993e6ddb5ab01a5692acb11b792ee7761072cfb Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 3 Jul 2012 14:18:48 +0530 Subject: [PATCH 08/14] Removed the track matching from librarysync. It was probably a longshot anyways, and it was taking a lot of time and causing too many errors to make it worth it --- headphones/librarysync.py | 100 +------------------------------------- 1 file changed, 1 insertion(+), 99 deletions(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index b7b102ac..811dbda5 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -107,105 +107,7 @@ def libraryScan(dir=None): # The have table will become the new database for unmatched tracks (i.e. tracks with no associated links in the database myDB.action('INSERT INTO have (ArtistName, AlbumTitle, TrackNumber, TrackTitle, TrackLength, BitRate, Genre, Date, TrackID, Location, CleanName, Format) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [f_artist, f.album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid, file, helpers.cleanName(f_artist+' '+f.album+' '+f.title), f.format]) - logger.info('Completed scanning of directory: %s' % dir) - logger.info('Checking filepaths to see if we can find any matches') - - # Now check empty file paths to see if we can find a match based on their folder format - tracks = myDB.select('SELECT * from tracks WHERE Location IS NULL') - for track in tracks: - - release = myDB.action('SELECT * from albums WHERE AlbumID=?', [track['AlbumID']]).fetchone() - - try: - year = release['ReleaseDate'][:4] - except TypeError: - year = '' - - artist = release['ArtistName'].replace('/', '_') - album = release['AlbumTitle'].replace('/', '_') - releasetype = release['Type'].replace('/', '_') - - if release['ArtistName'].startswith('The '): - sortname = release['ArtistName'][4:] - else: - sortname = release['ArtistName'] - - if sortname.isdigit(): - firstchar = '0-9' - else: - firstchar = sortname[0] - - - albumvalues = { '$Artist': artist, - '$Album': album, - '$Year': year, - '$Type': releasetype, - '$First': firstchar, - '$artist': artist.lower(), - '$album': album.lower(), - '$year': year, - '$type': releasetype.lower(), - '$first': firstchar.lower() - } - - - folder = helpers.replace_all(headphones.FOLDER_FORMAT, albumvalues) - folder = folder.replace('./', '_/').replace(':','_').replace('?','_') - - if folder.endswith('.'): - folder = folder.replace(folder[len(folder)-1], '_') - - if not track['TrackNumber']: - tracknumber = '' - else: - tracknumber = '%02d' % track['TrackNumber'] - - title = track['TrackTitle'] - - trackvalues = { '$Track': tracknumber, - '$Title': title, - '$Artist': release['ArtistName'], - '$Album': release['AlbumTitle'], - '$Year': year, - '$track': tracknumber, - '$title': title.lower(), - '$artist': release['ArtistName'].lower(), - '$album': release['AlbumTitle'].lower(), - '$year': year - } - - new_file_name = helpers.replace_all(headphones.FILE_FORMAT, trackvalues).replace('/','_') + '.*' - - new_file_name = new_file_name.replace('?','_').replace(':', '_') - - full_path_to_file = os.path.normpath(os.path.join(headphones.MUSIC_DIR, folder, new_file_name)).encode(headphones.SYS_ENCODING, 'replace') - - match = glob.glob(full_path_to_file) - - if match: - - logger.info('Found a match: %s. Writing MBID to metadata' % match[0]) - - unipath = unicode(match[0], headphones.SYS_ENCODING, errors='replace') - - myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [unipath, track['TrackID']]) - myDB.action('DELETE from have WHERE Location=?', [unipath]) - - # Try to insert the appropriate track id so we don't have to keep doing this - try: - f = MediaFile(match[0]) - f.mb_trackid = track['TrackID'] - f.save() - myDB.action('UPDATE tracks SET BitRate=?, Format=? WHERE TrackID=?', [f.bitrate, f.format, track['TrackID']]) - - logger.debug('Wrote mbid to track: %s' % match[0]) - - except: - logger.error('Error embedding track id into: %s' % match[0]) - continue - - logger.info('Done checking empty filepaths') - logger.info('Done syncing library with directory: %s' % dir) + logger.info('Completed scanning directory: %s' % dir) # Clean up the new artist list unique_artists = {}.fromkeys(new_artists).keys() From e878266071a8d1d678b57060668da44e283ed5d0 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 3 Jul 2012 14:55:17 +0530 Subject: [PATCH 09/14] Fixed variable name in blacklist logger --- headphones/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index 284e2fff..b5978a66 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -61,7 +61,7 @@ def artistlist_to_mbids(artistlist, forced=False): myDB = db.DBConnection() bl_artist = myDB.action('SELECT * FROM blacklist WHERE ArtistID=?', [artistid]).fetchone() if bl_artist or artistid == various_artists_mbid: - logger.info("Artist ID for '%s' is either blacklisted or Various Artists. Not Adding: %s (to add artist, you must do it manually)" % (name, artistid)) + logger.info("Artist ID for '%s' is either blacklisted or Various Artists. To add artist, you must do it manually (Artist ID: %s)" % (artist, artistid)) continue # Add to database if it doesn't exist From df45255a4495cd8182eba81816ebfb45953c107f Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 3 Jul 2012 22:56:30 +0530 Subject: [PATCH 10/14] Possible fix for foreign characters on windows --- headphones/librarysync.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 811dbda5..fe9bfaa1 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -26,13 +26,10 @@ def libraryScan(dir=None): if not dir: dir = headphones.MUSIC_DIR - try: - dir = str(dir) - except UnicodeEncodeError: - dir = unicode(dir).encode('unicode_escape') + dir = dir.encode(headphones.SYS_ENCODING) if not os.path.isdir(dir): - logger.warn('Cannot find directory: %s. Not scanning' % dir) + logger.warn('Cannot find directory: %s. Not scanning' % dir.decode(headphones.SYS_ENCODING)) return myDB = db.DBConnection() @@ -57,14 +54,13 @@ def libraryScan(dir=None): if any(files.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS): song = os.path.join(r, files) - file = unicode(os.path.join(r, files), headphones.SYS_ENCODING, errors='replace') # Try to read the metadata try: f = MediaFile(song) except: - logger.error('Cannot read file: ' + file) + logger.error('Cannot read file: ' + song.decode(headphones.SYS_ENCODING)) continue # Grab the bitrates for the auto detect bit rate option @@ -87,7 +83,7 @@ def libraryScan(dir=None): track = myDB.action('SELECT TrackID from tracks WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND TrackTitle LIKE ?', [f_artist, f.album, f.title]).fetchone() if track: - myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE TrackID=?', [file, f.bitrate, f.format, track['TrackID']]) + myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE TrackID=?', [song.decode(headphones.SYS_ENCODING), f.bitrate, f.format, track['TrackID']]) continue # Try to match on mbid if available and we couldn't find a match based on metadata @@ -98,14 +94,14 @@ def libraryScan(dir=None): track = myDB.action('SELECT TrackID from tracks WHERE TrackID=?', [f.mb_trackid]).fetchone() if track: - myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE TrackID=?', [file, f.bitrate, f.format, track['TrackID']]) + myDB.action('UPDATE tracks SET Location=?, BitRate=?, Format=? WHERE TrackID=?', [song.decode(headphones.SYS_ENCODING), f.bitrate, f.format, track['TrackID']]) continue # if we can't find a match in the database on a track level, it might be a new artist or it might be on a non-mb release new_artists.append(f_artist) # The have table will become the new database for unmatched tracks (i.e. tracks with no associated links in the database - myDB.action('INSERT INTO have (ArtistName, AlbumTitle, TrackNumber, TrackTitle, TrackLength, BitRate, Genre, Date, TrackID, Location, CleanName, Format) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [f_artist, f.album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid, file, helpers.cleanName(f_artist+' '+f.album+' '+f.title), f.format]) + myDB.action('INSERT INTO have (ArtistName, AlbumTitle, TrackNumber, TrackTitle, TrackLength, BitRate, Genre, Date, TrackID, Location, CleanName, Format) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [f_artist, f.album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid, song.decode(headphones.SYS_ENCODING), helpers.cleanName(f_artist+' '+f.album+' '+f.title), f.format]) logger.info('Completed scanning directory: %s' % dir) From 7f2402ecaf9d46a540e1d7d9ebb3e553224d512e Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 4 Jul 2012 12:35:03 +0530 Subject: [PATCH 11/14] Fixed bug where marking albums as skipped/downloaded in bulk resulted in them being marked as wanted --- headphones/webserve.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 40638337..9b23824b 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -149,11 +149,12 @@ class WebInterface(object): def markAlbums(self, ArtistID=None, action=None, **args): myDB = db.DBConnection() - if action == 'WantedNew' or 'WantedLossless': + if action == 'WantedNew' or action == 'WantedLossless': newaction = 'Wanted' else: newaction = action for mbid in args: + logger.info("Marking %s as %s" % (mbid, newaction)) controlValueDict = {'AlbumID': mbid} newValueDict = {'Status': newaction} myDB.upsert("albums", newValueDict, controlValueDict) From 2b3a4a19ce51d3c423f4c63a3101e837450c7a3b Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 4 Jul 2012 20:48:28 -0300 Subject: [PATCH 12/14] Fixed a bug where Torrent files were not actually being written to disk, also caused seacher.py to fail marking the Album as snatched. Files will now be written to the TORRENTBLACKHOLE_DIR. This addresses a few open issues: 460, 716, and 720 --- headphones/searcher.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index c610a236..f95bc2a3 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -916,11 +916,19 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): # Get torrent name from .torrent, this is usually used by the torrent client as the folder name + torrent_name = torrent_folder_name + '.torrent' download_path = os.path.join(headphones.TORRENTBLACKHOLE_DIR, torrent_name) try: - torrent_file = open(download_path, 'rb').read() - torrent_info = bencode.bdecode(torrent_file) + #Write the torrent file to a path derived from the TORRENTBLACKHOLE_DIR and file name. + torrent_file = open(download_path, 'wb') + torrent_file.write(data) + torrent_file.close() + #Open the fresh torrent file again so we can extract the proper torrent name + #Used later in post-processing. + torrent_file = open(download_path, 'rb') + torrent_info = bencode.bdecode(torrent_file.read()) + torrent_file.close() torrent_folder_name = torrent_info['info'].get('name','') logger.info('Torrent folder name: %s' % torrent_folder_name) except Exception, e: From f685a63de2448db7e5f901be2fe0812e63cce347 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 5 Jul 2012 12:30:23 +0530 Subject: [PATCH 13/14] Changed 'Blackhole' to 'Usenet' on default config page --- data/interfaces/default/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index be53db7c..8cac8612 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -153,7 +153,7 @@
- Blackhole + Usenet
From 6e6da07f450305d8cde0889551f452db64be61c2 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 5 Jul 2012 12:36:11 +0530 Subject: [PATCH 14/14] Set default retention rate to 1500 days --- headphones/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 42acc958..54512bd9 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -298,7 +298,7 @@ def initialize(): DOWNLOAD_DIR = check_setting_str(CFG, 'General', 'download_dir', '') BLACKHOLE = bool(check_setting_int(CFG, 'General', 'blackhole', 0)) BLACKHOLE_DIR = check_setting_str(CFG, 'General', 'blackhole_dir', '') - USENET_RETENTION = check_setting_int(CFG, 'General', 'usenet_retention', '') + USENET_RETENTION = check_setting_int(CFG, 'General', 'usenet_retention', '1500') INCLUDE_EXTRAS = bool(check_setting_int(CFG, 'General', 'include_extras', 0)) AUTOWANT_UPCOMING = bool(check_setting_int(CFG, 'General', 'autowant_upcoming', 1)) AUTOWANT_ALL = bool(check_setting_int(CFG, 'General', 'autowant_all', 0))