summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-04-15 06:20:47 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-04-15 06:20:47 +0000
commitac832cdab9476929ab08cf6b433cbccb8369b77b (patch)
treedf2ca555f52ca131214e359c07298270110bb98f /lib/class
parent3900727d938a6bdbe8453188a030abccb4fa537a (diff)
downloadampache-ac832cdab9476929ab08cf6b433cbccb8369b77b.tar.gz
ampache-ac832cdab9476929ab08cf6b433cbccb8369b77b.tar.bz2
ampache-ac832cdab9476929ab08cf6b433cbccb8369b77b.zip
add url_to_song function to api for amarok2
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/song.class.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index e6caa24d..82cb521d 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -874,6 +874,28 @@ class Song {
} // get_url
/**
+ * parse_song_url
+ * Takes a URL from this ampache install and returns the song that the url represents
+ * used by the API, and used to parse out stream urls for localplay
+ * right now just gets song id might do more later, hence the complexity
+ */
+ public static function parse_song_url($url) {
+
+ preg_match("/.+\/play\/index.php\?(.+)/",$url,$matches);
+ $raw_data = $matches['1'];
+
+ $elements = explode("&",$raw_data);
+
+ foreach ($elements as $items) {
+ list($key,$value) = explode("=",$items);
+ if ($key == 'song') {
+ return $value;
+ }
+ } // end foreach
+
+ } // parse_song_url
+
+ /**
* get_recently_played
* This function returns the last X songs that have been played
* it uses the popular threshold to figure out how many to pull