]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/vidbit.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_urlparse
11 class VidbitIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?vidbit\.co/(?:watch|embed)\?.*?\bv=(?P<id>[\da-zA-Z]+)'
14 'url': 'http://www.vidbit.co/watch?v=jkL2yDOEq2',
15 'md5': '1a34b7f14defe3b8fafca9796892924d',
19 'title': 'Intro to VidBit',
20 'description': 'md5:5e0d6142eec00b766cbf114bfd3d16b7',
21 'thumbnail': r
're:https?://.*\.jpg$',
22 'upload_date': '20160618',
27 'url': 'http://www.vidbit.co/embed?v=jkL2yDOEq2&auto=0&water=0',
28 'only_matching': True,
31 def _real_extract(self
, url
):
32 video_id
= self
._match
_id
(url
)
34 webpage
= self
._download
_webpage
(
35 compat_urlparse
.urljoin(url
, '/watch?v=%s' % video_id
), video_id
)
37 video_url
, title
= [None] * 2
39 config
= self
._parse
_json
(self
._search
_regex
(
40 r
'(?s)\.setup\(({.+?})\);', webpage
, 'setup', default
='{}'),
41 video_id
, transform_source
=js_to_json
)
43 if config
.get('file'):
44 video_url
= compat_urlparse
.urljoin(url
, config
['file'])
45 title
= config
.get('title')
48 video_url
= compat_urlparse
.urljoin(url
, self
._search
_regex
(
49 r
'file\s*:\s*(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1',
50 webpage, 'video URL
', group='url
'))
54 self._html_search_regex(
55 (r'<h1
>(.+?
)</h1
>', r'<title
>(.+?
)</title
>'),
56 webpage, 'title
', default=None) or self._og_search_title(webpage),
59 description = self._html_search_meta(
60 ('description
', 'og
:description
', 'twitter
:description
'),
61 webpage, 'description
')
63 upload_date = unified_strdate(self._html_search_meta(
64 'datePublished
', webpage, 'upload date
'))
66 view_count = int_or_none(self._search_regex(
67 r'<strong
>(\d
+)</strong
> views
',
68 webpage, 'view count
', fatal=False))
69 comment_count = int_or_none(self._search_regex(
70 r'id=["\']cmt_num["\'][^
>]*>\
((\d
+)\
)',
71 webpage, 'comment count
', fatal=False))
77 'description
': description,
78 'thumbnail
': self._og_search_thumbnail(webpage),
79 'upload_date
': upload_date,
80 'view_count
': view_count,
81 'comment_count
': comment_count,