def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list): logger.info('Starting post-processing for: %s - %s' % (release['ArtistName'], release['AlbumTitle'])) #start enconding if headphones.ENCODE: downloaded_track_list=encode.encode(albumpath) if headphones.EMBED_ALBUM_ART or headphones.ADD_ALBUM_ART: album_art_path = albumart.getAlbumArt(albumid) artwork = urllib.urlopen(album_art_path).read() if len(artwork) < 100: artwork = False logger.info("No suitable album art found. Not adding album art") if headphones.EMBED_ALBUM_ART and artwork: embedAlbumArt(artwork, downloaded_track_list) if headphones.CLEANUP_FILES: cleanupFiles(albumpath) if headphones.ADD_ALBUM_ART and artwork: addAlbumArt(artwork, albumpath) if headphones.CORRECT_METADATA: correctMetadata(albumid, release, downloaded_track_list) if headphones.EMBED_LYRICS: embedLyrics(downloaded_track_list) if headphones.RENAME_FILES: renameFiles(albumpath, downloaded_track_list, release) if headphones.MOVE_FILES and headphones.DESTINATION_DIR: albumpath = moveFiles(albumpath, release, tracks) if headphones.MOVE_FILES and not headphones.DESTINATION_DIR: logger.error('No DESTINATION_DIR has been set. Set "Destination Directory" to the parent directory you want to move the files to') pass myDB = db.DBConnection() # There's gotta be a better way to update the have tracks - sqlite trackcount = myDB.select('SELECT HaveTracks from artists WHERE ArtistID=?', [release['ArtistID']]) if not trackcount[0][0]: cur_track_count = 0 else: cur_track_count = trackcount[0][0] new_track_count = cur_track_count + len(downloaded_track_list) myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [new_track_count, release['ArtistID']]) myDB.action('UPDATE albums SET status = "Downloaded" WHERE AlbumID=?', [albumid]) myDB.action('UPDATE snatched SET status = "Processed" WHERE AlbumID=?', [albumid]) updateHave(albumpath) logger.info('Post-processing for %s - %s complete' % (release['ArtistName'], release['AlbumTitle'])) if headphones.PROWL_ONSNATCH: pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle'] logger.info(u"Prowl request") prowl = PROWL() prowl.notify(pushmessage,"Download and Postprocessing completed")
return False try: result = f.readlines() except Exception, e: logger.info(u"Error trying to get result from SAB, NZB not sent: ") return False if len(result) == 0: logger.info(u"No data returned from SABnzbd, NZB not sent") return False sabText = result[0].strip() logger.info(u"Result text from SAB: " + sabText) if sabText == "ok": logger.info(u"NZB sent to SAB successfully") if headphones.PROWL_ONSNATCH: logger.info(u"Prowl request") prowl = PROWL() prowl.notify(nzb.name,"Download started") return True elif sabText == "Missing authentication": logger.info(u"Incorrect username/password sent to SAB, NZB not sent") return False else: logger.info(u"Unknown failure sending NZB to sab. Return text is: " + sabText) return False