summaryrefslogtreecommitdiffstats
path: root/lib/class/stream_url.class.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-02-07 14:24:40 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2013-02-07 14:24:40 -0500
commit239ea81fdf2fa2bda8a8556e19412264396fe52a (patch)
tree0d753486ec6ded74cb4adb1a7e70dd9ce4ccfda6 /lib/class/stream_url.class.php
parent31afde9fc07a766229681a13d2cce0825e9fec93 (diff)
downloadampache-239ea81fdf2fa2bda8a8556e19412264396fe52a.tar.gz
ampache-239ea81fdf2fa2bda8a8556e19412264396fe52a.tar.bz2
ampache-239ea81fdf2fa2bda8a8556e19412264396fe52a.zip
Some cleanup of play URL handling
Move parsing from Song into Stream_URL and make it parse more things. Add the type parameter to all generated URLs instead of adding video to Video URLs.
Diffstat (limited to 'lib/class/stream_url.class.php')
-rw-r--r--lib/class/stream_url.class.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/class/stream_url.class.php b/lib/class/stream_url.class.php
index d651ca59..22a5777c 100644
--- a/lib/class/stream_url.class.php
+++ b/lib/class/stream_url.class.php
@@ -27,4 +27,33 @@ class Stream_URL extends memory_object {
public $properties = array('url', 'title', 'author', 'time', 'info_url', 'image_url', 'album', 'type');
+ /**
+ * parse
+ *
+ * Takes an url and parses out all the chewy goodness.
+ */
+ public static function parse($url) {
+ $query = parse_url($url, PHP_URL_QUERY);
+ $elements = explode('&', $query);
+ $results = array();
+
+ foreach ($elements as $element) {
+ list($key, $value) = explode('=', $items, 1);
+ switch ($key) {
+ case 'oid':
+ $key = 'id';
+ break;
+ case 'video':
+ if (make_bool($value)) {
+ $results['type'] = 'video';
+ }
+ default:
+ // Nothing
+ break;
+ }
+ $results[$key] = $value;
+ }
+
+ return $results;
+ }
}