summaryrefslogtreecommitdiffstats
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
parent3900727d938a6bdbe8453188a030abccb4fa537a (diff)
downloadampache-ac832cdab9476929ab08cf6b433cbccb8369b77b.tar.gz
ampache-ac832cdab9476929ab08cf6b433cbccb8369b77b.tar.bz2
ampache-ac832cdab9476929ab08cf6b433cbccb8369b77b.zip
add url_to_song function to api for amarok2
-rw-r--r--index.php2
-rw-r--r--lib/class/song.class.php22
-rw-r--r--server/xml.server.php7
-rw-r--r--templates/show_index.inc.php2
4 files changed, 31 insertions, 2 deletions
diff --git a/index.php b/index.php
index a7c3e852..c8274937 100644
--- a/index.php
+++ b/index.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
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
diff --git a/server/xml.server.php b/server/xml.server.php
index b6deeec1..ef5e3658 100644
--- a/server/xml.server.php
+++ b/server/xml.server.php
@@ -232,6 +232,13 @@ switch ($_REQUEST['action']) {
ob_end_clean();
echo xmlData::songs(array($uid));
break;
+ case 'url_to_song':
+ $url = scrub_in($_REQUEST['url');
+
+ $song_id = Song::parse_song_url($url);
+ ob_end_clean();
+ echo xmlData:;songs(array($song_id));
+ break;
case 'playlists':
Browse::reset_filters();
Browse::set_type('playlist');
diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php
index 938313c8..c9070eac 100644
--- a/templates/show_index.inc.php
+++ b/templates/show_index.inc.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or