]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/mychannels.py
[tumblr] Fix 403 errors and handle vimeo embeds (#2542)
[yt-dlp.git] / yt_dlp / extractor / mychannels.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4
5 from .common import InfoExtractor
6
7
8 class MyChannelsIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?mychannels\.com/.*(?P<id_type>video|production)_id=(?P<id>[0-9]+)'
10 _TEST = {
11 'url': 'https://mychannels.com/missholland/miss-holland?production_id=3416',
12 'md5': 'b8993daad4262dd68d89d651c0c52c45',
13 'info_dict': {
14 'id': 'wUUDZZep6vQD',
15 'ext': 'mp4',
16 'title': 'Miss Holland joins VOTE LEAVE',
17 'description': 'Miss Holland | #13 Not a potato',
18 'uploader': 'Miss Holland',
19 }
20 }
21
22 def _real_extract(self, url):
23 id_type, url_id = self._match_valid_url(url).groups()
24 webpage = self._download_webpage(url, url_id)
25 video_data = self._html_search_regex(r'<div([^>]+data-%s-id="%s"[^>]+)>' % (id_type, url_id), webpage, 'video data')
26
27 def extract_data_val(attr, fatal=False):
28 return self._html_search_regex(r'data-%s\s*=\s*"([^"]+)"' % attr, video_data, attr, fatal=fatal)
29 minoto_id = extract_data_val('minoto-id') or self._search_regex(r'/id/([a-zA-Z0-9]+)', extract_data_val('video-src', True), 'minoto id')
30
31 return {
32 '_type': 'url_transparent',
33 'url': 'minoto:%s' % minoto_id,
34 'id': url_id,
35 'title': extract_data_val('title', True),
36 'description': extract_data_val('description'),
37 'thumbnail': extract_data_val('image'),
38 'uploader': extract_data_val('channel'),
39 }