Search code examples
phphtmlvideotumblr

tumblr: retreive the video id from the video html string


I have connected to tumblr with php and I have got the video code, but when the video is an mp4 and inserted there is no overlaying play button. I have noticed that if I take the unique video reference and pass it to an iframe it could work.

The following is returned from tumblr. How can I get the number '123988138584' in the output so I can use in a different way? I need to do this on a loop, so I can't search for that number, I guess i need to grab the number between the 5th and 6th / in the source.

<video id="embed-59724c3fde66d663835959" class="crt-video crt-skin-default" width="250" height="141" poster="https://31.media.tumblr.com/tumblr_nrfpgvIFCb1twbtyc_frame1.jpg" preload="none" muted="" data-crt-video="" data-crt-options="{&quot;autoheight&quot;:null,&quot;duration&quot;:17,&quot;hdUrl&quot;:&quot;https:\/\/clarestrand.tumblr.com\/video_file\/t:8tTSaNxZkkAOPCxNMgJHPw\/123988138584\/tumblr_nrfpgvIFCb1twbtyc\/720&quot;,&quot;filmstrip&quot;:{&quot;url&quot;:&quot;https:\/\/33.media.tumblr.com\/previews\/tumblr_nrfpgvIFCb1twbtyc_filmstrip.jpg&quot;,&quot;width&quot;:&quot;200&quot;,&quot;height&quot;:&quot;112&quot;}}" controls="controls">
    <source src="https://clarestrand.tumblr.com/video_file/t:8tTSaNxZkkAOPCxNMgJHPw/123988138584/tumblr_nrfpgvIFCb1twbtyc/480" type="video/mp4">
</video>

I am open to other ideas. I need a play button on the video.

Thanks


Solution

  • preg_match would be the way

    preg_match("/\/video_file\/t\:.*\/(.*)\/.*\/.*\//", "$html", $matches, null, 0);
    

    Tested at: https://xrg.es/#1kiuxbb