问题
Using the YouTube Data API v3, is it actually able to return to me the URL for a video (by ID) of all the available video and audio streams? I have the YouTube video ID. I want to choose a video stream to play in a client app. I've read all the YouTube Data API documentation on this site:
https://developers.google.com/youtube/v3
And this question is not answered; in fact it seems to intentionally avoid this whole topic.
回答1:
Sorry for having to give you a negative response:
As far as I know, the answer to your question is no, there's no such API (and API endpoint for that matter) that will provide the URLs of the streams that YouTube does yield to its video players (embedded or not).
Of course, one may scrape this kind of info out of the YouTube's Web UI (like many tools available on the Internet do), but, if one does observe the DTOS specifications, will eventually come across the paragraph E.6 of section III. General Developer Policies, that explicitly forbids this activity.
An argument against the existence of such a API can also be derived from the DTOS document, same section III. General Developer Policies, but, in this case, from paragraph E.1:
E. Handling YouTube Data and Content
Aside from the permissions and rights granted in this section, you and your API Clients have no further permissions or rights to API Data, including to temporarily stored API Data.
Audiovisual Content
You and your API Clients must not, and must not encourage, enable, or require others to:
a. download, import, backup, cache, or store copies of YouTube audiovisual content without YouTube's prior written approval,
b. make content available for offline playback
c. [...]
Since is illegal to download video content from YouTube, it follows by simple formal logic, that it cannot exist an API that would provide URLs to the video content itself (under the assumption that the official APIs are formally consistent with the DTOS specifications).
回答2:
No the YouTube API doesn't give you the video url, otherwise it would be too easy to copy the file.
Also, YouTube videos can only be played inside the YouTube iFrame player and you can't have access to the HTML5 video object (to retrieve the video url) because of cross-domain policy.
来源:https://stackoverflow.com/questions/63974644/does-youtube-data-api-v3-provide-video-stream-urls