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