Slashdot Mirror


Efficiently Reading ID3v2 Tags Over HTTP?

Paul Crowley asks: "Given an HTTP URL for an MP3 file, what's the best way to read its ID3 tags on a GNU/Linux system? It shouldn't be necessary to fetch the whole file: HTTP byteranges should make it possible to fetch only the tiny fraction that's needed, for a big saving in network bandwidth. However, existing ID3v2 libraries are designed to read local files. Extending these libraries for this purpose, or implementing a new one, would be a big job. What's the clean solution - is FUSE the best way, or is there a simpler way that doesn't require root privs? Can I do it using the existing id3lib binary?"

3 of 65 comments (clear)

  1. Perhaps not this simple by Anonymous Coward · · Score: 3, Interesting

    Why couldn't you save the result of the remote HTTP access to a temporary local file and allow the libraries access to that file?

  2. You'd have to extend the API by Ayanami+Rei · · Score: 4, Interesting

    You'd better be prepared to extend the API with a URL handler...

    There's no point adding http:// support without also adding ftp:// URL support. FTP supports range fetching as well.

    So you have handlers for http:// URLs, ftp:// URLs, and file:// URLs.

    Then you'd have to map all the old (compatibility) file-oriented APIs into the new function handlers for file://. (Or maybe the opposite, map file:// into the old API, leaving the old implementation intact)

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  3. HTTP 499 by cryptor3 · · Score: 4, Interesting

    It seems like it shouldn't be that hard. You just initiate the HTTP transfer and then cancel it as soon as you have as much data as you need.

    I haven't actually done it, but speaking as a server operator, when I look through my server logs, you see some hits that end with status code 499, meaning that the transfer was aborted. So you just have the client software you're writing close the HTTP connection after it locates the end of the ID3 tag. It's probably not 100% efficient, but obviously a lot better than reading the whole MP3 file.

    I'm assuming you're doing this in C/C++, but I'll try to do a prototype in perl.