访问'书呆子的统计数据' youtube iFrame中的数据

时间:2018-02-26 09:22:25

标签: javascript google-chrome youtube youtube-api

我目前正在根据给定的网络条件对视频YouTube的质量进行衡量。由于youtube player api,我编写了一个自定义Chrome扩展程序来播放视频并获取缓冲信息。

我现在需要的是书呆子的统计数据的内容'右键单击视频时显示的面板(example)。 由于UI自动化,我可以显示它。但是,当我尝试使用javascript访问此面板的内容时,由于跨源资源共享(CORS),我收到错误。

我只想阅读面板的Current/OptimalRes您是否知道如何获得它?

我一直在寻找这个问题的答案。已经提到here,但这篇文章的答案并不是我所寻找的,因为它只提供有关视频的一般信息,而不是实际播放的分辨率。

1 个答案:

答案 0 :(得分:-1)

很抱歉,此代码位于“ AutoIT”中,但应易于通过管道传递给Javascript或任何其他类似的语言。这是“书呆子统计”数据的完整列表:

#include <IE.au3>

;Attach to open YouTube player within browser
$oIE = _IEAttach ("https://www.youtube.com", "url",1)

;Get a reference to the movie player
$oPlayerRef = $oIE.document.getElementById("movie_player")

;Video ID / sCPN
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).video_id_and_cpn)
;Viewport / Frames
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).dims_and_frames)
;Current / Optimal Res
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).resolution)
;Volume / Normalized
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).volume)
;Codecs
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).codecs)
;Connection Speed
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).bandwidth_kbps)
;Network Activity
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).network_activity_bytes)
;Buffer Health
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).buffer_health_seconds)
;Mystery Text
msgbox(0,"",$oPlayerRef.getStatsForNerds(0).debug_info)
相关问题