예제 #1
0
def doPostProcessing(albumid, albumpath, release, tracks,
                     downloaded_track_list):

    logger.info('Starting post-processing for: %s - %s' %
                (release['ArtistName'], release['AlbumTitle']))
    #start encoding
    if headphones.MUSIC_ENCODER:
        downloaded_track_list = music_encoder.encode(albumpath)

        if not downloaded_track_list:
            return

    album_art_path = albumart.getAlbumArt(albumid)

    if headphones.EMBED_ALBUM_ART or headphones.ADD_ALBUM_ART:
        if album_art_path:
            artwork = urllib.urlopen(album_art_path).read()
        if not album_art_path or len(artwork) < 100:
            logger.info(
                "No suitable album art found from Amazon. Checking Last.FM...."
            )
            artwork = albumart.getCachedArt(albumid)
            if not artwork or len(artwork) < 100:
                artwork = False
                logger.info(
                    "No suitable album art found from Last.FM. 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 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'
        )
        albumpaths = [albumpath]
    elif headphones.MOVE_FILES and headphones.DESTINATION_DIR:
        albumpaths = moveFiles(albumpath, release, tracks)
    else:
        albumpaths = [albumpath]

    myDB = db.DBConnection()
    myDB.action('UPDATE albums SET status = "Downloaded" WHERE AlbumID=?',
                [albumid])
    myDB.action('UPDATE snatched SET status = "Processed" WHERE AlbumID=?',
                [albumid])

    # Update the have tracks for all created dirs:
    for albumpath in albumpaths:
        librarysync.libraryScan(dir=albumpath,
                                append=True,
                                ArtistID=release['ArtistID'],
                                ArtistName=release['ArtistName'])

    logger.info(u'Post-processing for %s - %s complete' %
                (release['ArtistName'], release['AlbumTitle']))

    if headphones.PROWL_ENABLED:
        pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle']
        logger.info(u"Prowl request")
        prowl = notifiers.PROWL()
        prowl.notify(pushmessage, "Download and Postprocessing completed")

    if headphones.XBMC_ENABLED:
        xbmc = notifiers.XBMC()
        if headphones.XBMC_UPDATE:
            xbmc.update()
        if headphones.XBMC_NOTIFY:
            xbmc.notify(release['ArtistName'], release['AlbumTitle'],
                        album_art_path)

    if headphones.NMA_ENABLED:
        nma = notifiers.NMA()
        nma.notify(release['ArtistName'], release['AlbumTitle'])

    if headphones.SYNOINDEX_ENABLED:
        syno = notifiers.Synoindex()
        for albumpath in albumpaths:
            syno.notify(albumpath)
예제 #2
0
        librarysync.libraryScan(dir=albumpath,
                                append=True,
                                ArtistID=release['ArtistID'],
                                ArtistName=release['ArtistName'])

    logger.info(u'Post-processing for %s - %s complete' %
                (release['ArtistName'], release['AlbumTitle']))

    if headphones.PROWL_ENABLED:
        pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle']
        logger.info(u"Prowl request")
        prowl = notifiers.PROWL()
        prowl.notify(pushmessage, "Download and Postprocessing completed")

    if headphones.XBMC_ENABLED:
        xbmc = notifiers.XBMC()
        if headphones.XBMC_UPDATE:
            xbmc.update()
        if headphones.XBMC_NOTIFY:
            xbmc.notify(release['ArtistName'], release['AlbumTitle'],
                        album_art_path)

    if headphones.NMA_ENABLED:
        nma = notifiers.NMA()
        nma.notify(release['ArtistName'], release['AlbumTitle'])

    if headphones.SYNOINDEX_ENABLED:
        syno = notifiers.Synoindex()
        for albumpath in albumpaths:
            syno.notify(albumpath)
예제 #3
0
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.MUSIC_ENCODER:
		downloaded_track_list=music_encoder.encode(albumpath)
	
	album_art_path = albumart.getAlbumArt(albumid)
	
	if headphones.EMBED_ALBUM_ART or headphones.ADD_ALBUM_ART:
		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 = notifiers.PROWL()
		prowl.notify(pushmessage,"Download and Postprocessing completed")
		
	if headphones.XBMC_ENABLED:
		xbmc = notifiers.XBMC()
		if headphones.XBMC_UPDATE:
			xbmc.update()
		if headphones.XBMC_NOTIFY:
			xbmc.notify(release['ArtistName'], release['AlbumTitle'], album_art_path)
			
	if headphones.NMA_ENABLED:
		nma = notifiers.NMA()
		nma.notify(release['ArtistName'], release['AlbumTitle'])