如果一切顺利那么,YouTube 将使用 HTTP 303 See Other 进行响应,其中包含一个 Location 标头,其中包含指向 FLV 文件的直接链接。
UPDATE: This answer may now be outdated, see comments below. This was going to happen eventually anyway, as YouTube phases out FLV and shifts toward HTML5 video...
They simply resolve the link to the actual FLV file, and download it.
This is done by copying the video identifier from the URL:
Looking at the extension code, you can see it's doing it by regex parsing HTTP responses for various content types. The code is located in network-probe.js.
发布评论
评论(2)
更新:这个答案现在可能已经过时,请参阅下面的评论。无论如何,随着 YouTube 逐步淘汰 FLV 并转向 HTML5 视频,这最终会发生...
他们只是解析了实际 FLV 的链接文件,然后下载。
这是通过从 URL 复制视频标识符来完成的:
用于请求有关视频的信息:
视频信息包含一个
TOKEN
,然后您可以使用它来发出另一个请求:如果一切顺利那么,YouTube 将使用
HTTP 303 See Other
进行响应,其中包含一个Location
标头,其中包含指向FLV
文件的直接链接。UPDATE: This answer may now be outdated, see comments below. This was going to happen eventually anyway, as YouTube phases out FLV and shifts toward HTML5 video...
They simply resolve the link to the actual FLV file, and download it.
This is done by copying the video identifier from the URL:
Which is used to request info about the video:
The video info includes a
TOKEN
, which you can then you use to make another request:If all goes well, YouTube will respond with
HTTP 303 See Other
, including aLocation
header with a direct link to theFLV
file.查看扩展代码,您可以看到它是通过正则表达式解析各种内容类型的 HTTP 响应来实现的。该代码位于 network-probe.js 中。
具体来说,它使用 Firefox 插件 sdk 中的 http-on-examine-response 事件 - https ://developer.mozilla.org/en-US/docs/Observer_Notifications#HTTP_requests
Looking at the extension code, you can see it's doing it by regex parsing HTTP responses for various content types. The code is located in network-probe.js.
Specifically its using the http-on-examine-response event in the Firefox addon sdk - https://developer.mozilla.org/en-US/docs/Observer_Notifications#HTTP_requests