Embed videos from multiple sources - php

I am working on an application that displays a form to the user, the user inputs a video URL to be displayed on their profile. The video could be coming from any possible source like Youtube, Vimeo, etc. Right now I'm using an iframe on my view.
I want the users to be able to post their videos by pasting the video URL directly from their browsers. But on most sites the url required by the iframe is different than the one displayed on the browser. For example on youtube the url displayed on the browser is https://youtube.com/watch?v=id but the URL used for embedding the video ishttps://youtube.com/embed/id . Is there a way to solve this the fast way or do I have to use regular expressions to rewrite each URL?

Related

Set timelines in embedded youtube video in my own website

I have embedded youtube video in my website and timelines in text format. Is there a way to make my text timelines clickable for user to jump between timelines in embedded video, similar to how it's working in youtube?
Maybe this plugin for wordpress can help you :
https://wordpress.org/plugins/skip-to-timestamp/
Otherwise you can add ?start=[nbSeconds] to the embed url like so :
https://www.youtube.com/embed/bESGLojNYSo?start=50
and modify the player url with some javascript when clicking on the timeline link

Downloading a video from a php page

I want to download a video on example.com, but it's "protected" by a flash player.
By inspecting the HTML code of the page, I've been able to get the direct URL to the mp4 video from the player's parameters, something like example.com/video.mp4.
When I try to go to example.com/video.mp4, I just get a blank page mentioning access denied. I figured that you need to do a specific request in order to get the video.
I analyzed traffic while reloading the page and playing the video through the player, and I've been able to get the right URL, which is along the lines of example.com/get_video.php?param1=some_hash&param2=some_hash&filename=video.mp4
When I visit example.com/get_video.php?param1=some_hash&param2=some_hash&filename=video.mp4, I do have the video playing alone, with no other content, in my browser's default player. But when I try to save it, the dialog box wants to save the PHP page...
How do I save the video now that I have it ?
Thanks.

PHP & post Youtube ID to another page

I've been searching for this a lot but have not found exactly what I'm looking for.
So, I have a page (index.php) which displays my YouTube channel's uploaded videos as thumbnails, and either displays them inline above the thumbnails, or as links that redirect to Youtube. What I'd like to do, is to get the video's ID (which is in the a href link) and post it to another page (video.php) that shows the full embedded video (of the ID in question), with title & description. Is this possible to do?
My site is loosely based on this: http://www.yvoschaap.com/youtube.html and I've tried Youmax, but like said, they only play videos inline. I want to pass the ID of a clicked video as a parameter to the video.php page.
Sorry if this is confusing, but I'm still quite new to programming :)
You can look into Youtube Data API.
The main link you will need to retreive a list of all Videos for a channel will be somewhat like:
https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults={number_of_videos_you_want}
It will recieve it's response in JSON Format containing information like your Video ID which you can pass as Parameter to your video.php page

How to get Facebook to thumbnail an image from URL in post

I'm building an image library site. It will be mostly private but I'd like users to be able to directly use certain images in facebook posts by special URLs.
The URLs look plain enough: http://example.com/some/path/image.jpg although they're actually generated on demand by a script.
But when I paste that URL (the URL of the image, not a page with the image on) to Facebook it just comes up with the domain name; it does not thumbnail the image.
There are many questions about open graph meta tags - but that's to do with pages, and this question is about the case of a post with a direct image URL. I notice that it works for images from imgur, for example.
Is there something in the way the image is served, or something about the quality of the image itself that I can change to get facebook to work? Or is it just something like facebook knows to treat certain image sites a different way?
Thanks.
I think Facebook grabs the image using some kind of OpenGraph "Browser". So you need to serve it meta information depending on the User-Agent, which is
facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)
for Facebook.
So when a user browser hits your URL you serve the image, when it's facebook you serve it open-graph meta-data.
The only thing, off the top of my head, that I can think of is your favicon for that page.
Visit http://www.w3.org/2005/10/howto-favicon for information on favicons in html.

Crawl embeded Flash video and render Javascript to obtain final GUI

Now, I am encountering some difficulties when I have to scan or crawl a video URL link. This web page is using the Flash-based technology to embed the video and stream video.
In order to understand more clearly, this is a link example:
http://vnexpress.net/gl/the-gioi/tu-lieu/2012/11/bai-phat-bieu-thua-nhan-that-bai-cua-romney/
The above link has below content (HTML code for Flash embedded video):
<div id="flashContent" style="text-align:center;width:100%;">
<span id="FlashPlayer79237" class="Normal" align="center">Bạn cần cài Flash Player để xem được Clip này.</span>
</div>
In this above article, there is a above video. However, when I tried to scan or crawl the content, the video could not run properly (because it could not load correct video link) and only show Install Flash Player plugin words (Certainly, the real web page needs to run some Javascript script or Flash script to obtain the real video link and stream this video for users)
Therefore, how can I render Flash and Javascript script through PHP or ASP.NET or Java? How can I get the correct video link when I crawl the web page? In this case, how can I obtain the correct Flash embedded video (HTML code)?
Thank you so much.
Before I answer, I want to make a note that if you need this information to do anything shady... please don't.
Disclaimer aside, for that particular site it is relatively easy.
The flashvars param (which is probably put there by Javascript) contains a value called xmlPath, which is a url encoded path (relative to their domain name). If you grab that and decode it, you get something like:
/Service/FlashVideo/PlayListVideoPage.asp?id=79237&f=108&t=1
which points to
http://vnexpress.net/Service/FlashVideo/PlayListVideoPage.asp?id=79237&f=108&t=1
If you read that, it's an XML file which contains the URL of the actual video.
I'm not quite sure where that value is generated from. If you needed to do this fully server-side, you could use a headless browser to process it.

Categories