|
Register | Blogging | Today's Posts | Search |
![]() |
|
Thread Tools | Display Modes |
|
![]() |
#1 (permalink) |
thirsty ears
Join Date: Sep 2009
Location: Boulder
Posts: 742
|
![]()
tore, are you willing to share that script? it sounds incredibly useful!
at one point i tried using various plugins to grab genre/style info from AllMusic, but never got very good results... i'm not sure how much i would like using someone else's categorizations, but i can always back up tags and restore them if things don't work out ![]()
__________________
my flac collection |
![]() |
![]() |
![]() |
#2 (permalink) | |
Juicious Maximus III
Join Date: Nov 2008
Location: Scabb Island
Posts: 6,525
|
![]() Quote:
![]() It doesn't work for all files, but at least for more than 3/4ths of my own collection. Aside from artists and albums having wrong titles, a possible problem is when there are more bands with the same name. Discogs register them as Band (1), Band (2) and so on (f.ex Arsenal (1), Arsenal (2) etc.) and since we don't normally have numbers in parantheses after band names, those may not get tagged. Anyways, to make it work, there are a few things you're gonna need: And these two, both found at the same location : The latter of those two contains some files and folders (ex. python25.dll) that all need to be located in your base foobar folder. The files and folders should look something like this : Code:
C:\Program Files\foobar2000>dir p*.dll /s/b & dir *grab* /s/b & dir pygrabber\* /s/b & ver C:\Program Files\foobar2000\python25.dll C:\Program Files\foobar2000\lyrics_grabber_provider.cfg C:\Program Files\foobar2000\pygrabber C:\Program Files\foobar2000\components\foo_grabber_python.dll C:\Program Files\foobar2000\components\foo_lyricsgrabber.dll C:\Program Files\foobar2000\pygrabber\libs C:\Program Files\foobar2000\pygrabber\newscripts C:\Program Files\foobar2000\pygrabber\scripts C:\Program Files\foobar2000\pygrabber\system C:\Program Files\foobar2000\pygrabber\newscripts\newscripts.rar C:\Program Files\foobar2000\pygrabber\scripts\AZLyrics.py C:\Program Files\foobar2000\pygrabber\scripts\DarkLyrics.py C:\Program Files\foobar2000\pygrabber\scripts\Discogs_GetGenre.py C:\Program Files\foobar2000\pygrabber\scripts\Discogs_GetStyle.py C:\Program Files\foobar2000\pygrabber\scripts\LastFm_Bio.py C:\Program Files\foobar2000\pygrabber\scripts\LastFm_TopTag.py C:\Program Files\foobar2000\pygrabber\scripts\LastFm_TrackTags.py C:\Program Files\foobar2000\pygrabber\scripts\LeosLyrics.py C:\Program Files\foobar2000\pygrabber\scripts\LyrDB.py C:\Program Files\foobar2000\pygrabber\scripts\Lyricist(LRC).py C:\Program Files\foobar2000\pygrabber\scripts\TTPlayer(LRC).py C:\Program Files\foobar2000\pygrabber\system\autoexec.py C:\Program Files\foobar2000\pygrabber\system\BeautifulSoup.py C:\Program Files\foobar2000\pygrabber\system\BeautifulSoup.pyc C:\Program Files\foobar2000\pygrabber\system\Html2Text.py C:\Program Files\foobar2000\pygrabber\system\Html2Text.pyc C:\Program Files\foobar2000\pygrabber\system\LevenshteinDistance.py C:\Program Files\foobar2000\pygrabber\system\LevenshteinDistance.pyc C:\Program Files\foobar2000\pygrabber\system\Lucky.py C:\Program Files\foobar2000\pygrabber\system\Lucky.pyc C:\Program Files\foobar2000\pygrabber\system\pyexpat.pyd C:\Program Files\foobar2000\pygrabber\system\Python25.zip C:\Program Files\foobar2000\pygrabber\system\unicodedata.pyd C:\Program Files\foobar2000\pygrabber\system\_socket.pyd ![]() Your foobar folder will now contain a folder called "/pygrabber/scripts". This is where you should put the script I've written. The simplest way to do it I guess is just paste the script here for you to copy and paste. Then I can show you the changes you should make. So, copy the following script and save it in a text file in the scripts folder. Rename it to something like "tores_discogs_script.py" and then you may want to edit it and have a closer look at the red parts : Code:
import urllib, urllib2, gzip, cStringIO import xml.etree.ElementTree from xml.dom import minidom from encodings import utf_8 from grabber import LyricProviderBase class Discogs_GetGenre(LyricProviderBase): def GetName(self): return 'Discogs GenStyles' def GetVersion(self): return '0.1' def GetURL(self): return 'http://www.discogs.com' def Query(self, handles, status, abort): result = [] api_key = '783001745d' for handle in handles: status.Advance() if abort.Aborting(): return result artist = handle.Format("[%artist%]") album = handle.Format("[%album%]") album_file = open("C:\Python26\!album.txt", "r") test = album_file.read() album_file.close() try: if album == test: text_file = open("C:\Python26\!tag3.txt", "r") writeout = text_file.read() text_file.close() result.append(writeout) else: URL_s = 'http://www.discogs.com/search?type=all&q=' + artist.lower().replace(' ','+') + '+' + album.lower().replace(' ','+') + '&f=xml&api_key=' + api_key request = urllib2.Request(URL_s) request.add_header('Accept-Encoding', 'gzip') response = urllib2.urlopen(request) data = response.read() unzipped_data = gzip.GzipFile(fileobj = cStringIO.StringIO(data)).read() res = minidom.parseString(unzipped_data) uri_1 = res.getElementsByTagName("uri")[0] rel_id = uri_1.childNodes[0].data.encode('utf-8').rpartition('/')[2] URL_r = 'http://www.discogs.com/release/' + rel_id + '?f=xml&api_key=' + api_key request = urllib2.Request(URL_r) request.add_header('Accept-Encoding', 'gzip') response = urllib2.urlopen(request) data = response.read() unzipped_data = gzip.GzipFile(fileobj = cStringIO.StringIO(data)).read() xml.etree.ElementTree.fromstring(unzipped_data) def getGenres(tree): genres = [] release = tree.find('release') genreList = release.find('genres') if genreList: for i in genreList: genres.append(i.text) return genres def getStyles(tree): styles = [] release = tree.find('release') styleList = release.find('styles') if styleList: for i in styleList: styles.append(i.text) return styles lyric=getGenres(xml.etree.ElementTree.fromstring(unzipped_data)) lyric.append('//') lyric.append(getStyles(xml.etree.ElementTree.fromstring(unzipped_data))) lyric=str(lyric).strip('[').strip(']').replace(',', ';').replace('\'','').replace('[','').replace('Folk; World; & Country','Folk, World, & Country') result.append(lyric) album_file = open("C:\Python26\!album.txt", "w") album_file.write(album) album_file.close() text_file = open("C:\Python26\!tag3.txt", "w") text_file.write(lyric) text_file.close() except Exception, e: traceback.print_exc(file=sys.stdout) result.append('') album_file = open("C:\Python26\!album.txt", "w") album_file.write(album) album_file.close() text_file = open("C:\Python26\!tag3.txt", "w") text_file.write('') text_file.close() continue return result if __name__ == "__main__": LyricProviderInstance = Discogs_GetGenre()
__________________
Something Completely Different |
|
![]() |
![]() |
![]() |
|