]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vidlii.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  17 class VidLiiIE(InfoExtractor
): 
  18     _VALID_URL 
= r
'https?://(?:www\.)?vidlii\.com/(?:watch|embed)\?.*?\bv=(?P<id>[0-9A-Za-z_-]{11})' 
  20         'url': 'https://www.vidlii.com/watch?v=tJluaH4BJ3v', 
  21         'md5': '9bf7d1e005dfa909b6efb0a1ff5175e2', 
  25             'title': 'Vidlii is against me', 
  26             'description': 'md5:fa3f119287a2bfb922623b52b1856145', 
  27             'thumbnail': 're:https://.*.jpg', 
  28             'uploader': 'APPle5auc31995', 
  29             'uploader_url': 'https://www.vidlii.com/user/APPle5auc31995', 
  30             'upload_date': '20171107', 
  34             'average_rating': float, 
  35             'categories': ['News & Politics'], 
  36             'tags': ['Vidlii', 'Jan', 'Videogames'], 
  39         'url': 'https://www.vidlii.com/embed?v=tJluaH4BJ3v&a=0', 
  40         'only_matching': True, 
  43     def _real_extract(self
, url
): 
  44         video_id 
= self
._match
_id
(url
) 
  46         webpage 
= self
._download
_webpage
( 
  47             'https://www.vidlii.com/watch?v=%s' % video_id
, video_id
) 
  49         video_url 
= self
._search
_regex
( 
  50             r
'src\s*:\s*(["\'])(?P
<url
>(?
:https?
://)?
(?
:(?
!\
1).)+)\
1', webpage, 
  51             'video url
', group='url
') 
  53         title = self._search_regex( 
  54             (r'<h1
>([^
<]+)</h1
>', r'<title
>([^
<]+) - VidLii
<'), webpage, 
  57         description = self._html_search_meta( 
  58             ('description
', 'twitter
:description
'), webpage, 
  59             default=None) or strip_or_none( 
  60             get_element_by_id('des_text
', webpage)) 
  62         thumbnail = self._html_search_meta( 
  63             'twitter
:image
', webpage, default=None) 
  65             thumbnail_path = self._search_regex( 
  66                 r'img\s
*:\s
*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 
  67                 'thumbnail', fatal=False, group='url') 
  69                 thumbnail = urljoin(url, thumbnail_path) 
  71         uploader = self._search_regex( 
  72             r'<div[^>]+class=["\']wt_person
[^
>]+>\s
*<a
[^
>]+\bhref
=["\']/user/[^>]+>([^<]+)', 
  73             webpage, 'uploader', fatal=False) 
  74         uploader_url = 'https://www.vidlii.com/user/%s' % uploader if uploader else None 
  76         upload_date = unified_strdate(self._html_search_meta( 
  77             'datePublished', webpage, default=None) or self._search_regex( 
  78             r'<date>([^<]+)', webpage, 'upload date', fatal=False)) 
  80         duration = int_or_none(self._html_search_meta( 
  81             'video:duration', webpage, 'duration', 
  82             default=None) or self._search_regex( 
  83             r'duration\s*:\s*(\d+)', webpage, 'duration', fatal=False)) 
  85         view_count = int_or_none(self._search_regex( 
  86             (r'<strong>(\d+)</strong> views', 
  87              r'Views\s*:\s*<strong>(\d+)</strong>'), 
  88             webpage, 'view count', fatal=False)) 
  90         comment_count = int_or_none(self._search_regex( 
  91             (r'<span[^>]+id=["\']cmt_num
[^
>]+>(\d
+)', 
  92              r'Comments\s
*:\s
*<strong
>(\d
+)'), 
  93             webpage, 'comment count
', fatal=False)) 
  95         average_rating = float_or_none(self._search_regex( 
  96             r'rating\s
*:\s
*([\d
.]+)', webpage, 'average rating
', fatal=False)) 
  98         category = self._html_search_regex( 
  99             r'<div
>Category\s
*:\s
*</div
>\s
*<div
>\s
*<a
[^
>]+>([^
<]+)', webpage, 
 100             'category
', fatal=False) 
 101         categories = [category] if category else None 
 105             for tag in re.findall( 
 106                 r'<a
[^
>]+\bhref
=["\']/results\?.*?q=[^>]*>([^<]+)', 
 107                 webpage) if strip_or_none(tag) 
 114             'description': description, 
 115             'thumbnail': thumbnail, 
 116             'uploader': uploader, 
 117             'uploader_url': uploader_url, 
 118             'upload_date': upload_date, 
 119             'duration': duration, 
 120             'view_count': view_count, 
 121             'comment_count': comment_count, 
 122             'average_rating': average_rating, 
 123             'categories': categories,