1

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.

Adarsh Chouhan
  • 11
  • 1
  • 1
  • 6

3 Answers3

3

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
Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • Sadly this doesn't work (anymore?). Now it's been encoded and protected against scrapers. Any other ideas? – MG lolenstine Apr 16 '20 at 13:48
  • 2
    @MGlolenstine No it doesn't work anymore, they switched to HLS streaming. If you can intercept request for m3u8 playlist you can use ffmpeg to get all the pieces of the movie and stitch them together. Obviously the task is much more difficult now than writing a regex for html :) – Vaviloff Apr 16 '20 at 17:22
  • Not working when setup is [packed](https://stackoverflow.com/questions/21423397/what-is-the-custom-functionp-a-c-k-e-d-used-for) – Jurakin Mar 27 '23 at 16:07
1

No way. Getting it from the source is not possible everytime. Sometimes its hidden, and in this cases, you need to find the variable that difines the video url, usually something like :

*var video_url ="...*

So, you can open the page, play the video until it finishes, and on the console, run :

console.log(video_url);

This is fully functional, not fake .

David Augustus
  • 420
  • 3
  • 9
0

Suppose you can execute javascript (selenium) and your script looks like:

<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'}],

Then you can extract the url from the instance:

console.log(playerInstance.hls.url);
Jurakin
  • 832
  • 1
  • 5
  • 19