]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/videofyme.py
2dd51d8660452f74b8346addeda120b33d3cdb0b
[yt-dlp.git] / 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
10 class VideofyMeIE(InfoExtractor):
11 _VALID_URL = r'https?://(www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)'
12 IE_NAME = u'videofy.me'
13
14 _TEST = {
15 u'url': u'http://www.videofy.me/thisisvideofyme/1100701',
16 u'file': u'1100701.mp4',
17 u'md5': u'c77d700bdc16ae2e9f3c26019bd96143',
18 u'info_dict': {
19 u'title': u'This is VideofyMe',
20 u'description': None,
21 u'uploader': u'VideofyMe',
22 u'uploader_id': u'thisisvideofyme',
23 },
24
25 }
26
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('id')
30 config = self._download_xml('http://sunshine.videofy.me/?videoId=%s' % video_id,
31 video_id)
32 video = config.find('video')
33 sources = video.find('sources')
34 url_node = next(node for node in [find_xpath_attr(sources, 'source', 'id', 'HQ %s' % key)
35 for key in ['on', 'av', 'off']] if node is not None)
36 video_url = url_node.find('url').text
37
38 return {'id': video_id,
39 'title': video.find('title').text,
40 'url': video_url,
41 'ext': determine_ext(video_url),
42 'thumbnail': video.find('thumb').text,
43 'description': video.find('description').text,
44 'uploader': config.find('blog/name').text,
45 'uploader_id': video.find('identifier').text,
46 'view_count': re.search(r'\d+', video.find('views').text).group(),
47 }