Compare commits
	
		
			10 Commits
		
	
	
		
			d793790fe5
			...
			69ba9e1d14
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 69ba9e1d14 | |||
| 426d2680f7 | |||
| 70886bacba | |||
| 8f23b77ace | |||
| 3dac8013d8 | |||
| e92eff5107 | |||
| c5fb8657ca | |||
| 7ad5c67a77 | |||
| d3d8e6c421 | |||
| 90e1ed3805 | 
| 
						 | 
					@ -6,21 +6,22 @@ $query = "SELECT id, songid FROM " . INSTANTQTABLE . " ORDER BY id";
 | 
				
			||||||
$sth = $globaldbh->prepare($query);
 | 
					$sth = $globaldbh->prepare($query);
 | 
				
			||||||
$sth->execute();
 | 
					$sth->execute();
 | 
				
			||||||
$data = array();
 | 
					$data = array();
 | 
				
			||||||
$firstsong = true;
 | 
					$data["jukebox"] = array();
 | 
				
			||||||
while ( $row = $sth->fetch() ) {
 | 
					while ( $row = $sth->fetch() ) {
 | 
				
			||||||
   $id = $row['id'];
 | 
					   $id = $row['id'];
 | 
				
			||||||
   $song = new Song($row['songid']);
 | 
					   $song = new Song($row['songid']);
 | 
				
			||||||
   echo "<div id='juke_{$id}' class='songlist_song_container' onClick='dropJukeboxSong({$id});'>\n";
 | 
					   $curdata = array();
 | 
				
			||||||
   echo "  <div class='songlist_img_container'><img class='songlist_img' src='{$song->getArtFile(ARTURL)}'></div>\n";
 | 
					   $curdata["id"] = $song->getID();
 | 
				
			||||||
   echo "  <div class='songlist_details_container'>\n";
 | 
					   $curdata["arturl"] = $song->getArtFile(ARTURL);
 | 
				
			||||||
   echo "    <p class='nomargin'><span class='playing_label'>Song:</span> {$song->getTitle(HTMLSAFE)}</p>\n";
 | 
					   $curdata["title"] = $song->getTitle(HTMLSAFE);
 | 
				
			||||||
   echo "    <p class='nomargin'><span class='playing_label'>Artist:</span> {$song->getArtist(HTMLSAFE)}</p>\n";
 | 
					   $curdata["artist"] = $song->getArtist(HTMLSAFE);
 | 
				
			||||||
   echo "    <p class='nomargin'><span class='playing_label'>Album:</span> {$song->getAlbum(HTMLSAFE)}</p>\n";
 | 
					   $curdata["album"] = $song->getAlbum(HTMLSAFE);
 | 
				
			||||||
   echo "  </div>\n";
 | 
					   $curdata["year"] = $song->getYear(HTMLSAFE);
 | 
				
			||||||
   echo "</div>\n";
 | 
					   $data['jukebox'][] = $curdata;
 | 
				
			||||||
   echo "<hr class='songlist'>\n";
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header('Content-Type: application/json');
 | 
				
			||||||
 | 
					echo json_encode($data);
 | 
				
			||||||
exit();
 | 
					exit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// vim: sw=3 ts=3 ai mouse-=a:
 | 
				
			||||||
?>
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,36 +30,30 @@ $data['volume'] = getSystemVolume();
 | 
				
			||||||
system("HOME=" . WEBUSERHOMEDIR . " && ../scripts/homeaudio_togglemute.pl -show", $retval);
 | 
					system("HOME=" . WEBUSERHOMEDIR . " && ../scripts/homeaudio_togglemute.pl -show", $retval);
 | 
				
			||||||
$data['muted'] = ($retval == 0) ? false : true;
 | 
					$data['muted'] = ($retval == 0) ? false : true;
 | 
				
			||||||
$data['currentsong'] = array("art"=>"", "title"=>"", "artist"=>"", "album"=>"", "year"=>"");
 | 
					$data['currentsong'] = array("art"=>"", "title"=>"", "artist"=>"", "album"=>"", "year"=>"");
 | 
				
			||||||
$data['songlist'] = "";
 | 
					$data['songhistory'] = array();
 | 
				
			||||||
$firstsong = true;
 | 
					if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
 | 
				
			||||||
 | 
					   $song = new Song($row['songid']);
 | 
				
			||||||
 | 
					   $data['currentsong']["id"] = $song->getID();
 | 
				
			||||||
 | 
					   $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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
while ( $row = $sth->fetch() ) {
 | 
					while ( $row = $sth->fetch() ) {
 | 
				
			||||||
   $song = new Song($row['songid']);
 | 
					   $song = new Song($row['songid']);
 | 
				
			||||||
   if ( $firstsong ) {
 | 
					   $curdata = array();
 | 
				
			||||||
      $data['currentsong']["arturl"] = $song->getArtFile(ARTURL);
 | 
					   $curdata["id"] = $song->getID();
 | 
				
			||||||
      $data['currentsong']["title"] = $song->getTitle(HTMLSAFE);
 | 
					   $curdata["arturl"] = $song->getArtFile(ARTURL);
 | 
				
			||||||
      $data['currentsong']["artist"] = $song->getArtist(HTMLSAFE);
 | 
					   $curdata["title"] = $song->getTitle(HTMLSAFE);
 | 
				
			||||||
      $data['currentsong']["album"] = $song->getAlbum(HTMLSAFE);
 | 
					   $curdata["artist"] = $song->getArtist(HTMLSAFE);
 | 
				
			||||||
      $data['currentsong']["year"] = $song->getYear(HTMLSAFE);
 | 
					   $curdata["album"] = $song->getAlbum(HTMLSAFE);
 | 
				
			||||||
      $firstsong = false;
 | 
					   $curdata["year"] = $song->getYear(HTMLSAFE);
 | 
				
			||||||
   } else {
 | 
					   $data['songhistory'][] = $curdata;
 | 
				
			||||||
      $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";
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
if ( $debug ) {
 | 
					 | 
				
			||||||
   var_dump($data);
 | 
					 | 
				
			||||||
   echo "</pre>";
 | 
					 | 
				
			||||||
} else {
 | 
					 | 
				
			||||||
   echo json_encode($data);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header('Content-Type: application/json');
 | 
				
			||||||
 | 
					echo json_encode($data);
 | 
				
			||||||
exit();
 | 
					exit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// vim: set ts=3 sw=3 ai:
 | 
				
			||||||
?>
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,7 @@ $extbymimetypes = array(
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$artbygenre = array(
 | 
					$artbygenre = array(
 | 
				
			||||||
 | 
					   'Bluegrass' => 'Bluegrass.jpg',
 | 
				
			||||||
   'Christmas' => 'Christmas.jpg',
 | 
					   'Christmas' => 'Christmas.jpg',
 | 
				
			||||||
   'Classical' => 'Classical.jpg',
 | 
					   'Classical' => 'Classical.jpg',
 | 
				
			||||||
   'Comedy - Misc' => 'Comedy.jpg',
 | 
					   'Comedy - Misc' => 'Comedy.jpg',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,7 +142,7 @@ div.category_go {
 | 
				
			||||||
   float: right;
 | 
					   float: right;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
div.playing_contents {
 | 
					div.playing_contents {
 | 
				
			||||||
   width: 85%
 | 
					   width: 85%;
 | 
				
			||||||
   margin-left: auto;
 | 
					   margin-left: auto;
 | 
				
			||||||
   margin-right: auto;
 | 
					   margin-right: auto;
 | 
				
			||||||
   margin-top: 10px;
 | 
					   margin-top: 10px;
 | 
				
			||||||
| 
						 | 
					@ -174,7 +174,7 @@ span.playing_label {
 | 
				
			||||||
   font-weight: bold;
 | 
					   font-weight: bold;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
div.history_contents {
 | 
					div.history_contents {
 | 
				
			||||||
   width: 85%
 | 
					   width: 85%;
 | 
				
			||||||
   margin-left: auto;
 | 
					   margin-left: auto;
 | 
				
			||||||
   margin-right: auto;
 | 
					   margin-right: auto;
 | 
				
			||||||
   margin-top: 10px;
 | 
					   margin-top: 10px;
 | 
				
			||||||
| 
						 | 
					@ -183,7 +183,7 @@ div.history_contents {
 | 
				
			||||||
   text-align: left;
 | 
					   text-align: left;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
div.search_input {
 | 
					div.search_input {
 | 
				
			||||||
   width: 85%
 | 
					   width: 85%;
 | 
				
			||||||
   margin-left: auto;
 | 
					   margin-left: auto;
 | 
				
			||||||
   margin-right: auto;
 | 
					   margin-right: auto;
 | 
				
			||||||
   margin-top: 10px;
 | 
					   margin-top: 10px;
 | 
				
			||||||
| 
						 | 
					@ -192,7 +192,7 @@ div.search_input {
 | 
				
			||||||
   text-align: center;
 | 
					   text-align: center;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
div.search_contents {
 | 
					div.search_contents {
 | 
				
			||||||
   width: 85%
 | 
					   width: 85%;
 | 
				
			||||||
   margin-left: auto;
 | 
					   margin-left: auto;
 | 
				
			||||||
   margin-right: auto;
 | 
					   margin-right: auto;
 | 
				
			||||||
   margin-top: 10px;
 | 
					   margin-top: 10px;
 | 
				
			||||||
| 
						 | 
					@ -201,7 +201,7 @@ div.search_contents {
 | 
				
			||||||
   text-align: left;
 | 
					   text-align: left;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
div.lists_contents {
 | 
					div.lists_contents {
 | 
				
			||||||
   width: 85%
 | 
					   width: 85%;
 | 
				
			||||||
   margin-left: auto;
 | 
					   margin-left: auto;
 | 
				
			||||||
   margin-right: auto;
 | 
					   margin-right: auto;
 | 
				
			||||||
   margin-top: 10px;
 | 
					   margin-top: 10px;
 | 
				
			||||||
| 
						 | 
					@ -228,11 +228,17 @@ div.songlist_details_container {
 | 
				
			||||||
   margin-left: 0.25em;
 | 
					   margin-left: 0.25em;
 | 
				
			||||||
   float: left;
 | 
					   float: left;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					div.songlist_details_container p {
 | 
				
			||||||
 | 
					   margin: 0px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					div.songlist_details_container span {
 | 
				
			||||||
 | 
					   font-weight: bold;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
hr.songlist {
 | 
					hr.songlist {
 | 
				
			||||||
   width: 65%;
 | 
					   width: 65%;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
div.queue_contents {
 | 
					div.queue_contents {
 | 
				
			||||||
   width: 85%
 | 
					   width: 85%;
 | 
				
			||||||
   margin-left: auto;
 | 
					   margin-left: auto;
 | 
				
			||||||
   margin-right: auto;
 | 
					   margin-right: auto;
 | 
				
			||||||
   margin-top: 10px;
 | 
					   margin-top: 10px;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								img/Bluegrass.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								img/Bluegrass.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 132 KiB  | 
| 
						 | 
					@ -7,6 +7,7 @@ var gettingSongList = false;
 | 
				
			||||||
var gettingJukeboxList = false;
 | 
					var gettingJukeboxList = false;
 | 
				
			||||||
var searchTimeout = null;
 | 
					var searchTimeout = null;
 | 
				
			||||||
var queueTarget = 0;
 | 
					var queueTarget = 0;
 | 
				
			||||||
 | 
					var paused = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
   $('#tabs').tabs({
 | 
					   $('#tabs').tabs({
 | 
				
			||||||
| 
						 | 
					@ -57,7 +58,7 @@ $(document).ready(function() {
 | 
				
			||||||
   toggleMute($(this), 'show');
 | 
					   toggleMute($(this), 'show');
 | 
				
			||||||
   getSongList();
 | 
					   getSongList();
 | 
				
			||||||
   getQueueTarget();
 | 
					   getQueueTarget();
 | 
				
			||||||
   refreshTimerObj = setInterval('getSongList()', 10000);
 | 
					   refreshTimerObj = setInterval('doIntervalQuery()', 10000);
 | 
				
			||||||
   //document.documentElement.requestFullscreen();
 | 
					   //document.documentElement.requestFullscreen();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -180,6 +181,32 @@ 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() {
 | 
					function getSongList() {
 | 
				
			||||||
   gettingSongList = true;
 | 
					   gettingSongList = true;
 | 
				
			||||||
   $.ajax({
 | 
					   $.ajax({
 | 
				
			||||||
| 
						 | 
					@ -190,12 +217,12 @@ function getSongList() {
 | 
				
			||||||
            volFromServer = true;
 | 
					            volFromServer = true;
 | 
				
			||||||
            $('#volume_slider').slider("value", data.volume);
 | 
					            $('#volume_slider').slider("value", data.volume);
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
         $('#history_contents').html(data.songlist);
 | 
					 | 
				
			||||||
         $('#playing_img').attr("src", data.currentsong.arturl);
 | 
					         $('#playing_img').attr("src", data.currentsong.arturl);
 | 
				
			||||||
         $('#playing_title').html(data.currentsong.title);
 | 
					         $('#playing_title').html(data.currentsong.title);
 | 
				
			||||||
         $('#playing_artist').html(data.currentsong.artist);
 | 
					         $('#playing_artist').html(data.currentsong.artist);
 | 
				
			||||||
         $('#playing_album').html(data.currentsong.album);
 | 
					         $('#playing_album').html(data.currentsong.album);
 | 
				
			||||||
         $('#playing_year').html(data.currentsong.year);
 | 
					         $('#playing_year').html(data.currentsong.year);
 | 
				
			||||||
 | 
					         $('#history_contents').html(generateSongListHTML("hist", data.songhistory));
 | 
				
			||||||
         updateChristmasButton(data.christmas);
 | 
					         updateChristmasButton(data.christmas);
 | 
				
			||||||
         updateMuteButton(data.muted);
 | 
					         updateMuteButton(data.muted);
 | 
				
			||||||
         $('#christmas_freq').val(data.christmasfreq);
 | 
					         $('#christmas_freq').val(data.christmasfreq);
 | 
				
			||||||
| 
						 | 
					@ -220,9 +247,9 @@ function getJukeboxList() {
 | 
				
			||||||
      gettingJukeboxList = true;
 | 
					      gettingJukeboxList = true;
 | 
				
			||||||
      $.ajax({
 | 
					      $.ajax({
 | 
				
			||||||
         url: 'ajax/ajax_getjukebox.php',
 | 
					         url: 'ajax/ajax_getjukebox.php',
 | 
				
			||||||
         dataType: 'html',
 | 
					         dataType: 'json',
 | 
				
			||||||
         success: function(data, stat, jqo) {
 | 
					         success: function(data, stat, jqo) {
 | 
				
			||||||
            $('#jukebox_contents').html(data);
 | 
					            $('#jukebox_contents').html(generateSongListHTML("juke", data.jukebox));
 | 
				
			||||||
            gettingSongList = false;
 | 
					            gettingSongList = false;
 | 
				
			||||||
            gettingJukeboxList = false;
 | 
					            gettingJukeboxList = false;
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,13 @@
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require_once 'getid3/getid3.php';
 | 
					require_once dirname(__FILE__).'/../vendor/autoload.php';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$ini = parse_ini_file("/etc/homeaudio.ini");
 | 
					$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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
define("MP3ROOTDIR", $ini['MP3DIR']);
 | 
					define("MP3ROOTDIR", $ini['MP3DIR']);
 | 
				
			||||||
define("ARTDIR", $ini['ARTDIR']);
 | 
					define("ARTDIR", $ini['ARTDIR']);
 | 
				
			||||||
| 
						 | 
					@ -12,6 +17,7 @@ $globaldbh = new PDO("mysql:host={$ini['DBHOST']};dbname={$ini['DBNAME']}", $ini
 | 
				
			||||||
$ignoredirs = array();
 | 
					$ignoredirs = array();
 | 
				
			||||||
$ignoredirs[] = "Album Playlists";
 | 
					$ignoredirs[] = "Album Playlists";
 | 
				
			||||||
$ignoredirs[] = "Alphabetical";
 | 
					$ignoredirs[] = "Alphabetical";
 | 
				
			||||||
 | 
					$ignoredirs[] = "Dad Music";
 | 
				
			||||||
$ignoredirs[] = "Incoming2";
 | 
					$ignoredirs[] = "Incoming2";
 | 
				
			||||||
$ignoredirs[] = "Recent";
 | 
					$ignoredirs[] = "Recent";
 | 
				
			||||||
$ignoredirs[] = "Recent (1-2 Months)";
 | 
					$ignoredirs[] = "Recent (1-2 Months)";
 | 
				
			||||||
| 
						 | 
					@ -40,7 +46,11 @@ function pruneDB() {
 | 
				
			||||||
      if ( !file_exists(MP3ROOTDIR . $row['path'] . $row['song']) ) {
 | 
					      if ( !file_exists(MP3ROOTDIR . $row['path'] . $row['song']) ) {
 | 
				
			||||||
         $fieldsdel = array();
 | 
					         $fieldsdel = array();
 | 
				
			||||||
         $fieldsdel[':id'] = $row['id'];
 | 
					         $fieldsdel[':id'] = $row['id'];
 | 
				
			||||||
         $sthdel->execute($fieldsdel);
 | 
					         if ( SIMULATE ) {
 | 
				
			||||||
 | 
					            echo "Would have removed: {$row['song']}\n";
 | 
				
			||||||
 | 
					         } else {
 | 
				
			||||||
 | 
					            $sthdel->execute($fieldsdel);
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
         $prunecount++;
 | 
					         $prunecount++;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
| 
						 | 
					@ -59,13 +69,21 @@ function addNewSongs($path = "") {
 | 
				
			||||||
         if ( substr($entry, -3) != "mp3" ) continue;
 | 
					         if ( substr($entry, -3) != "mp3" ) continue;
 | 
				
			||||||
         $song = $path . $entry;
 | 
					         $song = $path . $entry;
 | 
				
			||||||
         $fields = array();
 | 
					         $fields = array();
 | 
				
			||||||
         $fields[':path'] = $path;
 | 
					         $fields[':path'] = mb_convert_encoding($path, "UTF-8");
 | 
				
			||||||
         $fields[':song'] = $entry;
 | 
					         $fields[':song'] = mb_convert_encoding($entry, "UTF-8");
 | 
				
			||||||
         $sth_exists->execute($fields);
 | 
					         try {
 | 
				
			||||||
 | 
					            $sth_exists->execute($fields);
 | 
				
			||||||
 | 
					         } catch ( Exception $e ) {
 | 
				
			||||||
 | 
					            echo "Could not query database for song: {$path}/{$entry}\n";
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
         if ( $sth_exists->fetchColumn() == 0 ) {
 | 
					         if ( $sth_exists->fetchColumn() == 0 ) {
 | 
				
			||||||
            $newcount++;
 | 
					            $newcount++;
 | 
				
			||||||
            if ( ($newcount % 1000) == 0 ) echo ".";
 | 
					            if ( ($newcount % 1000) == 0 ) echo ".";
 | 
				
			||||||
            $sth_addnew->execute($fields);
 | 
					            if ( SIMULATE ) {
 | 
				
			||||||
 | 
					               echo "Would have added: {$fields[':path']}{$fields[':song']}\n";
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					               $sth_addnew->execute($fields);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
| 
						 | 
					@ -88,26 +106,37 @@ function parseSongs() {
 | 
				
			||||||
      $info = $getid3->analyze(MP3ROOTDIR . $row['path'] . $row['song']);
 | 
					      $info = $getid3->analyze(MP3ROOTDIR . $row['path'] . $row['song']);
 | 
				
			||||||
      if ( isset($info['id3v2']['comments']['title'][0]) ) {
 | 
					      if ( isset($info['id3v2']['comments']['title'][0]) ) {
 | 
				
			||||||
         $fields[':title'] = $info['id3v2']['comments']['title'][0];
 | 
					         $fields[':title'] = $info['id3v2']['comments']['title'][0];
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					         $fields[':title'] = "";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if ( !isset($fields[':title']) || ($fields[':title'] == "") ) {
 | 
					      if ( !isset($fields[':title']) || ($fields[':title'] == "") ) {
 | 
				
			||||||
         @list($junk, $fields[':title']) = explode(" - ", substr($row['song'], 0, -4), 2);
 | 
					         @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]) ) {
 | 
					      if ( isset($info['id3v2']['comments']['artist'][0]) ) {
 | 
				
			||||||
         $fields[':artist'] = $info['id3v2']['comments']['artist'][0];
 | 
					         $fields[':artist'] = $info['id3v2']['comments']['artist'][0];
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					         $fields[':artist'] = "";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if ( !isset($fields[':artist']) || ($fields[':artist'] == "") ) {
 | 
					      if ( !isset($fields[':artist']) || ($fields[':artist'] == "") ) {
 | 
				
			||||||
         @list($fields[':artist'], $junk) = explode(" - ", basename($row['path']), 2);
 | 
					         @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]) ) {
 | 
					      if ( isset($info['id3v2']['comments']['album'][0]) ) {
 | 
				
			||||||
         $fields[':album'] = $info['id3v2']['comments']['album'][0];
 | 
					         $fields[':album'] = $info['id3v2']['comments']['album'][0];
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					         $fields[':album'] = "";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if ( !isset($fields[':album']) || ($fields[':album'] == "") ) {
 | 
					      if ( !isset($fields[':album']) || ($fields[':album'] == "") ) {
 | 
				
			||||||
         @list($junk, $fields[':album']) = explode(" - ", basename($row['path']), 2);
 | 
					         @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]) ) {
 | 
					      if ( isset($info['id3v2']['comments']['year'][0]) ) {
 | 
				
			||||||
         $fields[':year'] = $info['id3v2']['comments']['year'][0];
 | 
					         $fields[':year'] = $info['id3v2']['comments']['year'][0];
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					         $fields[':year'] = "";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if ( !isset($fields[':year']) ) $fields[':year'] = "";
 | 
					      if ( !isset($fields[':year']) || is_null($fields[':year']) ) $fields[':year'] = "";
 | 
				
			||||||
      @list($min, $sec) = explode(":", $info['playtime_string'], 2);
 | 
					      @list($min, $sec) = explode(":", $info['playtime_string'], 2);
 | 
				
			||||||
      $fields[':length'] = (intval($min) * 60) + intval($sec);
 | 
					      $fields[':length'] = (intval($min) * 60) + intval($sec);
 | 
				
			||||||
      $fields[':artfile'] = "";
 | 
					      $fields[':artfile'] = "";
 | 
				
			||||||
| 
						 | 
					@ -118,12 +147,14 @@ function parseSongs() {
 | 
				
			||||||
            $fields[':artfile'] = $artmd5 . "." . $extbymimetypes[$mimetype];
 | 
					            $fields[':artfile'] = $artmd5 . "." . $extbymimetypes[$mimetype];
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if ( ($fields[':artfile'] != "") && !file_exists(ARTDIR . $fields[':artfile']) ) {
 | 
					      if ( !SIMULATE ) {
 | 
				
			||||||
         file_put_contents(ARTDIR . $fields[':artfile'], $info['comments']['picture'][0]['data']);
 | 
					         if ( ($fields[':artfile'] != "") && !file_exists(ARTDIR . $fields[':artfile']) ) {
 | 
				
			||||||
 | 
					            file_put_contents(ARTDIR . $fields[':artfile'], $info['comments']['picture'][0]['data']);
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					         $sth_info->execute($fields);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      $parsecount++;
 | 
					      $parsecount++;
 | 
				
			||||||
      if ( ($parsecount % 1000) == 0 ) echo ".";
 | 
					      if ( ($parsecount % 1000) == 0 ) echo ".";
 | 
				
			||||||
      $sth_info->execute($fields);
 | 
					 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
   return $parsecount;
 | 
					   return $parsecount;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -160,4 +191,4 @@ echo "Parsing ID3 tags...";
 | 
				
			||||||
$parsecount = parseSongs();
 | 
					$parsecount = parseSongs();
 | 
				
			||||||
echo " ", $parsecount, " tags parsed.\n";
 | 
					echo " ", $parsecount, " tags parsed.\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
?>
 | 
					// vim: set et ts=3 sw=3 ai mouse-=a:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,4 +86,4 @@ switch ($argv[1]) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
echo "\n";
 | 
					echo "\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// vim: ts=3:sw=3
 | 
					// vim: ts=3 sw=3 et ai:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user