Debian Codegraph @

editcomment

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