From e5f833c181af20877dae4a4cb63e339df5260ea7 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Sat, 16 Apr 2005 20:54:36 +0000 Subject: [PATCH] framework for testing metadata scanners outside of mt-daapd --- src/scanner-driver.c | 144 +++++++++++++++++++++++++++++++++++++++++++ src/scanner.mk | 6 ++ 2 files changed, 150 insertions(+) create mode 100644 src/scanner-driver.c create mode 100644 src/scanner.mk diff --git a/src/scanner-driver.c b/src/scanner-driver.c new file mode 100644 index 00000000..9a1ec770 --- /dev/null +++ b/src/scanner-driver.c @@ -0,0 +1,144 @@ +/* + * $Id$ + * Simple driver to test tag scanners without the overhead + * of all of mt-daapd + * + * Copyright (C) 2005 Ron Pedde (ron@pedde.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include + +#include "err.h" +#include "mp3-scanner.h" + +/* + * externs + */ +extern int scan_get_wmainfo(char *filename, MP3FILE *pmp3); + + +/* + * Typedefs + */ +typedef struct scannerlist_tag { + char *ext; + int (*scanner)(char *file, MP3FILE *pmp3); +} SCANNERLIST; + + +/* + * Globals + */ +SCANNERLIST scanner_list[] = { + { "wma",scan_get_wmainfo }, + { NULL, NULL } +}; +char *av0; + + +void dump_mp3(MP3FILE *pmp3) { + int min,sec; + + min=(pmp3->song_length/1000) / 60; + sec = (pmp3->song_length/1000) - (60 * min); + + printf("path..........: %s\n",pmp3->path); + printf("fname.........: %s\n",pmp3->fname); + printf("title.........: %s\n",pmp3->title); + printf("artist........: %s\n",pmp3->artist); + printf("album.........: %s\n",pmp3->album); + printf("genre.........: %s\n",pmp3->genre); + printf("comment.......: %s\n",pmp3->comment); + printf("type..........: %s\n",pmp3->type); + printf("composter.....: %s\n",pmp3->composer); + printf("orchestra.....: %s\n",pmp3->orchestra); + printf("conductor.....: %s\n",pmp3->conductor); + printf("grouping......: %s\n",pmp3->grouping); + printf("year..........: %d\n",pmp3->year); + printf("url...........: %s\n",pmp3->url); + + printf("bitrate.......: %dkb\n",pmp3->bitrate); + printf("samplerate....: %d\n",pmp3->samplerate); + printf("length........: %dms (%d:%02d)\n",pmp3->song_length,min,sec); + printf("size..........: %d\n",pmp3->file_size); + + printf("track.........: %d of %d\n",pmp3->track,pmp3->total_tracks); + printf("disc..........: %d of %d\n",pmp3->disc,pmp3->total_discs); + + printf("compilation...: %d\n",pmp3->compilation); +} + +void usage(int errorcode) { + fprintf(stderr,"Usage: %s [options] input-file\n\n",av0); + fprintf(stderr,"options:\n\n"); + fprintf(stderr," -d level set debuglevel (9 is highest)\n"); + + fprintf(stderr,"\n\n"); + exit(errorcode); +} + +int main(int argc, char *argv[]) { + MP3FILE mp3; + SCANNERLIST *plist; + int option; + char *ext; + + memset((void*)&mp3,0x00,sizeof(MP3FILE)); + + if(strchr(argv[0],'/')) { + av0 = strrchr(argv[0],'/')+1; + } else { + av0 = argv[0]; + } + + while((option = getopt(argc, argv, "d:")) != -1) { + switch(option) { + case 'd': + err_debuglevel = atoi(optarg); + break; + default: + fprintf(stderr,"Error: unknown option (%c)\n\n",option); + usage(-1); + } + } + + argc -= optind; + argv += optind; + + if(argc == 0) { + fprintf(stderr,"Error: Must specifiy file name\n\n"); + usage(-1); + } + + printf("Getting info for %s\n",argv[0]); + + ext = strrchr(argv[0],'.')+1; + plist=scanner_list; + + while(plist->ext && (strcasecmp(plist->ext,ext) != 0)) { + plist++; + } + + if(!plist->ext) { + fprintf(stderr,"Cannot find dispatch for file of type %s\n",ext); + exit(-1); + } + + plist->scanner(argv[0],&mp3); + dump_mp3(&mp3); +} diff --git a/src/scanner.mk b/src/scanner.mk new file mode 100644 index 00000000..2b726ac0 --- /dev/null +++ b/src/scanner.mk @@ -0,0 +1,6 @@ +CC=gcc +CFLAGS=-g + +scanner: scanner-driver.o restart.o wma.o err.o + $(CC) -o scanner scanner-driver.o restart.o wma.o err.o +