]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/videofyme.py
debian/gbp.conf: Change to new git-buildpackage syntax.
[youtubedl] / youtube_dl / extractor / videofyme.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 find_xpath_attr,
6 int_or_none,
7 )
8
9
10 class VideofyMeIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)'
12 IE_NAME = 'videofy.me'
13
14 _TEST = {
15 'url': 'http://www.videofy.me/thisisvideofyme/1100701',
16 'md5': 'c77d700bdc16ae2e9f3c26019bd96143',
17 'info_dict': {
18 'id': '1100701',
19 'ext': 'mp4',
20 'title': 'This is VideofyMe',
21 'description': None,
22 'uploader': 'VideofyMe',
23 'uploader_id': 'thisisvideofyme',
24 'view_count': int,
25 },
26
27 }
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 config = self._download_xml('http://sunshine.videofy.me/?videoId=%s' % video_id,
32 video_id)
33 video = config.find('video')
34 sources = video.find('sources')
35 url_node = next(node for node in [find_xpath_attr(sources, 'source', 'id', 'HQ %s' % key)
36 for key in ['on', 'av', 'off']] if node is not None)
37 video_url = url_node.find('url').text
38 view_count = int_or_none(self._search_regex(
39 r'([0-9]+)', video.find('views').text, 'view count', fatal=False))
40
41 return {
42 'id': video_id,
43 'title': video.find('title').text,
44 'url': video_url,
45 'thumbnail': video.find('thumb').text,
46 'description': video.find('description').text,
47 'uploader': config.find('blog/name').text,
48 'uploader_id': video.find('identifier').text,
49 'view_count': view_count,
50 }