Created
June 29, 2011 14:12
-
-
Save Yonaba/1053909 to your computer and use it in GitHub Desktop.
Retrieve ID3 tags from MP3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Custom function that collects ID3 tag from mp3 File | |
function getID3(filename) | |
local ID3 = {} | |
local file = assert(io.open(filename,"rb")) | |
file:seek("end") | |
file:seek("cur",-128) | |
ID3.TAG = file:read(3) | |
ID3.TITLE = file:read(30) | |
ID3.INTERPRET = file:read(30) | |
ID3.ALBUM = file:read(30) | |
ID3.YEAR = tonumber(file:read(4)) | |
ID3.COMMENT = file:read(30) | |
file:close() | |
for k in pairs(ID3) do | |
if not ID3[k] then table.remove(ID3,k) end | |
end | |
return ID3 | |
end | |
--Example | |
local tag = getID3("mp3.mp3") | |
for k,v in pairs(tag) do print(k,v) end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment