Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: cp1252 -*-
- # Script made by João Rodrigues
- # Gets Album Covers from http://albumart.org and saves them in the album folder.
- # WARNING: THE COVERS MAY NOT BE THE BEST ONES! NOR THE CORRECT ONES (though they were in my tests..)!
- # 23.09.2008 @ Utrecht
- # Rant to: anaryin@gmail.com
- import os
- import urllib2
- import re
- from mutagen.mp3 import MP3
- import urllib
- # Accessing the music folder
- userName = os.path.expanduser('~').split('\\')[-1]
- musicPath = r'C:\Users\%s\Music' %userName
- allNames = []
- for root, dirs, files in os.walk(musicPath):
- for fileName in files:
- if fileName.split('.')[-1] == 'mp3':
- # Get audio file info
- audioFile = MP3(os.path.join(root, fileName))
- bandName = audioFile["TPE1"]
- albumName = audioFile["TALB"]
- if albumName not in allNames:
- allNames.append(str(albumName))
- # Get cover and save it
- print bandName, '-', albumName
- baseUrl = 'http://albumart.org/index.php?srchkey=%s&itempage=1&newsearch=1&searchindex=Music' %((str(bandName)+' '+str(albumName)).replace(' ', '+'))
- jpegReGex = '.(http://ecx.images-amazon.com/[\w / -]+.jpg).'
- matches = re.findall(jpegReGex, urllib2.urlopen(baseUrl).read())
- if matches:
- probableCandidate = matches[0]
- urllib.urlretrieve(probableCandidate, os.path.join(root, '%s - %s.jpg' %(bandName, albumName)))
- print "Finished"
- print "Press any key to exit.."
- raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement