流式音频(YouTube)的 [英] Streaming audio (YouTube)

查看:134
本文介绍了流式音频(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 psented重新$ P $ = 网址的部分,一个隐藏字段 T = 这是在页面的源代码present。我不知道这是什么 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=*******

凡星重新present获得的值。

Where the stars represent the values obtained.

我猜你可以要求用户输入的视频ID,因为它是直接地获得。那么你的程序将下载 HTML源为该视频,解析为<$ C $源C> 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;

<一个href=\"http://www.youtube.com/get_video?video_id=3HrSN7176XI&t=vjVQa1PpcFNM4c8MbEhsnGaNvYKoYERIJ-hK7ErLpUI=\" rel=\"nofollow\">http://www.youtube.com/get_video?video_id=3HrSN7176XI&t=vjVQa1PpcFNM4c8MbEhsnGaNvYKoYERIJ-hK7ErLpUI=

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

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