last day (14 days later) » 

7:03 AM
1
A: Fetching the title and artist of online MP3 files in Python 2.7

hkulekciI think, you should download mp3 to aremporary folder. After that, you xan read its information. For example, from urllib2 import Request, urlopen from mutagen.mp3 import MP3 def getInfo(url): start_byte = 0 end_byte = 5000 url = Request(url) url.add_header('Range', 'bytes=' + ...

 
I considered this, but it takes a long time to download it, and I need it to be pretty quick Do you know if there's a way to just download the ID3 tags?
Oh also, as I said; as of recently, line 5 doesn't work, it errors ValueError: too many values to unpack And when I change it to 1 value like this: filename = urlopen(url) Line 9 gives an error: TypeError: coercing to Unicode: need string or buffer, instance found
 
i fexed my error. Maybe you can read only mp3 file header with HTTP Range header. And you can parse it.
 
I'm confused. I still get this, even after your fix: TypeError: coercing to Unicode: need string or buffer, instance found
 
Oh sorry. I did not test, I was writing codes my pad. Now, i is working.
 
Awesome, thanks! Now is there any way to make it faster? Like maybe just downloading the ID3 somehow? If not, I'll take this :)
 
7:03 AM
i edit my code and it is faster than older. Do you know which bytes return me mp3 id3 header?
 
Awesome, that is so much faster, thanks! And no I don't, but I'll do some research
Hey, it told me to move this to a chat. That okay with you?
 
Share with us. you are welcome.
 
Well I'm getting this error now, no matter what range I put in:
EOFError: Requested 0x5722 of 0x1389 (test_file.mp3)
Oh wait, never mind, I changed the start_byte to 1 and it worked, I think
Let me test more
Okay, it works now! The only issue is I can't find information about an artist
:(
I believe I just need to find the correct range. Thank you very much!
 
8:06 AM
Ugh, I'm still having issues. :/
mutagen won't recognize it unless I download the entire thing
 
 
3 hours later…
11:30 AM
Got it!
 

last day (14 days later) »