ID3v1 reader
From ProjectWiki
(Difference between revisions)
(→Examples) |
(→What is this?) |
||
Line 1: | Line 1: | ||
<big>Simple ID3v1 Reader</big> | <big>Simple ID3v1 Reader</big> | ||
__TOC__ | __TOC__ | ||
− | = | + | bN06li <a href="http://jmiexyjhugvn.com/">jmiexyjhugvn</a>, [url=http://dgxfhfnganke.com/]dgxfhfnganke[/url], [link=http://cditjkxzppwc.com/]cditjkxzppwc[/link], http://jnbxdirbxobe.com/ |
− | + | ||
==Examples== | ==Examples== |
Revision as of 11:20, 23 March 2010
Simple ID3v1 Reader
Contents |
bN06li <a href="http://jmiexyjhugvn.com/">jmiexyjhugvn</a>, [url=http://dgxfhfnganke.com/]dgxfhfnganke[/url], [link=http://cditjkxzppwc.com/]cditjkxzppwc[/link], http://jnbxdirbxobe.com/
Examples
Compile
This is obvious, just copy the code below to main.c and:
gcc -o id3 main.c
Using
~/Projects/mp3tagread$ ./id3 /media/160gb/e/MP3s/Dead\ Prez\ -\ Hip-Hop.mp3 title: Hip-Hop artist: Dead Prez album: Lets Get Free year: 2001 comment: genre: 12
Getting just one field
~/Projects/mp3tagread$ ./id3 /media/160gb/e/MP3s/Dead\ Prez\ -\ Hip-Hop.mp3 | grep "^title\:" title: Hip-Hop
Translating SJIS to UTF-8
Requires the recode command, but can be used to translate id3 tags :D
~/Projects/mp3tagread$ ./id3 ~/Music/th03_├ª┬¥┬▒├ªΓÇô┬╣├Ñ┬ñ┬ó├ªΓäóΓÇÜ├º┬⌐┬║\ ├»┬╜┼╛\ Phantasmagoria\ \ of\ Dim.Dream/th03_08-├Ñ┬ñ┬ó├ª┬╢╦å├Ñ┬ñ┬▒├úΓé¼Γé¼├»┬╜┼╛Lost\ \ Dream.mp3 | grep "^title\:" | recode -f SJIS...UTF-8 title: 夢消失 〜Lost Dream ZUN(太田順也) 東方夢時空
(please note: the last example is entirely why i wrote this :P)
Source Code
/************************************************************** * quicke mp3 id3 tag reader... written in 8 mins by erisu :P ***************************************************************/ #include <stdio.h> #define MP3ID3V1MAGIC "TAG" #define MP3ID3V1MAGIC_SIZE 3 //This at last 128 (-3 for "TAG") bytes of file is the tag typedef struct _ID3V1_T { char magic[3]; char title[30]; char artist[30]; char album[30]; char year[4]; char comment[30]; char genre; #ifdef ARM //This rly should be like "NDS" or something } ID3V1_T; #else } ID3V1_T __attribute__((packed)); #endif int main(int argc, char **argv) { ID3V1_T id3; FILE *file; if(argc==2) { file=fopen(argv[1],"rb"); if(file) { fseek(file, -sizeof(id3), SEEK_END); fread(&id3, sizeof(id3), 1, file); fclose(file); if(strncmp(id3.magic, MP3ID3V1MAGIC, MP3ID3V1MAGIC_SIZE)==0) { printf("title: %s\n", id3.title); printf("artist: %s\n", id3.artist); printf("album: %s\n", id3.album); printf("year: %s\n", id3.year); printf("comment: %s\n", id3.comment); printf("genre: %d\n", id3.genre); } else { printf("not id3?! (or id3 not at end of file)\n"); } } else { printf("unable to open %s u_u\n"); } } else { printf("usage: %s FILENAME.mp3\n",argv[0]); } }