id3db.sh revision 1.1 1 1.1 agc #! /bin/sh
2 1.1 agc
3 1.1 agc # $NetBSD: id3db.sh,v 1.1 2007/04/15 15:22:44 agc Exp $
4 1.1 agc #
5 1.1 agc # Copyright 2007 Alistair Crooks. All rights reserved.
6 1.1 agc #
7 1.1 agc # Redistribution and use in source and binary forms, with or without
8 1.1 agc # modification, are permitted provided that the following conditions
9 1.1 agc # are met:
10 1.1 agc # 1. Redistributions of source code must retain the above copyright
11 1.1 agc # notice, this list of conditions and the following disclaimer.
12 1.1 agc # 2. Redistributions in binary form must reproduce the above copyright
13 1.1 agc # notice, this list of conditions and the following disclaimer in the
14 1.1 agc # documentation and/or other materials provided with the distribution.
15 1.1 agc # 3. The name of the author may not be used to endorse or promote
16 1.1 agc # products derived from this software without specific prior written
17 1.1 agc # permission.
18 1.1 agc #
19 1.1 agc # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20 1.1 agc # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 1.1 agc # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 agc # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 1.1 agc # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 agc # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 1.1 agc # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 agc # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 1.1 agc # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 1.1 agc # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 1.1 agc # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 agc #
31 1.1 agc
32 1.1 agc id3info=/usr/music/.id3info
33 1.1 agc id3db=/usr/music/.id3.db
34 1.1 agc
35 1.1 agc db -w -C -E B btree $id3db
36 1.1 agc
37 1.1 agc awk -v database=$id3db '
38 1.1 agc /^Filename:/ { filename = $2 }
39 1.1 agc /^Title:/ { title = $2 }
40 1.1 agc /^Artist:/ { artist = $2 }
41 1.1 agc /^Album:/ { album = $2 }
42 1.1 agc /^Year:/ { year = $2 }
43 1.1 agc /^Genre:/ { genre = $2 " " $3 }
44 1.1 agc /^Track:/ { track = $2 }
45 1.1 agc /^Comment:/ { comment = $0 }
46 1.1 agc /^Directory/ { directory = $2 }
47 1.1 agc /^$/ {
48 1.1 agc if (artist == "")
49 1.1 agc artist = "Unknown"
50 1.1 agc if (year == "")
51 1.1 agc year = "Unknown"
52 1.1 agc if (genre == "")
53 1.1 agc genre = "Unknown"
54 1.1 agc s = sprintf("db -w -E B btree %s %ca%s/%s%c %c%s%c %cy%s/%s%c %c%s%c %cg%s/%s%c %c%s%c",
55 1.1 agc database,
56 1.1 agc 39, directory, filename, 39, 39, artist, 39,
57 1.1 agc 39, directory, filename, 39, 39, year, 39,
58 1.1 agc 39, directory, filename, 39, 39, genre, 39);
59 1.1 agc system(s);
60 1.1 agc }
61 1.1 agc ' $id3info
62 1.1 agc
63 1.1 agc exit 0
64