projects
/
songbook.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed up title handling
[songbook.git]
/
web
/
webchord.cgi
diff --git
a/web/webchord.cgi
b/web/webchord.cgi
index
20140cc
..
e657db8
100755
(executable)
--- a/
web/webchord.cgi
+++ b/
web/webchord.cgi
@@
-68,38
+68,30
@@
sub error {
exit;
} # error
exit;
} # error
+sub getTitle ($) {
+ my ($song) = @_;
+
+ return fileparse ($song, qr/\.pro/);
+} # getTitle
+
sub musicFileExists ($) {
my ($song) = @_;
debug "ENTER musicFileExists ($song)";
sub musicFileExists ($) {
my ($song) = @_;
debug "ENTER musicFileExists ($song)";
- my $title =
fileparse ($song, qr/\.pro/
);
+ my $title =
getTitle ($song
);
my $musicfile = "/opt/media/$title.mp3";
my $musicfile = "/opt/media/$title.mp3";
- if (-r $musicfile) {
- debug "Exists!";
-
- return $title;
- } else {
- debug "Could not find $musicfile";
-
- return;
- } # if
+ return -r $musicfile;
} # musicFileExists
sub updateMusicpath ($$) {
my ($chopro, $song) = @_;
} # musicFileExists
sub updateMusicpath ($$) {
my ($chopro, $song) = @_;
- my $title = musicFileExists $song;
-
# If there's no corresponding music file then do nothing
# If there's no corresponding music file then do nothing
- return unless
$title
;
+ return unless
musicFileExists $song
;
# If the .pro file already has musicpath then do nothing
# If the .pro file already has musicpath then do nothing
- if ($chopro =~ /\{musicpath:.*\}/) {
- debug "$song already has musicpath";
- } # if
-
return if $chopro =~ /\{musicpath:.*\}/;
# Otherwise append the musicpath
return if $chopro =~ /\{musicpath:.*\}/;
# Otherwise append the musicpath
@@
-118,6
+110,7
@@
sub updateMusicpath ($$) {
} # unless
my $songbase = '/sdcard';
} # unless
my $songbase = '/sdcard';
+ my $title = getTitle $song;
print $songfile "{musicpath:$songbase/SongBook/Media/$title.mp3}\n";
print $songfile "{musicpath:$songbase/SongBook/Media/$title.mp3}\n";
@@
-158,7
+151,7
@@
sub chopro2html ($$) {
<body>
END
<body>
END
- $title =
musicFileExists
$song;
+ $title =
getTitle
$song;
if ($title) {
updateMusicpath $chopro, $song;
if ($title) {
updateMusicpath $chopro, $song;
@@
-254,7
+247,7
@@
END
} # if
} # if
} # while
} # if
} # if
} # while
-
+
print "</div>";
} # chordpro2html
print "</div>";
} # chordpro2html