phpcurlweb-scrapingvideo-streamingjwplayer

How can i get source url of online streaming video using jwplayer


I have been struggling to get the streaming source of this video.

https://vidnode.net/streaming.php?id=MTU3MjM2&title=Hostiles&typesub=SUB&sub_es=true&sub=L2hvc3RpbGVzL2hvc3RpbGVzLnZ0dA==

it is using jwplayer and i can see its source via chrome developer tools.

https://video.xx.fbcdn.net/v/t42.9040-2/10000000_187709758618199_5004280148501987328_n.mp4?_nc_cat=0&efg=eyJybHIiOjE1MDAsInJsYSI6NDA5NiwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=1500&vabr=571&oh=0bdc32a88a81edb15ea8470c6dc1b9fd&oe=5B00DA98

But is there any way i can scrape and get it programatically via php?Any help will be highly appreciated.


Solution

  • The source for video is right there in the HTML of the page, in the script section:

        <div id="myVideo"></div>
        <script type="text/JavaScript">
            var playerInstance = jwplayer("myVideo");
            var countplayer = 1;
            var countcheck = 0;
            playerInstance.setup({
                sources:[{file: 'https://video.xx.fbcdn.net/v/t42.9040-2/10000000_187709758618199_5004280148501987328_n.mp4?_nc_cat=0&efg=eyJybHIiOjE1MDAsInJsYSI6NDA5NiwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=1500&vabr=571&oh=0bdc32a88a81edb15ea8470c6dc1b9fd&oe=5B00DA98',label: 'auto P','type' : 'mp4'}],
    

    You just have to get the file value from the first sources array.

    preg_match("/sources:\[{file:\ '(.*?)'/s", $html, $match);
    echo($match[1]);
    

    gives the sought result:

    https://video.xx.fbcdn.net/v/t42.9040-2/10000000_187709758618199_5004280148501987328_n.mp4?_nc_cat=0&efg=eyJybHIiOjE1MDAsInJsYSI6NDA5NiwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=1500&vabr=571&oh=0bdc32a88a81edb15ea8470c6dc1b9fd&oe=5B00DA98