Have php script that generates stream urls from youtube video id.
Here is link I am using:
http://www.youtube.com/get_video_info?el=detailpage&asv=3&video_id={video_id}
I get url_encoded_fmt_stream_mapfrom this link and decode it to get urls. If video is using cipher signature then I decode it and generate working urls.
It works for all cases except regional restriction. My server is located in US and can't get video stream blocked in US.
For example:
This video https://www.youtube.com/watch?v=DrCI35uAqiw is blocked in US so I am getting this error from get_video_info :
reason=This+video+contains+content+from+Wediacorp%2C+who+has+blocked+it+in+your+country+on+copyright+grounds.&errordetail=0&errorcode=150&status=fail
If you have any solutions please share.
Thanks,
Shota.
Disclaimer :
You really should only use this method for accessing your own
video file content (like if Youtube holds a backup copy). If you just
take any multiple videos, you risk closing this option for all of us.
Morality rant over...
Instead of: http://www.youtube.com/get_video_info?el=detailpage&asv=3&video_id=video_id
Try this instead: http://www.youtube.com/get_video_info?&video_id=DrCI35uAqiw
Related
I want to get the m3u8 link which loaded after playing video. From the website https://www.firstonetv.eu. It's unavailable in HTML source code. Now I can see it on network tab in Chrome. Here is the image:
Network tab snap
But I want to get it through PHP.Also, a javascirpt solution is appreciated. How could I get the m3u8 link?
Every site is different. You would have to reverse engineer their site to figure out how it's getting the URL to the HLS playlist.
Alternatively, a generic solution could be implemented by writing a browser extension to look for application/x-mpegURL in the content type headers in HTTP responses... and when you find one, log it or open it elsewhere. Keep in mind that the video you get could be anything... ads and such.
What you should do instead though is contact the site and ask for access to their API or a better proper way to do this. You do have their permission, right?
Im using the PHP example code given in Youtube API v3 : https://developers.google.com/youtube/v3/docs/captions/download , to download captions from 3rd party, publicly available YouTube videos in my webapp i.e. I have NOT uploaded the content on Youtube.
I am able to get access to the list of caption tracks, but unable to download the caption using the caption track ID from the received list.
The error that shows up upon attempting to DOWNLOAD is:
Error calling GET https://
www.googleapis.com/youtube/v3/captions/Lw0e5xDNU17GFafOl8DcyeOtwzWJTf9V?tfmt=srt&alt=media:
(404) Not Found
(I have tried removing tfmt (optional parameter), but still gives an error.)
But the error is different for attempting to DELETE captions:
Error calling DELETE https://
www.googleapis.com/youtube/v3/captions?id=Lw0e5xDNU17GFafOl8DcyeOtwzWJTf9V:
(403) Forbidden
Therefore it seems that captions.download is NOT forbidden for users other than owner (just like the captions.list is NOT forbidden) and therefore I would like to use this data for my webapp.
Any help is gratefully received.
Thanks,
Nikhil
I just tried the URL you mentioned in a browser and in the API explorer, and in both cases I received a 401 when I had no oAuth token and a 403 when I had an access token (since I'm not the owner), so the endpoints are acting as intended; according to the documentation, downloading captions requires oAuth consent from the owner of the video.
Perhaps, if you're getting 404s instead, there's a problem in the PHP library?
I have found another way to access any YouTube video's caption data.
The code is written in Ruby.
Read Youtube transcript (captions) from any public Youtube video
Works great, I just need to find a way to integrate this with my webapp.
I'm using Google Cloud Storage for media. My website is stored elsewhere. I just want to display an image on my website without make this image public. I tried to display this image like this:
create API key for browser limited to my website (API key for http://*.example.com)
display image on this website <img src="https://www.googleapis.com/storage/v1/b/MY_BUKET/o/MY_MEDIA.jpg?key=MY_KEY" />
I can see in chrome console : ... "code": 401, "message": "Login Required" ...
I don't understand what I've missed, if I read the doc from google I'm lost: I just want to display an image with low security (but not public), not manage my media from my PHP app.
I can use google-api-php-client (my website is in PHP), but I don't know if I have something to do with this to make it work. I don't know where to start...
Thanks ! (I hope it's clear enough)
EDIT: I did not found any simple code example to render a private media in HTML using google-api-php-client; I'm lost
The "key=" parameter doesn't assign any sort of permissions. It's a less secure identifier that is used to tell Google which project should be billed for this otherwise-anonymous, incoming call. It won't get you access to objects that aren't publicly available.
The only way you could embed a non-public image into your web page would be to generate a signed URL when the HTML page is requested. See https://cloud.google.com/storage/docs/accesscontrol#Signed-URLs for instructions on generating them.
If your app is hosted on app engine then you can use the CloudStorageTools::serve() function to return the image as the result of a HTTP request and put in any access control you want.
There is site which gets direct link to youtube server as for example if we visit the link
http://vimow.com/watch?v=TLM6e_slo7Q-Play-Xbox-in-a-WEB-BROWSER?---Inside-Gaming-Daily
now if we view the page source will notice that there is the following link in video src
https://r5---sn-npo7enel.c.docs.google.com/videoplayback?mt=1410551258&expire=1410572981&ratebypass=yes&key=yt5&signature=C3FB417A7FB4C61600553152F9FFB57E473C762B.8F451B015AF741FFE45777DB5CEF424E452D433F&fexp=914095%2C927622%2C931983%2C932404%2C934030%2C946023%2C947209%2C948205%2C953600%2C953801%2C955400&upn=nnZKYWtq7gU&pfa=20s&initcwndbps=12869000&id=o-AMzBGT7otDdEr3LZCZRZA1hv1-ovI_PTghQHLJWtmAGq&ipbits=0&source=youtube&ms=au&pm_type=static&pbr=yes&mm=31&ip=128.199.133.159&sver=3&mv=m&sparams=id%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cmm%2Cms%2Cmv%2Cpbr%2Cpfa%2Cpm_type%2Cratebypass%2Csource%2Cupn%2Cexpire&itag=18
my question is that how they are getting that link from youtube ?
i searched youtube api but did not find any solution.
I've messaged you about your query. Check once. Since its not allowed as in terms of YouTube ToS, I can't disclose the method publically.
got o youtube choose your video and click share after that click include (or something like that i can see it in french soo..) it will genereate a link like this one embed it in your page :
<iframe width="560" height="315" src="//www.youtube.com/embed/YoB8t0B4jx4" frameborder="0" allowfullscreen></iframe>
or you can just make it (the iframe adding the url of the video look at src of the iframe abouve
I have got the solution for this problem.
Youtube videos are hosted in google's server.
So we need to find the root link to the video and we can just stream the video using any HTML player.
This is example of a link
https://r3---sn-npo7enee.c.docs.google.com/videoplayback?ms=au&source=youtube&mv=m&ip=128.199.175.59&initcwndbps=15683750&id=o-AOiPqW3plUekS9E0iFfUXJ6M6iuK8dAdvw0rtzBvFIMf&key=yt5&mm=31&ipbits=0&mt=1411445657&itag=18&sver=3&fexp=927622,930666,931983,932404,934030,936216,946023,947209,949408,952302,953801&upn=W8Os8snP-z8&sparams=id,initcwndbps,ip,ipbits,itag,mm,ms,mv,ratebypass,source,upn,expire&expire=1411467316&ratebypass=yes&signature=0F620B35EBCD3796509B9F72DC0EA15384721857.734B6A96DB834E600CEFBEF9305AA30E3F051A66
So i hope after getting this link you can easily stream a youtube video.
You can use youtube downloader which fetches the link using CURL.
A good script on github
https://github.com/jeckman/YouTube-Downloader
Using the script if you input the video id portion of any youtube video.
Example: youtube(dot)com/watch?v=Fw-BM-Mqgeg
It uses curl to fetch the video link and u can use the link to stream video in your site.
These movies are placed on Google Drive, and the link comes from there. See:
http://drive.google.com
For sharing details see:
https://support.google.com/drive/answer/2494822?hl=en&ref_topic=2525251
So, no, they're not from Youtube. There are API's for Google drive:
https://developers.google.com/drive/
For PHP see:
https://developers.google.com/drive/web/quickstart/quickstart-php
You'll have to familiarize yourself with this API before you can use it. The documentation by Google is far more than I could provide here.
The link you provided is a link in Google Drive. It has nothing to do with YouTube.
On another hand, if you're looking to embed YouTube videos in your website, then this will help you: https://developers.google.com/youtube/youtube_player_demo
If you want to stream a video while it occurs ("live streaming" or live coverage), then you need to use a special server which supports live streaming:
You can use the YouTube Live API: https://developers.google.com/youtube/v3/live/
You can use LiveSteam: http://new.livestream.com/
and there's many other streaming services
Keep in mind that you need a videocam which supports streaming services, or you should link the videocam to your computer. It depends on the streaming service you're using.
I have video files stored on my web server which I want to be able to upload to YouTube in an automated kind of way. These videos are created on my website, which then the user can just upload to their YouTube Channel.
I am trying to make HTTP request calls to automate this video upload process, according to the Resumable Video Upload process here: https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads
Everything works fine (getting the user's access permission, sending the metadata of the video) until the final step, which is the upload of the video itself. When I make the PUT request, it returns a response code 417 and says Invalid Request. Like this:
The following error was encountered:
Invalid Request
Some aspect of the HTTP Request is invalid. Possible problems:
Missing or unknown request method
Missing URL
Missing HTTP Identifier (HTTP/1.0)
Request is too large
Content-Length missing for POST or PUT requests
Illegal character in hostname; underscores are not allowed
I took a look at all those suggested possible problems, but I cannot find a fault anywhere in my code.
And the error message is just to vague and not specific enough to tell me where the problem is.
I am performing every step of the video upload process using the PHP's standard Http Request class. (http://www.php.net/manual/en/class.httprequest.php)
Here is my code:
$videoFile = *Some Video File*;
$httpRequest = new httpRequest($_SESSION['youtube_data_api']['upload_url'], HttpRequest::METH_PUT);
$httpRequest->setContentType('video/mp4');
$httpRequest->setPutFile($videoFile);
$headersArr = array('Content-Length' => strlen($httpRequest->getRawRequestMessage()));
$httpRequest->setHeaders($headersArr);
$httpMessage = $httpRequest->send();
I dug around on the internet a lot regarding this question, and a lot of times what I found are people using the Zend framework's YouTube library to accomplish this instead, which is a lot easier. Unfortunately, with the size of my website right now, it is just not feasible to spend some much time trying to integrate framework into my website.
Any insight into this problem would help tremendously! Thanks!