]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vidbit.py
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
4 from ..compat
import compat_urlparse
13 class VidbitIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?vidbit\.co/(?:watch|embed)\?.*?\bv=(?P<id>[\da-zA-Z]+)'
16 'url': 'http://www.vidbit.co/watch?v=jkL2yDOEq2',
17 'md5': '1a34b7f14defe3b8fafca9796892924d',
21 'title': 'Intro to VidBit',
22 'description': 'md5:5e0d6142eec00b766cbf114bfd3d16b7',
23 'thumbnail': r
're:https?://.*\.jpg$',
24 'upload_date': '20160618',
29 'url': 'http://www.vidbit.co/embed?v=jkL2yDOEq2&auto=0&water=0',
30 'only_matching': True,
33 def _real_extract(self
, url
):
34 video_id
= self
._match
_id
(url
)
36 webpage
= self
._download
_webpage
(
37 compat_urlparse
.urljoin(url
, '/watch?v=%s' % video_id
), video_id
)
39 video_url
, title
= [None] * 2
41 config
= self
._parse
_json
(self
._search
_regex
(
42 r
'(?s)\.setup\(({.+?})\);', webpage
, 'setup', default
='{}'),
43 video_id
, transform_source
=js_to_json
)
45 if config
.get('file'):
46 video_url
= compat_urlparse
.urljoin(url
, config
['file'])
47 title
= config
.get('title')
50 video_url
= compat_urlparse
.urljoin(url
, self
._search
_regex
(
51 r
'file\s*:\s*(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1',
52 webpage, 'video URL
', group='url
'))
56 self._html_search_regex(
57 (r'<h1
>(.+?
)</h1
>', r'<title
>(.+?
)</title
>'),
58 webpage, 'title
', default=None) or self._og_search_title(webpage),
61 description = self._html_search_meta(
62 ('description
', 'og
:description
', 'twitter
:description
'),
63 webpage, 'description
')
65 upload_date = unified_strdate(self._html_search_meta(
66 'datePublished
', webpage, 'upload date
'))
68 view_count = int_or_none(self._search_regex(
69 r'<strong
>(\d
+)</strong
> views
',
70 webpage, 'view count
', fatal=False))
71 comment_count = int_or_none(self._search_regex(
72 r'id=["\']cmt_num["\'][^
>]*>\
((\d
+)\
)',
73 webpage, 'comment count
', fatal=False))
79 'description
': description,
80 'thumbnail
': self._og_search_thumbnail(webpage),
81 'upload_date
': upload_date,
82 'view_count
': view_count,
83 'comment_count
': comment_count,