Compare commits

...

4 Commits

4 changed files with 113 additions and 5 deletions

4
index.php Normal file → Executable file
View File

@ -44,7 +44,7 @@ $queues = Queue::getList();
<div id='playing'> <div id='playing'>
<div id='playing_contents' class='playing_contents'></div> <div id='playing_contents' class='playing_contents'></div>
<div id='playing_buttons' class='playing_contents'> <div id='playing_buttons' class='playing_contents'>
<p><input type='button' id='skipsong_playing_btn' value='Skip Song'></p> <p><input type='button' class='skipsong_btn' id='skipsong_playing_btn' value='Skip Song'></p>
<p><input type='button' id='mute_playing_btn' value='Mute'></p> <p><input type='button' id='mute_playing_btn' value='Mute'></p>
</div> </div>
</div> </div>
@ -56,7 +56,7 @@ $queues = Queue::getList();
<div id='volume_slider'></div> <div id='volume_slider'></div>
</div> </div>
<p><input type='button' id='mute_btn' value='Mute'></p> <p><input type='button' id='mute_btn' value='Mute'></p>
<p><input type='button' id='skipsong_btn' value='Skip Song'></p> <p><input type='button' class='skipsong_btn' id='skipsong_btn' value='Skip Song'></p>
<p><input type='button' id='dropsong_btn' value='Drop Song'></p> <p><input type='button' id='dropsong_btn' value='Drop Song'></p>
<p><input type='button' id='emptyjukebox_btn' value='Empty Jukebox'></p> <p><input type='button' id='emptyjukebox_btn' value='Empty Jukebox'></p>
<p><input type='button' id='christmas_btn' value='Christmas: Inactive' class='christmas_btn'> <p><input type='button' id='christmas_btn' value='Christmas: Inactive' class='christmas_btn'>

View File

@ -21,8 +21,9 @@ $(document).ready(function() {
}); });
$('#max_btn').click(function() { setSliderVolume(maxVolume); }); $('#max_btn').click(function() { setSliderVolume(maxVolume); });
$('#min_btn').click(function() { setSliderVolume(minVolume); }); $('#min_btn').click(function() { setSliderVolume(minVolume); });
$('#skipsong_btn').click(function() { skipSong($(this)); }); //$('#skipsong_btn').click(function() { skipSong($(this)); });
$('#skipsong_playing_btn').click(function() { skipSong($(this)); }); //$('#skipsong_playing_btn').click(function() { skipSong($(this)); });
$('.skipsong_btn').click(function() { skipSong($(this)); });
$('#dropsong_btn').click(function() { dropSong($(this)); }); $('#dropsong_btn').click(function() { dropSong($(this)); });
$('#mute_btn').click(function() { toggleMute($(this)); }); $('#mute_btn').click(function() { toggleMute($(this)); });
$('#mute_playing_btn').click(function() { toggleMute($(this)); }); $('#mute_playing_btn').click(function() { toggleMute($(this)); });
@ -169,6 +170,9 @@ function toggleChristmas(callingElement) {
success: function(data, stat, jqo) { success: function(data, stat, jqo) {
callingElement.removeClass("buttonactive"); callingElement.removeClass("buttonactive");
updateChristmasButton(data.christmas); updateChristmasButton(data.christmas);
},
error: function(jqo, stat, err) {
callingElement.removeClass("buttonactive");
} }
}); });
} }
@ -341,20 +345,26 @@ function toggleMute(callingElement, show) {
success: function(data, stat, jqo) { success: function(data, stat, jqo) {
callingElement.removeClass("buttonactive"); callingElement.removeClass("buttonactive");
updateMuteButton(data.muted); updateMuteButton(data.muted);
},
error: function(jqo, stat, err) {
callingElement.removeClass("buttonactive");
} }
}); });
} }
function skipSong (callingElement) { function skipSong (callingElement) {
callingElement.blur(); callingElement.blur();
callingElement.addClass("buttonactive");
if ( gettingJukeboxList || gettingSongList ) return false; if ( gettingJukeboxList || gettingSongList ) return false;
callingElement.addClass("buttonactive");
$.ajax({ $.ajax({
url: 'ajax_skipsong.php', url: 'ajax_skipsong.php',
async: false, async: false,
success: function (data, stat, jqo) { success: function (data, stat, jqo) {
callingElement.removeClass("buttonactive"); callingElement.removeClass("buttonactive");
getSongList(); getSongList();
},
error: function(jqo, stat, err) {
callingElement.removeClass("buttonactive");
} }
}); });
} }
@ -368,6 +378,9 @@ function emptyJukebox (callingElement) {
callingElement.removeClass("buttonactive"); callingElement.removeClass("buttonactive");
getJukeboxList(); getJukeboxList();
//skipSong(); //skipSong();
},
error: function(jqo, stat, err) {
callingElement.removeClass("buttonactive");
} }
}); });
} }
@ -382,6 +395,9 @@ function dropSong (callingElement) {
success: function (data, stat, jqo) { success: function (data, stat, jqo) {
callingElement.removeClass("buttonactive"); callingElement.removeClass("buttonactive");
getSongList(); getSongList();
},
error: function(jqo, stat, err) {
callingElement.removeClass("buttonactive");
} }
}); });
} }

View File

@ -0,0 +1,89 @@
<?php
require_once 'getid3/getid3.php';
$ini = parse_ini_file("/etc/homeaudio.ini");
define("MP3ROOTDIR", $ini['MP3DIR']);
define("ARTDIR", $ini['ARTDIR']);
define("SONGSTABLE", "songs");
$globaldbh = new PDO("mysql:host={$ini['DBHOST']};dbname={$ini['DBNAME']}", $ini['DBUSER'], $ini['DBPASS']);
$ignoredirs = array();
$ignoredirs[] = "Album Playlists";
$ignoredirs[] = "Alphabetical";
$ignoredirs[] = "Incoming2";
$ignoredirs[] = "Recent";
$ignoredirs[] = "Recent (1-2 Months)";
$ignoredirs[] = "Recent (2-3 Months)";
$ignoredirs[] = "playlists";
$extbymimetypes = array(
'image/jpg' => 'jpg',
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif'
);
function search() {
global $globaldbh, $argv;
$target = $argv[2];
switch ($target) {
case "song":
case "songs":
$terms = array();
for ( $i=3; $i<count($argv); $i++ ) {
if ( strlen($argv[$i]) > 2 ) $terms[] = $argv[$i];
}
if ( count($terms) == 0 ) {
echo "Searching requires search terms as command line parameters\n\n";
exit();
}
$query = "SELECT id, path, song, artist, album, title FROM songs WHERE (PATH LIKE :term1";
for ( $i=1; $i<count($terms); $i++ ) {
$query .= " AND path LIKE :term" . ($i+1);
}
$query .= ") OR (song LIKE :term1";
for ( $i=1; $i<count($terms); $i++ ) {
$query .= " AND song LIKE :term" . ($i+1);
}
$query .= ") OR (title LIKE :term1";
for ( $i=1; $i<count($terms); $i++ ) {
$query .= " AND title LIKE :term" . ($i+1);
}
$query .= ") OR (artist LIKE :term1";
for ( $i=1; $i<count($terms); $i++ ) {
$query .= " AND artist LIKE :term" . ($i+1);
}
$query .= ") ORDER BY path, song";
$sth = $globaldbh->prepare($query);
for ( $i=0; $i<count($terms); $i++ ) {
$sth->bindValue(":term".($i+1), "%".$terms[$i]."%", PDO::PARAM_STR);
}
$sth->execute();
if ( $sth->rowCount() > 0 ) {
echo " ID | Path | Song | Title | Artist\n";
echo "-------|----------------------------------------|------------------------------|---------------------------|----------------------\n";
}
while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
echo str_pad(strval($row['id']), 7) . "|";
echo " " . str_pad(substr($row['path'], 0, 37), 39) . "|";
echo " " . str_pad(substr($row['song'], 0, 27), 29) . "|";
echo " " . str_pad(substr($row['title'], 0, 24), 26) . "|";
echo " " . substr($row['artist'], 0, 25) . "\n";
}
break;
}
}
switch ($argv[1]) {
case "search":
search();
break;
default:
echo "Nothing to do\n";
}
echo "\n";
// vim: ts=3:sw=3

3
scripts/hu Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
php homeaudio_utils.php $1 $2 $3 $4 $5 $6