流媒体音频 (YouTube) [英] Streaming audio (YouTube)

查看:37
本文介绍了流媒体音频 (YouTube)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为音乐媒体平台编写 CLI.其中一项功能是您可以直接从 CLI 播放 YouTube 视频.我真的不知道该怎么做,但这听起来最合理:

I'm writing a CLI for a music-media-platform. One of the features is going to be that you can directly play YouTube videos from the CLI. I don't really have an idea of how to do it, but this one sounded the most reasonable:

我将使用那些可以从 YouTube 下载音乐的网站,例如 http://keepvid.com/ 然后我直接流式传输并播放它,但我有一个问题.有没有能够做到这一点的 Python 库,如果有,你有什么具体的例子吗?

I'm going to use of those sites where you can download music from YouTube, for example, http://keepvid.com/ and then I directly stream and play this, but I have one problem. Is there any Python library capable of doing this and if so, do you have any concrete examples?

我一直在寻找,但我什么也没找到,即使使用 GStreamer 也没有找到.

I've been looking, but I found nothing, even not with GStreamer.

推荐答案

你需要两个东西才能下载一个 YouTube 视频,视频 ID,由 v= 部分表示URL,以及存在于页面来源.我不知道这个 t 值是什么,但它是你需要的 :)

You need two things to be able to download a YouTube video, the video id, which is represented by the v= section of the URL, and a hidden field t= which is present in the page source. I have no idea what this t value is, but it's what you need :)

然后您可以使用格式中的 URL 下载视频;

You can then download the video using a URL in the format;

http://www.youtube.com/get_video?video_id=*******&t=*******

星星代表获得的值.

我猜您可以从用户输入中询问视频 ID,因为它很容易获得.然后,您的程序将下载该视频的 HTML 源代码,解析 的源代码t 值,然后使用新构建的 URL 下载视频.

I'm guessing you can ask for the video id from user input, as it's straightforward to obtain. Your program would then download the HTML source for that video, parse the source for the t value, then download the video using the newly constructed URL.

例如,如果您在浏览器中打开此链接,它应该会下载视频,或者您可以使用诸如 Wget;

For example, if you open this link in your browser, it should download the video, or you can use a downloading program such as Wget;

http://www.video?com/get_video_id=3HrSN7176XI&t=vjVQa1PpcFNM4c8MbEhsnGaNvYKoYERIJ-hK7ErLpUI=

这篇关于流媒体音频 (YouTube)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆