javascript 下载/存储 Periscope 实时流媒体广播
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30073330/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Downloading/storing Periscope live streaming broadcasts
提问by Christian
I'm crawling tweets and, if available, store information to external resources (e.g., Instagram images). Now poeple start using Periscope where users tweet links to a Periscope live streaming broadcast (also then available for the next 24h). Hereis an example link, but it might be invalid/obsolete soon.
我正在抓取推文,并在可用的情况下将信息存储到外部资源(例如 Instagram 图像)。现在人们开始使用 Periscope,用户在推特上发布指向 Periscope 实时流媒体广播的链接(在接下来的 24 小时内也可用)。这是一个示例链接,但它可能很快就会失效/过时。
Is there any way I can fetch that broadcast, i.e., store it locally as a video file?
有什么方法可以获取该广播,即将其作为视频文件存储在本地?
When I look at the source code of a Periscope broadcast, I get something like that:
当我查看 Periscope 广播的源代码时,我得到了类似的信息:
<html>
<head>
...
<script src="https://assets.periscope.tv/assets/bugsnag-2.min.js"></script>
<script src="https://assets.periscope.tv/js/vendor.a8cd99eb89a488ec6ea465f57d3ad41bcd832eff.js"></script>
</head>
<body>
<div id="periscope-app" class="u-fullHeight"></div>
<script src="https://assets.periscope.tv/js/application.min.2a8176c317fb715fd0e6c2728cb04318c5c53941.js"></script>
</body>
So everything is essentially scripted. I've tried to look into the Javascript file to see if I can somehow at least reconstruct the stream URL or something. But I wasn't successful. I also tried with Google Chrome to inspect the requests made from the side. But this also didn't bring me any further.
所以一切基本上都是脚本化的。我试图查看 Javascript 文件,看看我是否可以以某种方式至少重建流 URL 或其他东西。但我没有成功。我还尝试使用 Google Chrome 来检查从侧面发出的请求。但这也没有让我更进一步。
EDIT: Here's my current Phantom.js script:
编辑:这是我当前的 Phantom.js 脚本:
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: periscope.js <periscope-url>');
phantom.exit();
}
page.onResourceRequested = function(request) {
console.log('Request ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function(response) {
console.log('Receive ' + JSON.stringify(response, undefined, 4));
};
address = system.args[1];
page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36';
page.open(address, function(status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
}
//phantom.exit();
});
When I use Google Chrome's Developer Tools I find the application/vnd.apple.mpegurl
request, but it never pops up from the Phantom.js script.
当我使用 Google Chrome 的开发人员工具时,我找到了application/vnd.apple.mpegurl
请求,但它从未从 Phantom.js 脚本中弹出。
回答by aergistal
It uses Http Live Streaming (HLS) on Chrome Desktop so just proxy/sniff HTTP responses of type application/vnd.apple.mpegurl
and get the request URL. I was able to watch your stream in VLC.
它在 Chrome 桌面上使用 Http Live Streaming (HLS),因此只需代理/嗅探 HTTP 响应类型application/vnd.apple.mpegurl
并获取请求 URL。我能够在 VLC 中观看您的视频流。
You can use Phantom.js.
您可以使用Phantom.js。
回答by georgiecasey
the latest version of the fantastic livestreamer(1.12.2) can download periscope videos
梦幻直播最新版(1.12.2)可以下载潜望镜视频
livestreamer https://www.periscope.tv/w/aKzPpDIxNDYxN3w2OTg1MTQxNZnjGACxw2Nyl6RSvdnX8T3EaE7z5mSvxfK_-uqS5SQv best --output output.mp4
if you want to do it programmatically seeing as this is StackOverflow, the periscope plugin in python is here: https://github.com/chrippa/livestreamer/blob/develop/src/livestreamer/plugins/periscope.py
如果您想以编程方式执行此操作,因为这是 StackOverflow,python 中的潜望镜插件在这里:https: //github.com/chrippa/livestreamer/blob/develop/src/livestreamer/plugins/periscope.py