I'm using YouTube's Android Player API to play YouTube videos in an app I'm developing. A video's ID must be supplied to the API to load a video, but in this situation I'm trying to play a video given it's URL. Plenty of SO questions suggest ways of using regex to obtain the video ID from a URL, but that seems temperamental, and the YouTube developer policies say developers can't "...use any technology other than YouTube API Services to access or retrieve API Data, including to access any portion of any YouTube audiovisual content", which seems to indicate that this is not the intended way to load videos.
Is there a recommended way of using YouTube's API's to obtain a video ID from its URL?
Try this,
Pattern compiledPattern = Pattern.compile(pattern);
Matcher matcher = compiledPattern.matcher("https://www.youtube.com/watch?v=fhWaJi1Hsfo");
if (matcher.find()) {
String id = matcher.group();
Log.i("id", "++++" + id);
}
Hope it helps you.!!
Related
I want to use the YouTube API to check for a current livestream and get it's URL. The livestream is UNLISTED.
I can successfully get information on my PUBLIC livestream from my channel using this:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=MyChannelId&type=video&eventType=live&key=MyApiKey
However it does not return any results when the livestream is UNLISTED.
What am I missing here?
EDIT:
I am using PHP if that matters.
It appears that this is probably what I am trying to implement: https://developers.google.com/api-client-library/php/auth/service-accounts
And perhaps I will need to use liveStream or liveBroadcast? https://developers.google.com/youtube/v3/live/getting-started
This is the intended feature for any UNLISTED videos/streams. They cannot be accessed like regular vids. UNLISTED vids can only be accessed through:
anyone who knows the video's unique video ID can retrieve the video
metadata.
as mentioned in Youtube properties.
Also Jeff Posnick of Youtube answered in this google forum:
The public videos feed doesn't contain any information about private
or unlisted videos, so they won't be returned in the results.
My product is a media player box without a browser supports. Our YouTube application on the box used to use v2 to retrieve videos's url links with mp4 formats to make a playback:
http://gdata.youtube.com/feeds/api/videos/VIDEO_ID?format=3
Recently, all video links using this method direct me to a warning video, saying that I need to migrate to v3.
I study the v3 but cannot find a way to retrieve the video links.
How can I supposed to play YouTube videos without a browser on my box?
Are there any official ways?
as mentioned in the question
Can I get the youtube as sound file with any extension
I mean specifically with using JSON or any other way ?
One way to get songs from Youtube is to use their API, and search for your song. It will return a youtubeID url of video/song.
You can then stream this into an iOS app.
A handy framework to extract video url from youtube ID url, is LBYoutubePlayer which can be found here https://github.com/larcus94/LBYouTubeView
You would then need to extract the audio from the video.
Technically, that could all work. Not sure if it goes beyond Youtube's terms and services though.
I want to develop an app that uses videos issued from dailymotion or youtube.
I wanted to know if there are some conditions or legal rules for using the player api of this sites.
My main question : I want to do an application that act on the video, so the user should look and can't interact. Is it a problem if the user can't act on the video ?
The YouTube API Terms of Service dictates what you can and can't do using the YouTube Data and Player APIs:
https://developers.google.com/youtube/terms
I can't answer specific legal/policy questions—you should read the ToS for yourself and interpret it.
I am uploading videos using the YouTube/Gdata API (in python).
After a video has been uploaded via the API, I receive the a response with data about the video (Youtube link, id, etc). However, the video is not publicly available while it is being encoded by YouTube (typically a few minutes).
Can I specify a callback url that YouTube can post to after it finishes processing the video?
No.
You need to poll using the video id to and check the 'state' of the video to detect when 'processing' is no longer present.
With Youtube's V3 API, you need to do something similar, but slightly different.
GET https://www.googleapis.com/youtube/v3/videos?part=processingDetails&id={VIDEO_ID}&key={YOUR_API_KEY}
Further details here:
https://developers.google.com/youtube/v3/docs/videos/list