]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/manyvids.py
New upstream version 2018.03.14
[youtubedl] / youtube_dl / extractor / manyvids.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import int_or_none
6
7
8 class ManyVidsIE(InfoExtractor):
9 _VALID_URL = r'(?i)https?://(?:www\.)?manyvids\.com/video/(?P<id>\d+)'
10 _TEST = {
11 'url': 'https://www.manyvids.com/Video/133957/everthing-about-me/',
12 'md5': '03f11bb21c52dd12a05be21a5c7dcc97',
13 'info_dict': {
14 'id': '133957',
15 'ext': 'mp4',
16 'title': 'everthing about me (Preview)',
17 'view_count': int,
18 'like_count': int,
19 },
20 }
21
22 def _real_extract(self, url):
23 video_id = self._match_id(url)
24
25 webpage = self._download_webpage(url, video_id)
26
27 video_url = self._search_regex(
28 r'data-(?:video-filepath|meta-video)\s*=s*(["\'])(?P<url>(?:(?!\1).)+)\1',
29 webpage, 'video URL', group='url')
30
31 title = '%s (Preview)' % self._html_search_regex(
32 r'<h2[^>]+class="m-a-0"[^>]*>([^<]+)', webpage, 'title')
33
34 like_count = int_or_none(self._search_regex(
35 r'data-likes=["\'](\d+)', webpage, 'like count', default=None))
36 view_count = int_or_none(self._html_search_regex(
37 r'(?s)<span[^>]+class="views-wrapper"[^>]*>(.+?)</span', webpage,
38 'view count', default=None))
39
40 return {
41 'id': video_id,
42 'title': title,
43 'view_count': view_count,
44 'like_count': like_count,
45 'formats': [{
46 'url': video_url,
47 }],
48 }