java - Downloading Flowplayer Videos With Authentication -


my university has uploaded lecture videos on website. access them, credentials have entered possess. using simple apache server. videos embedded flowplayer , not provide means of downloading them. html source of video page following:

<!doctype html> <html> <head> <meta charset="utf-8"> <title>show video</title> <script type="text/javascript" src="https://www.example.com/videos/javascript/jquery.js"></script> <link rel="stylesheet" type="text/css" href="https://www.example.com/videos/css/mta.css?timestamp=1440967823" /> </head> <body> <script src="javascript/flowplayer/flowplayer-3.2.12.min.js"></script> <div style="width: 256px; height: 256px; background-color: #ff00ff" id="player"></div> <script type="text/javascript"> $f("player", "javascript/flowplayer/flowplayer-3.2.16.swf", {     onload: function(){         $.get("https://www.example.com/videos/preparevideo",                 {videoid :'fae98609a52e6d252606248d1339e919'},                 function(data){                                         $f("player").play(data.url);                                         $('#player').width(data.width);                                         $('#player').height(data.height);                                         $('#title').html("playing "+data.description);                 }            );     } } ); </script> </body> </html> 

i tried observing network tab in chrome developer tools , revealed location of video due highest network consumption. called video.mp4.

opening url in browser returns page following contents:

<html><body>404 file not found, no session data found</body></html> 

why not find file? what's deal session data? authenticated myself. there way video , download programmatically via direct download link though assuming 1 can supply credentials?

not sure if information still helpful you, following short script trick:

#!/bin/sh vid="$1";  user="youknowit"; pass="youknowit";  file="cookies.txt" opts="--load-cookies=$file --save-cookies=$file --keep-session-cookies"; prep="https://www.example.com/the-real-fsid/preparevideo?videoid=$vid";  raw="$(wget $opts --user=$user --password=$pass -qo - $prep)"; echo $raw; url="$(echo $raw | grep '"url":"' | sed 's/.*"url":"\([^"]*\)".*/\1/g;s/\\//g')"; tag="$(echo $raw | grep '"description":"' | sed 's/.*"description":"\([^"]*\)".*/\1/g;s/\\//g')"; echo $url; wget $opts --user=$user --password=$pass -o "$tag".mp4 "$url"; echo "done!"; 

actually, sole purpose of http-server's credentials used here authenticate you. next steps important ones. site uses session-cookies keep track of request on video. "perparevideo"-script php-script, - far figure out - creating temporary file on server present while you're playing video. file seems become invalid if time elapses between preparation , download request.

so 2 consecutive http-requests necessary "see" real video file. realized 2 runs of wget-tool. "bonus" here is, file gets real name (tag) out of meta-information gathered first http-request.

the important thing is, 2 requests shall belong same session, rest easy ;)

i think invested amount of time in building video infrastructure , more in avoiding download of videos, funny thing is, lecture "security" covers "availability", videos there should (at least in opinion) available when 1 not able access internet, content should provided barrier-free. so, since of content available videos, there need download content same way can done pdf-files.

best wishes ...


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -