Debian Codegraph @

editcomment

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 #!/usr/bin/perl
2 # Written to suppliment crip with a tag editor.
3 # Supports both .ogg and .flac files.
4
5 # Put preferred editor here
6 $editor = "vim";
7
8 $file = $ARGV[0];
9
10 unless (-e "$file") {
11 die "File \"$file\" does not exist.\n";
12 }
13
14 if (-e "$file.tag.tmp") {
15 die "WTF is \"$file.tag.tmp\" already doing in /tmp ?!\n";
16 }
17
18 # Escape certain characters from $file
19 # code taken directly from crip actually (crip does the same
20 # sort of thing 3 different times in its code)
21 # (don't ask me why it worked above but doesn't work below without escapes)
22 $file =~ s/\(/\\(/g; $file =~ s/\)/\\)/g;
23 $file =~ s/'/\\'/g; $file =~ s/`/\\`/g;
24 $file =~ s/\"/\\\"/g; $file =~ s/ /\\ /g;
25 $file =~ s/\;/\\\;/g; $file =~ s/,/\\,/g;
26 $file =~ s/&/\\&/g; $file =~ s/\$/\\\$/g;
27
28 if ($file =~ m/\.ogg$/) {
29 # First check for vorbiscomment existence:
30 $out = `which vorbiscomment`;
31 if ($out eq "") {
32 die "Cannot find `vorbiscomment` for tagging the Ogg Vorbis files!\n";
33 }
34
35 system "vorbiscomment -l $file > /tmp/$file.tag.tmp";
36
37 system "$editor /tmp/$file.tag.tmp";
38
39 print "Writing new tag info...\n";
40 system "vorbiscomment -w -c /tmp/$file.tag.tmp $file";
41 print "Done.\n";
42
43 print "Deleting temporary file /tmp/$file.tag.tmp\n";
44 system "rm /tmp/$file.tag.tmp";
45
46 print "\nTag info now reads:\n";
47 system "vorbiscomment -l $file";
48 } elsif ($file =~ m/\.flac$/) {
49 # First check for metaflac existence:
50 $out = `which metaflac`;
51 if ($out eq "") {
52 die "Cannot find `metaflac` for tagging the flac files!\n";
53 } else {
54 # metaflac exists, get its version number
55 $mfver = `metaflac --version`; chop $mfver;
56 $mfver =~ m/(\d+\..+)/; $mfver = $1;
57 }
58
59 if ($mfver lt "1.1.1") {
60 system "metaflac --export-vc-to=/tmp/$file.tag.tmp $file";
61 } else {
62 system "metaflac --export-tags-to=/tmp/$file.tag.tmp $file";
63 }
64
65 system "$editor /tmp/$file.tag.tmp";
66
67 print "Writing new tag info...\n";
68 if ($mfver lt "1.1.1") {
69 system "metaflac --remove-vc-all --import-vc-from=/tmp/$file.tag.tmp $file";
70 } else {
71 system "metaflac --remove-all-tags --import-tags-from=/tmp/$file.tag.tmp $file";
72 }
73 print "Done.\n";
74
75 print "Deleting temporary file /tmp/$file.tag.tmp\n";
76 system "rm /tmp/$file.tag.tmp";
77
78 print "\nTag info now reads:\n";
79 if ($mfver lt "1.1.1") {
80 system "metaflac --export-vc-to=- $file";
81 } else {
82 system "metaflac --export-tags-to=- $file";
83 }
84
85 } else {
86 die "File \"$file\" does not have the .ogg or .flac extension.\n";
87 }
88
89 print "\n";
90
91