diff options
author | Paul Arthur <flowerysong00@yahoo.com> | 2013-01-15 00:56:42 -0500 |
---|---|---|
committer | Paul Arthur <flowerysong00@yahoo.com> | 2013-01-15 11:30:47 -0500 |
commit | e2ca05d5b419944adb3723ab0253c7c35418a0e4 (patch) | |
tree | f4d0635b3690cd6c060acf69c3afebc8a7e67284 /play/index.php | |
parent | e2484ee9a0e7f7de16fe2b3d015af59f0c9111c0 (diff) | |
download | ampache-e2ca05d5b419944adb3723ab0253c7c35418a0e4.tar.gz ampache-e2ca05d5b419944adb3723ab0253c7c35418a0e4.tar.bz2 ampache-e2ca05d5b419944adb3723ab0253c7c35418a0e4.zip |
Make playlist downloads idempotent
Should fix the VLC plugin, as well as allow direct use of an Ampache
site on Android devices.
First, split the Stream class into an instantiable class that does the
playlist wrangling and a static class that handles the streaming stuff.
How does this work? Well, stream.php does its fancy stuff like
gathering the media IDs and clearing the playlist, but instead
of generating the playlist file there we use the Stream_Playlist
class to store the list of URLs in the database, then redirect to
play/index.php to create the actual download (there are some magic
playlist types like localplay that don't need to redirect.)
The playlist will be cached as long as that stream session is active, so
it can be downloaded multiple times and by clients that don't share the
browser's cookie cache.
Clean up the playlist generation by reducing copypasta.
Diffstat (limited to 'play/index.php')
-rw-r--r-- | play/index.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/play/index.php b/play/index.php index e7c3917c..fb50a6ce 100644 --- a/play/index.php +++ b/play/index.php @@ -39,10 +39,19 @@ ob_end_clean(); /* These parameters had better come in on the url. */ $uid = scrub_in($_REQUEST['uid']); -$oid = $_REQUEST['song'] ? scrub_in($_REQUEST['song']) : scrub_in($_REQUEST['oid']); +$oid = $_REQUEST['oid'] + // FIXME: Any place that doesn't use oid should be fixed + ? scrub_in($_REQUEST['oid']) + : scrub_in($_REQUEST['song']); $sid = scrub_in($_REQUEST['ssid']); $xml_rpc = scrub_in($_REQUEST['xml_rpc']); $video = make_bool($_REQUEST['video']); +$type = scrub_in($_REQUEST['type']); + +if ($type == 'playlist') { + $playlist_type = scrub_in($_REQUEST['playlist_type']); + $oid = $sid; +} /* This is specifically for tmp playlist requests */ $demo_id = scrub_in($_REQUEST['demo_id']); @@ -120,6 +129,18 @@ if (Config::get('access_control')) { } } // access_control is enabled +// Handle playlist downloads +if ($type == 'playlist') { + $playlist = new Stream_Playlist($oid); + // Some rudimentary security + if ($uid != $playlist->user) { + access_denied(); + exit; + } + $playlist->generate_playlist($playlist_type, false); + exit; +} + /** * If we've got a tmp playlist then get the * current song, and do any other crazyness |