Videos.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:enigma2-plugins 作者: opendreambox 项目源码 文件源码
def _request(self):
        ie_key = "YoutubeLive" if "live" in self._baseurl.lower() else "Youtube"
        try:
            self._setupFormatMap()
            with YoutubeDL(self._params) as ytdl:
                result = ytdl.extract_info(self._baseurl, ie_key=ie_key, download=False, process=True)
                if self.KEY_ENTRIES in result: # Can be a playlist or a list of videos
                    entry = result[self.KEY_ENTRIES][0] #TODO handle properly
                else:# Just a video
                    entry = result
                    fmt = entry.get(self.KEY_FORMAT_ID)
                    url = ""
                    suburi = ""
                    for f in entry.get(self.KEY_REQUESTED_FORMATS, []):
                        if not url and f.get(self.KEY_VCODEC, u"none") != u"none":
                            url = str(f.get(self.KEY_URL, ""))
                        elif not suburi and f.get(self.KEY_ACODEC, u"none") != u"none":
                            suburi = str(f.get(self.KEY_URL, ""))
                    if not url:
                        url = str(entry.get(self.KEY_URL, ""))
                    self._onResult(True, url, fmt, suburi)
        except Exception as e:
            Log.w(e)
            self._onResult(False, None, -1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号