Search code examples
c#htmlwindows-store-appsmp4jwplayer

How do I get videostreaming mp4 from JWPlayer


I would like to programatically get straming URL to this video. The page uses JWPlayer, but there is no URL in the source coe.

I figured out that the URL for this particular video would be http://photon.trollvid.net/videos/076b127c.mp4, but I have no idea how to get the &st parameter. I'm using c# with html agility pack What should I do?


Solution

  • HttpClient client = new HttpClient();
    var html = await client.GetStringAsync(url);
    
    //result is in atob('....') as base64 encoded....
    var base64 = Regex.Match(html, @"atob\(\'(.+?)\'\)").Groups[1].Value;
    //make enough '=' padding
    base64 = base64.PadRight(base64.Length + (4 - base64.Length % 4) % 4, '=');
    
    var buf = Convert.FromBase64String(base64);
    var videourl = WebUtility.UrlDecode(Encoding.UTF8.GetString(buf));
    

    Output: http://photon.trollvid.net/videos/076b127c.mp4?st=2G8wyq0wtRqsQVYBzVJW_w&e=1439320535