我想添加Yogaglo对youtube dl的支持。在
我遵循了Github的指导。在
并起草了以下文件:
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
class YogagloIE(InfoExtractor):
_SIGNIN_URL = 'https://www.yogaglo.com/login'
_PASSWORD_URL = 'https://www.yogaglo.com/login/password'
_USER_URL = 'https://www.yogaglo.com/login/user'
_ACCOUNT_CREDENTIALS_HINT = 'Use --username and --password options to provide yogaglo.com account credentials.'
_NETRC_MACHINE = 'yogaglo'
def _real_initialize(self):
self._login()
_VALID_URL = r'https?://(?:www\.)?yogaglo\.com/class/(?P<id>[0-9]+)'
_TEST = {
'url': 'https://www.yogaglo.com/class/7206',
'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)',
'info_dict': {
'id': '7206',
'ext': 'mp4',
'title': 'Have a Great Day!'
# TODO more properties, either as:
# * A value
# * MD5 checksum; start the string with md5:
# * A regular expression; start the string with re:
# * Any Python type (for example int or float)
}
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<h1>(.+?)</h1>', webpage, 'title')
return {
'id': video_id,
'title': title,
'description': self._og_search_description(webpage),
'uploader': self._search_regex(r'<div[^>]+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False),
# TODO more properties (see youtube_dl/extractor/common.py)
}
我已经将yogagloIE添加到提取器列表中,当我运行它时,我得到一个错误:URL不受支持。这实际上是一个初稿和任何指导,以改善它和使它发挥作用是推荐的。在
在Python中,缩进是非常重要的,所以要确保正确地缩进类。在
之后,您必须定义一个
_login
方法,或者简单地将_real_initialize
留空。在实现后,将调用提取器(当然它还不能正常工作):
您可以使用下面的命令(可能是
^{pr2}$git stash
之前的所有命令)来获取此工作状态,并将旧的瑜伽糖.py其他文件):相关问题 更多 >
编程相关推荐