From 906eb10b86fb9b99de7583b723cc285dbef4cab5 Mon Sep 17 00:00:00 2001 From: GeorgeY Date: Thu, 9 Jul 2015 16:53:01 -0700 Subject: [PATCH] Added Eyed3 Library for automating metadata information of each mp3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I noticed that the filenames were being formatted but there was no metadata being put into them. When I tried asking my music app for album covers, it couldn’t provide any because the metadata was empty. I’m using the Eyed3 Python library which allows mp3 metadata tagging for Artist and Title. --- hypeme.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hypeme.py b/hypeme.py index b23ee36..638b31e 100644 --- a/hypeme.py +++ b/hypeme.py @@ -27,6 +27,7 @@ import json import string import os +import eyed3 ##############AREA_TO_SCRAPE################ # This is the general area that you'd @@ -146,6 +147,8 @@ def download_songs(self, tracks, cookie): mp3_song_file = open(filename, "wb") mp3_song_file.write(download_response.read() ) mp3_song_file.close() + + edit_metadata(filename, artist, title) except urllib2.HTTPError, e: print 'HTTPError = ' + str(e.code) + " trying hypem download url." except urllib2.URLError, e: @@ -153,7 +156,12 @@ def download_songs(self, tracks, cookie): except Exception, e: print 'generic exception: ' + str(e) - +def edit_metadata(filename, artist, title): + song = eyed3.load(filename) + song.initTag() + song.tag.artist = unicode(artist, "utf-8") + song.tag.title = unicode(title, "utf-8") + song.tag.save() def main():