Fixed path for getting cached album art in postprocessor

This commit is contained in:
rembo10
2012-07-18 18:59:09 +05:30
parent 5bb0c01654
commit 158f33845b
2 changed files with 18 additions and 3 deletions

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Headphones. If not, see <http://www.gnu.org/licenses/>.
from headphones import db
from headphones import db, cache
def getAlbumArt(albumid):
@@ -23,3 +23,18 @@ def getAlbumArt(albumid):
url = 'http://ec1.images-amazon.com/images/P/%s.01.LZZZZZZZ.jpg' % asin
return url
def getCachedArt(albumid):
c = Cache()
artwork_path = c.get_artwork_from_cache(AlbumID=albumid)
if not artwork_path:
return None
if artwork_path.startswith('http://'):
artwork = urllib.urlopen(artwork_path).read()
return artwork
else:
artwork = open(artwork_path, "r").read()
return artwork

View File

@@ -26,7 +26,7 @@ from lib.beets import autotag
from lib.beets.mediafile import MediaFile
import headphones
from headphones import db, albumart, lyrics, logger, helpers, cache
from headphones import db, albumart, lyrics, logger, helpers
postprocessor_lock = threading.Lock()
@@ -239,7 +239,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
artwork = urllib.urlopen(album_art_path).read()
if len(artwork) < 100:
logger.info("No suitable album art found from Amazon. Checking Last.FM....")
artwork = urllib.urlopen(cache.getArtwork(AlbumID=albumid)).read()
artwork = albumart.getCachedArt(albumid)
if len(artwork) < 100:
artwork = False
logger.info("No suitable album art found from Last.FM. Not adding album art")