mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-06 03:49:56 +02:00
fixed WMP11 Now Playing, broke Album Art gathering, re-writing to fix some serious logic flaws
This commit is contained in:
parent
2e6c6e4646
commit
0b4e8ed38c
6 changed files with 79 additions and 52 deletions
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
v.3.3.3-Beta3
|
v.3.3.3-Beta3
|
||||||
|
- Fixed Now Playing to account for Windows Media Player 11s
|
||||||
|
3 HTTP Requests per song stupidity
|
||||||
- Added ability to mass tag using play selected functionality
|
- Added ability to mass tag using play selected functionality
|
||||||
- Fixed Preferences page, preferences now ordered semi-logically
|
- Fixed Preferences page, preferences now ordered semi-logically
|
||||||
- Fixed MPD controller so it displays track numbers correctly
|
- Fixed MPD controller so it displays track numbers correctly
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
All Rights Reserved
|
All Rights Reserved
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License v2
|
||||||
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation.
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
@ -20,10 +19,11 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
@header Album Class
|
* Album Class
|
||||||
*/
|
* This is the class responsible for handling the Album object
|
||||||
|
* it is related to the album table in the database.
|
||||||
|
*/
|
||||||
class Album {
|
class Album {
|
||||||
|
|
||||||
/* Variables from DB */
|
/* Variables from DB */
|
||||||
|
@ -32,6 +32,10 @@ class Album {
|
||||||
var $year;
|
var $year;
|
||||||
var $prefix;
|
var $prefix;
|
||||||
|
|
||||||
|
/* Art Related Fields */
|
||||||
|
var $art;
|
||||||
|
var $art_mime;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function Album
|
@function Album
|
||||||
@discussion Album class, for modifing a song.
|
@discussion Album class, for modifing a song.
|
||||||
|
@ -39,51 +43,53 @@ class Album {
|
||||||
*/
|
*/
|
||||||
function Album($album_id = 0) {
|
function Album($album_id = 0) {
|
||||||
|
|
||||||
/* If we have passed an id then do something */
|
if (!$album_id) { return false; }
|
||||||
if ($album_id) {
|
|
||||||
|
|
||||||
/* Assign id for use in get_info() */
|
/* Assign id for use in get_info() */
|
||||||
$this->id = intval($album_id);
|
$this->id = $album_id;
|
||||||
|
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
if ($info = $this->get_info()) {
|
if ($info = $this->_get_info()) {
|
||||||
|
$this->name = trim($info['prefix'] . " " . $info['album_name']);
|
||||||
|
$this->songs = $info['song_count'];
|
||||||
|
$this->artist_count = $info['artist_count'];
|
||||||
|
$this->year = $info['year'];
|
||||||
|
$this->artist = trim($info['artist_prefix'] . " " . $info['artist_name']);
|
||||||
|
$this->artist_id = $info['art_id'];
|
||||||
|
$this->album = $info['album_name'];
|
||||||
|
$this->has_art = $info['has_art'];
|
||||||
|
$this->prefix = $info['prefix'];
|
||||||
|
} // if info
|
||||||
|
|
||||||
/* Assign Vars */
|
return true;
|
||||||
$this->name = trim($info->prefix . " " . $info->album_name);
|
|
||||||
$this->songs = $info->song_count;
|
|
||||||
$this->artist_count = $info->artist_count;
|
|
||||||
$this->year = $info->year;
|
|
||||||
$this->artist = trim($info->artist_prefix . " " . $info->artist_name);
|
|
||||||
$this->artist_id = $info->art_id;
|
|
||||||
$this->album = $info->album_name;
|
|
||||||
|
|
||||||
$this->prefix = $info->prefix;
|
|
||||||
} // if info
|
|
||||||
|
|
||||||
} // if album_id
|
|
||||||
|
|
||||||
} //constructor
|
} //constructor
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function get_info
|
@function get_info
|
||||||
@discussion get's the vars for $this out of the database
|
@discussion get's the vars for $this out of the database
|
||||||
@param $this->id Taken from the object
|
@param $this->id Taken from the object
|
||||||
*/
|
*/
|
||||||
function get_info() {
|
function _get_info() {
|
||||||
|
|
||||||
|
$this->id = intval($this->id);
|
||||||
|
|
||||||
/* Grab the basic information from the catalog and return it */
|
/* Grab the basic information from the catalog and return it */
|
||||||
$sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,album.prefix,album.year,album.name AS album_name,COUNT(song.id) AS song_count," .
|
$sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,album.prefix,album.year,album.name AS album_name,COUNT(song.id) AS song_count," .
|
||||||
"artist.name AS artist_name,artist.id AS art_id,artist.prefix AS artist_prefix ".
|
"artist.name AS artist_name,artist.id AS art_id,artist.prefix AS artist_prefix,album.art AS has_art ".
|
||||||
"FROM song,artist,album WHERE album.id='$this->id' AND song.album=album.id AND song.artist=artist.id GROUP BY song.album";
|
"FROM song,artist,album WHERE album.id='$this->id' AND song.album=album.id AND song.artist=artist.id GROUP BY song.album";
|
||||||
|
|
||||||
$db_results = mysql_query($sql, dbh());
|
$db_results = mysql_query($sql, dbh());
|
||||||
|
|
||||||
$results = mysql_fetch_object($db_results);
|
$results = mysql_fetch_assoc($db_results);
|
||||||
|
|
||||||
|
// If there is art then set it to 1, if not set it to 0, we don't want to cary
|
||||||
|
// around the full blob with every object because it can be pretty big
|
||||||
|
$results['has_art'] = strlen($results['has_art']) ? '1' : '0';
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} //get_info
|
} // _get_info
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function get_songs
|
@function get_songs
|
||||||
|
@ -131,12 +137,12 @@ class Album {
|
||||||
} // get_song_ids
|
} // get_song_ids
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* format_album
|
* format
|
||||||
* reformats this object with f_name, f_songs and f_artist
|
* This is the format function for this object. It sets cleaned up
|
||||||
* that contain links etc...
|
* album information with the base required
|
||||||
* //FIXME: Rename to format() so that it can be called more dynamicly between object types
|
* f_link, f_name
|
||||||
*/
|
*/
|
||||||
function format_album() {
|
function format() {
|
||||||
|
|
||||||
$web_path = conf('web_path');
|
$web_path = conf('web_path');
|
||||||
|
|
||||||
|
@ -157,22 +163,37 @@ class Album {
|
||||||
$this->year = "N/A";
|
$this->year = "N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // format
|
||||||
|
|
||||||
|
/**
|
||||||
|
* format_album
|
||||||
|
* DEPRECIATED DO NOT USE!
|
||||||
|
*/
|
||||||
|
function format_album() {
|
||||||
|
|
||||||
|
// Call the real function
|
||||||
|
$this->format();
|
||||||
|
|
||||||
} // format_album
|
} // format_album
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_art
|
* get_art
|
||||||
* get art wrapper function
|
* This function should be called for gathering and returning Album Art
|
||||||
|
* By default it ignores the DB and looks at the current gathering preferences
|
||||||
|
* as defined by the config file and attempts to find the album art. If the
|
||||||
|
* param FAST is passed then it will only check the database, if no art is
|
||||||
|
* found it return false. This only return the first art found and should
|
||||||
|
* not be used for the advanced album art finding functions, but for the
|
||||||
|
* catalog
|
||||||
*/
|
*/
|
||||||
function get_art($fast = 0) {
|
function get_art($fast = 0) {
|
||||||
|
|
||||||
/* Check DB first */
|
// If we are doing fast then only return
|
||||||
if ($image = $this->get_db_art()) {
|
// what's in the database
|
||||||
return $image;
|
if ($fast) {
|
||||||
|
return $this->get_db_art();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop here if we are doing the fast art */
|
|
||||||
if ($fast) { return false; }
|
|
||||||
|
|
||||||
/* Create Base Vars */
|
/* Create Base Vars */
|
||||||
$album_art_order = array();
|
$album_art_order = array();
|
||||||
|
|
||||||
|
|
|
@ -702,8 +702,8 @@ function get_newest ($type = 'artist') {
|
||||||
}
|
}
|
||||||
elseif ( $type == 'album' ) {
|
elseif ( $type == 'album' ) {
|
||||||
$album = new Album($item[0]);
|
$album = new Album($item[0]);
|
||||||
$album->format_album();
|
$album->format();
|
||||||
$items[] = "<li>" . $album->f_name . "</li>";
|
$items[] = "<li>$album->f_link</li>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
|
|
|
@ -56,7 +56,7 @@ function get_songs_from_type($type,$results,$artist_id='') {
|
||||||
|
|
||||||
$type = sql_escape($type);
|
$type = sql_escape($type);
|
||||||
|
|
||||||
$sql = "SELECT id FROM song WHERE ";
|
$sql = "SELECT id FROM song WHERE (";
|
||||||
|
|
||||||
foreach ($results as $value) {
|
foreach ($results as $value) {
|
||||||
$value = sql_escape($value);
|
$value = sql_escape($value);
|
||||||
|
@ -64,7 +64,7 @@ function get_songs_from_type($type,$results,$artist_id='') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the long query
|
// Run the long query
|
||||||
$sql = rtrim($sql,'OR ');
|
$sql = rtrim($sql,'OR ') . ')';
|
||||||
$sql .= " ORDER BY `track`";
|
$sql .= " ORDER BY `track`";
|
||||||
|
|
||||||
$db_results = mysql_query($sql,dbh());
|
$db_results = mysql_query($sql,dbh());
|
||||||
|
|
|
@ -52,6 +52,9 @@ function delete_now_playing($insert_id) {
|
||||||
*/
|
*/
|
||||||
function gc_now_playing() {
|
function gc_now_playing() {
|
||||||
|
|
||||||
|
/* Account for WMP11's Initial Streaming */
|
||||||
|
if (strstr($_SERVER['HTTP_USER_AGENT'],"WMFSDK/11")) { return false; }
|
||||||
|
|
||||||
$time = time();
|
$time = time();
|
||||||
$expire = $time - 3200; // 86400 seconds = 1 day
|
$expire = $time - 3200; // 86400 seconds = 1 day
|
||||||
$session_id = sql_escape($_REQUEST['sid']);
|
$session_id = sql_escape($_REQUEST['sid']);
|
||||||
|
@ -80,6 +83,9 @@ function insert_now_playing($song_id,$uid,$song_length) {
|
||||||
/* Windows Media Player is evil and it makes multiple requests per song */
|
/* Windows Media Player is evil and it makes multiple requests per song */
|
||||||
if (stristr($user_agent,"Windows-Media-Player")) { return false; }
|
if (stristr($user_agent,"Windows-Media-Player")) { return false; }
|
||||||
|
|
||||||
|
/* Check for Windows Media Player 11 */
|
||||||
|
if (strstr($user_agent,"WMFSDK/11")) { return false; }
|
||||||
|
|
||||||
/* Set the Expire Time */
|
/* Set the Expire Time */
|
||||||
|
|
||||||
// If they are using Windows media player
|
// If they are using Windows media player
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
$web_path = conf('web_path');
|
$web_path = conf('web_path');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<form method="post" action="" enctype="multipart/form-data">
|
|
||||||
<table border="0" cellpadding="14" cellspacing="0" class="text-box">
|
<table border="0" cellpadding="14" cellspacing="0" class="text-box">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
@ -67,4 +66,3 @@ if (is_object($GLOBALS['playlist'])) { ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue