如何获取youtube任意视频的数据流链接?

发布于 2024-10-09 17:19:18 字数 161 浏览 1 评论 0原文

我不确定这是否是发布这个问题的正确位置,我用谷歌搜索了很多关于这个问题的信息,但什么也没有出现。对于表单的链接

http://www.youtube.com/watch?v=[video_id]

如何获取数据流的链接?

I'm not sure if this is the right place to post this question,I googled a lot about this,but nothing turned up,. for a link of the form

http://www.youtube.com/watch?v=[video_id]

How do i get the link for the data stream?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风轻花落早 2024-10-16 17:19:18

以下 bash 脚本将检索 youtube 流媒体 url。我知道这已经过时了,但也许这会对某人有所帮助。

#!/bin/bash

[ -z "$1" ] && printf "usage: `basename $0` <youtube_url>\n" && exit 1

ID="$(echo "$1" | grep -o "v=[^\&]*" | sed 's|v=||')"
URL="$(curl -s "http://www.youtube.com/get_video_info?&video_id=$ID" | sed -e 's|%253A|:|g' -e 's|%252F|/|g' -e 's|%253F|?|g' -e 's|%253D|=|g' -e 's|%2525|%|g' -e 's|%2526|\&|g' -e 's|\%26|\&|g' -e 's|%3D|=|g' -e 's|type=video/[^/]*&sig|signature|g' | grep -o "http://o-o---preferred[^:]*signature=[^\&]*" | head -1)"

[ -z "$URL" ] && printf "Nothing was found...\n" && exit 2

echo "$URL"

The following bash script will retrieve youtube streaming url's. I know this is outdated, but maybe this will help someone.

#!/bin/bash

[ -z "$1" ] && printf "usage: `basename $0` <youtube_url>\n" && exit 1

ID="$(echo "$1" | grep -o "v=[^\&]*" | sed 's|v=||')"
URL="$(curl -s "http://www.youtube.com/get_video_info?&video_id=$ID" | sed -e 's|%253A|:|g' -e 's|%252F|/|g' -e 's|%253F|?|g' -e 's|%253D|=|g' -e 's|%2525|%|g' -e 's|%2526|\&|g' -e 's|\%26|\&|g' -e 's|%3D|=|g' -e 's|type=video/[^/]*&sig|signature|g' | grep -o "http://o-o---preferred[^:]*signature=[^\&]*" | head -1)"

[ -z "$URL" ] && printf "Nothing was found...\n" && exit 2

echo "$URL"
绮筵 2024-10-16 17:19:18

以下是有关对 YouTube 页面进行逆向工程以提取流数据的快速课程。

在 HTML 中,您会发现一个

该代码段后面的引号中的文本是显示 Flash 对象的 HTML。 请注意,此文本是一组连接在一起的分解字符串,因此您需要对其进行清理(即删除 '" + "' 的实例以及转义反斜杠以获得 HTML字符串。)

清理后,您需要找到 ;标记name="flashvars",此标记的值是一个 & 分隔的 URL。对 & 进行拆分您将获得与该视频相关的所有数据的键值对。

您要查找的主要是“fmt_url_map”,它是一个以“35|”开头的逗号分隔值的 URL 编码字符串。或“34|”或其他。 (这些在另一个键“fmt_list”中定义为分辨率为 854x480(35)、640x360(34)的文件,等等。)

Here's a quick lesson in reverse-engineering the YouTube page to extract the stream data.

In the HTML you'll find a <script> tag which defines a variable "swfHTML" - it looks like this: "var swfHTML = (isIE) ? "...

The text in the quotes that follows that snippet is the HTML that displays the Flash object. Note, this text is a set of broken up strings that get concatenated so you'll need to clean it up (i.e. strip instances of '" + "' and and escaping backslashes in order to get the HTML string.)

Once clean you'll need to find the <param> tag with name="flashvars", the value of this tag is an &-delimited URL. Do a split on the & and you'll get your key-value pairs for all the data relating to this video.

The main key you're looking for is "fmt_url_map" and it's an URL Encoded string of Comma-Separated Values starting with "35|" or "34|" or other. (These are defined in another key, "fmt_list" to be files of resolution 854x480 for 35, 640x360 for 34, etc..)

凉城已无爱 2024-10-16 17:19:18

每个频道都提供RSS数据,但不会立即更新。

这是 Youtube RSS 文件的生成器。您应该能够根据 RSS 信息推断出视频文件的位置。 flv 文件应该是可流式传输的,但也提供其他格式。

编辑:
http://www.referd.info/ 不再可用。它基本上是一项服务,您可以在其中提供 YouTube 链接,然后取消引用,找到该视频的所有可能的下载源。我确信这些服务仍然存在......这个已经不复存在了。

each channel provides rss-data, wich is not updated immediatelly.

Here is a generator for Youtube RSS Files. You should be able to deduce the location of videofiles based on the RSS information. The flv files should be streamable but other formats are also provided.

EDIT:
http://www.referd.info/ is no longer available. It basically was a service where you provided the youtube link and it dereferenced it found all possible downloadsources for that video. I am sure those services are still out there... this one isnt anymore.

淑女气质 2024-10-16 17:19:18

你需要像这样打开链接
http://www.youtube.com/get_video_info?&video_id=OjEG808MfF4
并找到您的流返回数据

You Need Open Link Like This
http://www.youtube.com/get_video_info?&video_id=OjEG808MfF4
And Find Your Stream Your In Return Data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文