在youtube-dl的支持列表中新增Yogaglo

2024-09-30 08:17:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我想添加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不受支持。这实际上是一个初稿和任何指导,以改善它和使它发挥作用是推荐的。在


Tags: thehttpsselfcomidurltitlewww
1条回答
网友
1楼 · 发布于 2024-09-30 08:17:12

在Python中,缩进是非常重要的,所以要确保正确地缩进类。在

之后,您必须定义一个_login方法,或者简单地将_real_initialize留空。在

实现后,将调用提取器(当然它还不能正常工作):

$ youtube-dl test:yogaglo
[TestURL] Test URL: https://www.yogaglo.com/class/7206
[Yogaglo] 7206: Downloading webpage
ERROR: Unable to extract title; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the  verbose flag and include its complete output.

您可以使用下面的命令(可能是git stash之前的所有命令)来获取此工作状态,并将旧的瑜伽糖.py其他文件):

^{pr2}$

相关问题 更多 >

    热门问题