mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-24 11:59:16 -05:00
framework for testing metadata scanners outside of mt-daapd
This commit is contained in:
parent
2762f6730b
commit
e5f833c181
144
src/scanner-driver.c
Normal file
144
src/scanner-driver.c
Normal file
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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);
|
||||
}
|
6
src/scanner.mk
Normal file
6
src/scanner.mk
Normal file
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user