it needs physical contact to the mp3 data.
exchange all entries in main.shtml reading index.shtml
to the file sourcing this main.shtml file.
+build mp3read executing a simple "make".
+copy readtag.sh and mp3read in your $PATH location.
2)
4)
-make your mp3 data is mp3db compatible.
+make sure your mp3 data is mp3db compatible.
that means, no special character and small letters.
you may test ./make_mp3dbcompat script to do so.
this will definetly fuck your system, i mean it :)
-/* read mp3 info, hackbard */
+/* read mp3 header & tag, author: hackbard */
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
-#define MAX_READ 1024
+#define ID_TAG_SIZE 128
+#define MAX_BUF_SIZE 32
+#define MAX_TITLE 30
+#define MAX_ARTIST 30
+#define MAX_ALBUM 30
+#define MAX_YEAR 4
+#define MAX_COMMENT 30
+#define MAX_GENRE 1
+
#define MAX_FILENAME 32
-#define MAX_VER_ID 64
+
/*
info:
int main (int argc,char **argv)
{
- int file_fd,exit,count;
- unsigned char buf;
- unsigned char header[3];
- char mpeg_ver_id[MAX_VER_ID];
+ int file_fd;
+ int file_size;
+ unsigned char buf[MAX_BUF_SIZE];
char filename[MAX_FILENAME];
strcpy(filename,argv[1]);
+ file_size=atoi(argv[2]);
if((file_fd=open(filename,O_RDONLY))<=0) {
puts("open failed");
return -23;
}
- count=0;
- exit=0;
- while(!exit) {
- printf("count=%d\n",count++);
- read(file_fd,&buf,1);
- if(buf==0xff) {
- read(file_fd,&buf,1);
- if(buf>=0xe0) {
- puts("got frame header:");
- exit=1;
- header[0]=buf;
- read(file_fd,header+1,2);
-
- printf("debug: %x%x%x \n",header[0],header[1],header[2]);
-
- if(((header[0]&0x18)>>3)==0x00) strcpy(mpeg_ver_id,"MPEG Version 2.5");
- else if(((header[0]&0x18)>>3)==0x10) strcpy(mpeg_ver_id,"MPEG Version 2 (ISO/IEC 13818-3)");
- else if(((header[0]&0x18)>>3)==0x11) strcpy(mpeg_ver_id,"MPEG Version 1 (ISO/IEC 11172-3)");
- else strcpy(mpeg_ver_id,"unknown");
-
- printf("version: %s\n",mpeg_ver_id);
- }
- }
+ if((lseek(file_fd,file_size-ID_TAG_SIZE,SEEK_SET))<0) {
+ puts("cannot seek to id tag");
+ return -23;
+ }
+
+ /* verify TAG now */
+ if((read(file_fd,&buf,3))<3) {
+ puts("read failed (1)");
+ return -23;
}
+ if(strncmp(buf,"TAG",3)) {
+ puts("TAG not found");
+ return -23;
+ }
+
+ read(file_fd,&buf,MAX_TITLE);
+ printf("title: %s\n",buf);
+
+ read(file_fd,&buf,MAX_ARTIST);
+ printf("artist: %s\n",buf);
+
+ read(file_fd,&buf,MAX_ALBUM);
+ printf("album: %s\n",buf);
+
+ read(file_fd,&buf,MAX_YEAR);
+ printf("year: %s\n",buf);
+
+ read(file_fd,&buf,MAX_COMMENT);
+ printf("comment: %s\n",buf);
+
+ read(file_fd,&buf,MAX_GENRE);
+ printf("genre: %c\n",*buf);
+
close(file_fd);
- puts("");
- puts("done");
-
return 23;
}
-
-
-