2017-12-05 11 views
1

youtube-dlのYogagloサポートを追加したいと思います。youtube-dlサイト対応のYogagloを追加

私は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がサポートされていないエラーが発生します。これは実際には最初の草案であり、改善するための鍬のガイダンスが推奨されています。

答えて

0

インデントが重要なので、クラスを正しくインデントするようにしてください。

その後、_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すべてを、この作業状態を引っ張って、あなたの名前を変更することができます古いyogaglo.pyファイル):

git pull https://github.com/phihag/youtube-dl.git yogaglo 
関連する問題