summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2012-04-12 21:42:44 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2012-04-12 21:42:44 -0400
commitecdb8bc02df492995431eed115750ae427b67543 (patch)
tree5130b086b436dd73d88e79a0076cf1f67ae2226e
parentdec61fc7511ed92c349c7cd4bf2f4dbdc47a2731 (diff)
downloadampache-ecdb8bc02df492995431eed115750ae427b67543.tar.gz
ampache-ecdb8bc02df492995431eed115750ae427b67543.tar.bz2
ampache-ecdb8bc02df492995431eed115750ae427b67543.zip
Add support for pulling ratings from id3 tags
Not used by anything yet, but it might work.
-rw-r--r--lib/class/vainfo.class.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php
index f453f398..1aeaddcb 100644
--- a/lib/class/vainfo.class.php
+++ b/lib/class/vainfo.class.php
@@ -288,6 +288,7 @@ class vainfo {
$info['size'] = $info['size'] ?: $tags['size'];
$info['mime'] = $info['mime'] ?: $tags['mime'];
$info['encoding'] = $info['encoding'] ?: $tags['encoding'];
+ $info['rating'] = $info['rating'] ?: $tags['rating'];
$info['time'] = $info['time'] ?: intval($tags['time']);
$info['channels'] = $info['channels'] ?: $tags['channels'];
@@ -692,12 +693,14 @@ class vainfo {
$id3v2 = $this->_raw['id3v2'];
if(!empty($id3v2['UFID'])) {
+ // Find the MBID for the track
foreach ($id3v2['UFID'] as $ufid) {
if ($ufid['ownerid'] == 'http://musicbrainz.org') {
$array['mb_trackid'] = $this->_clean_tag($ufid['data']);
}
}
+ // Find the MBIDs for the album and artist
for ($i = 0, $size = sizeof($id3v2['comments']['text']) ; $i < $size ; $i++) {
if ($id3v2['TXXX'][$i]['description'] == 'MusicBrainz Album Id') {
$array['mb_albumid'] = $this->_clean_tag($id3v2['comments']['text'][$i]);
@@ -708,6 +711,17 @@ class vainfo {
}
}
+ // Find the rating
+ if (is_array($id3v2['POPM'])) {
+ foreach ($id3v2['POPM'] as $popm) {
+ if (array_key_exists('email', $popm) &&
+ $user = User::get_from_email($popm['email'])) {
+ // Ratings are out of 255; scale it
+ $array['rating'][$user->id] = $popm['rating'] / 255 * 5;
+ }
+ }
+ }
+
return $array;
} // _parse_id3v2