Compare commits

..

No commits in common. "69ba9e1d1470ad5fe799e7be756920c0ef59b955" and "d793790fe5916834a0007219c8e25251d2f70ef7" have entirely different histories.

8 changed files with 63 additions and 123 deletions

View File

@ -6,22 +6,21 @@ $query = "SELECT id, songid FROM " . INSTANTQTABLE . " ORDER BY id";
$sth = $globaldbh->prepare($query);
$sth->execute();
$data = array();
$data["jukebox"] = array();
$firstsong = true;
while ( $row = $sth->fetch() ) {
$id = $row['id'];
$song = new Song($row['songid']);
$curdata = array();
$curdata["id"] = $song->getID();
$curdata["arturl"] = $song->getArtFile(ARTURL);
$curdata["title"] = $song->getTitle(HTMLSAFE);
$curdata["artist"] = $song->getArtist(HTMLSAFE);
$curdata["album"] = $song->getAlbum(HTMLSAFE);
$curdata["year"] = $song->getYear(HTMLSAFE);
$data['jukebox'][] = $curdata;
echo "<div id='juke_{$id}' class='songlist_song_container' onClick='dropJukeboxSong({$id});'>\n";
echo " <div class='songlist_img_container'><img class='songlist_img' src='{$song->getArtFile(ARTURL)}'></div>\n";
echo " <div class='songlist_details_container'>\n";
echo " <p class='nomargin'><span class='playing_label'>Song:</span> {$song->getTitle(HTMLSAFE)}</p>\n";
echo " <p class='nomargin'><span class='playing_label'>Artist:</span> {$song->getArtist(HTMLSAFE)}</p>\n";
echo " <p class='nomargin'><span class='playing_label'>Album:</span> {$song->getAlbum(HTMLSAFE)}</p>\n";
echo " </div>\n";
echo "</div>\n";
echo "<hr class='songlist'>\n";
}
header('Content-Type: application/json');
echo json_encode($data);
exit();
// vim: sw=3 ts=3 ai mouse-=a:
?>

View File

@ -30,30 +30,36 @@ $data['volume'] = getSystemVolume();
system("HOME=" . WEBUSERHOMEDIR . " && ../scripts/homeaudio_togglemute.pl -show", $retval);
$data['muted'] = ($retval == 0) ? false : true;
$data['currentsong'] = array("art"=>"", "title"=>"", "artist"=>"", "album"=>"", "year"=>"");
$data['songhistory'] = array();
if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
$data['songlist'] = "";
$firstsong = true;
while ( $row = $sth->fetch() ) {
$song = new Song($row['songid']);
$data['currentsong']["id"] = $song->getID();
if ( $firstsong ) {
$data['currentsong']["arturl"] = $song->getArtFile(ARTURL);
$data['currentsong']["title"] = $song->getTitle(HTMLSAFE);
$data['currentsong']["artist"] = $song->getArtist(HTMLSAFE);
$data['currentsong']["album"] = $song->getAlbum(HTMLSAFE);
$data['currentsong']["year"] = $song->getYear(HTMLSAFE);
$firstsong = false;
} else {
$data['songlist'] .= "<div class='songlist_song_container'>\n";
$data['songlist'] .= " <div class='songlist_img_container'><img class='songlist_img' src='{$song->getArtFile(ARTURL)}'></div>\n";
$data['songlist'] .= " <div class='songlist_details_container'>\n";
$data['songlist'] .= " <p class='nomargin'><span class='playing_label'>Title:</span> {$song->getTitle(HTMLSAFE)}</p>\n";
$data['songlist'] .= " <p class='nomargin'><span class='playing_label'>Artist:</span> {$song->getArtist(HTMLSAFE)}</p>\n";
$data['songlist'] .= " <p class='nomargin'><span class='playing_label'>Album:</span> {$song->getAlbum(HTMLSAFE)}</p>\n";
$data['songlist'] .= " </div>\n";
$data['songlist'] .= "</div>\n";
$data['songlist'] .= "<hr class='songlist'>\n";
}
}
while ( $row = $sth->fetch() ) {
$song = new Song($row['songid']);
$curdata = array();
$curdata["id"] = $song->getID();
$curdata["arturl"] = $song->getArtFile(ARTURL);
$curdata["title"] = $song->getTitle(HTMLSAFE);
$curdata["artist"] = $song->getArtist(HTMLSAFE);
$curdata["album"] = $song->getAlbum(HTMLSAFE);
$curdata["year"] = $song->getYear(HTMLSAFE);
$data['songhistory'][] = $curdata;
if ( $debug ) {
var_dump($data);
echo "</pre>";
} else {
echo json_encode($data);
}
header('Content-Type: application/json');
echo json_encode($data);
exit();
// vim: set ts=3 sw=3 ai:
?>

View File

@ -31,7 +31,6 @@ $extbymimetypes = array(
);
$artbygenre = array(
'Bluegrass' => 'Bluegrass.jpg',
'Christmas' => 'Christmas.jpg',
'Classical' => 'Classical.jpg',
'Comedy - Misc' => 'Comedy.jpg',

View File

@ -142,7 +142,7 @@ div.category_go {
float: right;
}
div.playing_contents {
width: 85%;
width: 85%
margin-left: auto;
margin-right: auto;
margin-top: 10px;
@ -174,7 +174,7 @@ span.playing_label {
font-weight: bold;
}
div.history_contents {
width: 85%;
width: 85%
margin-left: auto;
margin-right: auto;
margin-top: 10px;
@ -183,7 +183,7 @@ div.history_contents {
text-align: left;
}
div.search_input {
width: 85%;
width: 85%
margin-left: auto;
margin-right: auto;
margin-top: 10px;
@ -192,7 +192,7 @@ div.search_input {
text-align: center;
}
div.search_contents {
width: 85%;
width: 85%
margin-left: auto;
margin-right: auto;
margin-top: 10px;
@ -201,7 +201,7 @@ div.search_contents {
text-align: left;
}
div.lists_contents {
width: 85%;
width: 85%
margin-left: auto;
margin-right: auto;
margin-top: 10px;
@ -228,17 +228,11 @@ div.songlist_details_container {
margin-left: 0.25em;
float: left;
}
div.songlist_details_container p {
margin: 0px;
}
div.songlist_details_container span {
font-weight: bold;
}
hr.songlist {
width: 65%;
}
div.queue_contents {
width: 85%;
width: 85%
margin-left: auto;
margin-right: auto;
margin-top: 10px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

View File

@ -7,7 +7,6 @@ var gettingSongList = false;
var gettingJukeboxList = false;
var searchTimeout = null;
var queueTarget = 0;
var paused = true;
$(document).ready(function() {
$('#tabs').tabs({
@ -58,7 +57,7 @@ $(document).ready(function() {
toggleMute($(this), 'show');
getSongList();
getQueueTarget();
refreshTimerObj = setInterval('doIntervalQuery()', 10000);
refreshTimerObj = setInterval('getSongList()', 10000);
//document.documentElement.requestFullscreen();
});
@ -181,32 +180,6 @@ function updateChristmasButton(active) {
}
}
function doIntervalQuery() {
if ( paused ) return;
getSongList();
}
function togglePause() {
paused = !paused;
console.log("Paused: " + (paused) ? "True" : "False");
}
function generateSongListHTML(type, songs) {
var body = "";
songs.forEach(function(item, index, arr) {
body += "<div id='" + type + "_" + item.id + "' class='songlist_song_container'>";
body += "<div class='songlist_img_container'><img class='songlist_img' src='" + item.arturl + "' /></div>";
body += "<div class='songlist_details_container'>";
body += "<p><span>Title:</span> " + item.title + "</p>";
body += "<p><span>Artist:</span> " + item.artist + "</p>";
body += "<p><span>Album:</span> " + item.album + "</p>";
body += "</div>";
body += "</div>";
body += "<hr class='songlist'>";
});
return body;
}
function getSongList() {
gettingSongList = true;
$.ajax({
@ -217,12 +190,12 @@ function getSongList() {
volFromServer = true;
$('#volume_slider').slider("value", data.volume);
}
$('#history_contents').html(data.songlist);
$('#playing_img').attr("src", data.currentsong.arturl);
$('#playing_title').html(data.currentsong.title);
$('#playing_artist').html(data.currentsong.artist);
$('#playing_album').html(data.currentsong.album);
$('#playing_year').html(data.currentsong.year);
$('#history_contents').html(generateSongListHTML("hist", data.songhistory));
updateChristmasButton(data.christmas);
updateMuteButton(data.muted);
$('#christmas_freq').val(data.christmasfreq);
@ -247,9 +220,9 @@ function getJukeboxList() {
gettingJukeboxList = true;
$.ajax({
url: 'ajax/ajax_getjukebox.php',
dataType: 'json',
dataType: 'html',
success: function(data, stat, jqo) {
$('#jukebox_contents').html(generateSongListHTML("juke", data.jukebox));
$('#jukebox_contents').html(data);
gettingSongList = false;
gettingJukeboxList = false;
}

View File

@ -1,13 +1,8 @@
<?php
require_once dirname(__FILE__).'/../vendor/autoload.php';
require_once 'getid3/getid3.php';
$ini = parse_ini_file("/etc/homeaudio.ini", false, INI_SCANNER_RAW);
if ( isset($argv[1]) && ($argv[1] == "simulate") ) {
define("SIMULATE", true);
} else {
define("SIMULATE", false);
}
$ini = parse_ini_file("/etc/homeaudio.ini");
define("MP3ROOTDIR", $ini['MP3DIR']);
define("ARTDIR", $ini['ARTDIR']);
@ -17,7 +12,6 @@ $globaldbh = new PDO("mysql:host={$ini['DBHOST']};dbname={$ini['DBNAME']}", $ini
$ignoredirs = array();
$ignoredirs[] = "Album Playlists";
$ignoredirs[] = "Alphabetical";
$ignoredirs[] = "Dad Music";
$ignoredirs[] = "Incoming2";
$ignoredirs[] = "Recent";
$ignoredirs[] = "Recent (1-2 Months)";
@ -46,11 +40,7 @@ function pruneDB() {
if ( !file_exists(MP3ROOTDIR . $row['path'] . $row['song']) ) {
$fieldsdel = array();
$fieldsdel[':id'] = $row['id'];
if ( SIMULATE ) {
echo "Would have removed: {$row['song']}\n";
} else {
$sthdel->execute($fieldsdel);
}
$prunecount++;
}
}
@ -69,24 +59,16 @@ function addNewSongs($path = "") {
if ( substr($entry, -3) != "mp3" ) continue;
$song = $path . $entry;
$fields = array();
$fields[':path'] = mb_convert_encoding($path, "UTF-8");
$fields[':song'] = mb_convert_encoding($entry, "UTF-8");
try {
$fields[':path'] = $path;
$fields[':song'] = $entry;
$sth_exists->execute($fields);
} catch ( Exception $e ) {
echo "Could not query database for song: {$path}/{$entry}\n";
}
if ( $sth_exists->fetchColumn() == 0 ) {
$newcount++;
if ( ($newcount % 1000) == 0 ) echo ".";
if ( SIMULATE ) {
echo "Would have added: {$fields[':path']}{$fields[':song']}\n";
} else {
$sth_addnew->execute($fields);
}
}
}
}
closedir($fh);
}
@ -106,37 +88,26 @@ function parseSongs() {
$info = $getid3->analyze(MP3ROOTDIR . $row['path'] . $row['song']);
if ( isset($info['id3v2']['comments']['title'][0]) ) {
$fields[':title'] = $info['id3v2']['comments']['title'][0];
} else {
$fields[':title'] = "";
}
if ( !isset($fields[':title']) || ($fields[':title'] == "") ) {
@list($junk, $fields[':title']) = explode(" - ", substr($row['song'], 0, -4), 2);
if ( is_null($fields[':title']) ) $fields[':title'] = substr($row['song'], 0, -4);
}
if ( isset($info['id3v2']['comments']['artist'][0]) ) {
$fields[':artist'] = $info['id3v2']['comments']['artist'][0];
} else {
$fields[':artist'] = "";
}
if ( !isset($fields[':artist']) || ($fields[':artist'] == "") ) {
@list($fields[':artist'], $junk) = explode(" - ", basename($row['path']), 2);
if ( is_null($fields[':artist']) ) $fields[':artist'] = basename($row['path'], "/");
}
if ( isset($info['id3v2']['comments']['album'][0]) ) {
$fields[':album'] = $info['id3v2']['comments']['album'][0];
} else {
$fields[':album'] = "";
}
if ( !isset($fields[':album']) || ($fields[':album'] == "") ) {
@list($junk, $fields[':album']) = explode(" - ", basename($row['path']), 2);
if ( is_null($fields[':album']) ) $fields[':album'] = basename($row['path'], "/");
}
if ( isset($info['id3v2']['comments']['year'][0]) ) {
$fields[':year'] = $info['id3v2']['comments']['year'][0];
} else {
$fields[':year'] = "";
}
if ( !isset($fields[':year']) || is_null($fields[':year']) ) $fields[':year'] = "";
if ( !isset($fields[':year']) ) $fields[':year'] = "";
@list($min, $sec) = explode(":", $info['playtime_string'], 2);
$fields[':length'] = (intval($min) * 60) + intval($sec);
$fields[':artfile'] = "";
@ -147,14 +118,12 @@ function parseSongs() {
$fields[':artfile'] = $artmd5 . "." . $extbymimetypes[$mimetype];
}
}
if ( !SIMULATE ) {
if ( ($fields[':artfile'] != "") && !file_exists(ARTDIR . $fields[':artfile']) ) {
file_put_contents(ARTDIR . $fields[':artfile'], $info['comments']['picture'][0]['data']);
}
$sth_info->execute($fields);
}
$parsecount++;
if ( ($parsecount % 1000) == 0 ) echo ".";
$sth_info->execute($fields);
}
return $parsecount;
}
@ -191,4 +160,4 @@ echo "Parsing ID3 tags...";
$parsecount = parseSongs();
echo " ", $parsecount, " tags parsed.\n";
// vim: set et ts=3 sw=3 ai mouse-=a:
?>

View File

@ -86,4 +86,4 @@ switch ($argv[1]) {
}
echo "\n";
// vim: ts=3 sw=3 et ai:
// vim: ts=3:sw=3