1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-18 06:54:35 +01:00
youtube-dl/youtube_dl/extractor/videofyme.py

51 lines
1.7 KiB
Python
Raw Normal View History

2014-11-26 13:01:39 +01:00
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
find_xpath_attr,
2014-11-26 13:01:39 +01:00
int_or_none,
)
2014-11-23 20:41:03 +01:00
class VideofyMeIE(InfoExtractor):
2014-11-26 13:01:39 +01:00
_VALID_URL = r'https?://(?:www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)'
IE_NAME = 'videofy.me'
_TEST = {
2014-11-26 13:01:39 +01:00
'url': 'http://www.videofy.me/thisisvideofyme/1100701',
'md5': 'c77d700bdc16ae2e9f3c26019bd96143',
'info_dict': {
'id': '1100701',
'ext': 'mp4',
'title': 'This is VideofyMe',
'description': None,
'uploader': 'VideofyMe',
'uploader_id': 'thisisvideofyme',
'view_count': int,
},
2014-11-23 20:41:03 +01:00
}
def _real_extract(self, url):
2014-11-26 13:01:39 +01:00
video_id = self._match_id(url)
config = self._download_xml('http://sunshine.videofy.me/?videoId=%s' % video_id,
2014-11-23 21:39:15 +01:00
video_id)
video = config.find('video')
sources = video.find('sources')
2014-11-23 20:41:03 +01:00
url_node = next(node for node in [find_xpath_attr(sources, 'source', 'id', 'HQ %s' % key)
2014-11-23 21:39:15 +01:00
for key in ['on', 'av', 'off']] if node is not None)
video_url = url_node.find('url').text
2014-11-26 13:01:39 +01:00
view_count = int_or_none(self._search_regex(
r'([0-9]+)', video.find('views').text, 'view count', fatal=False))
2014-11-26 13:01:39 +01:00
return {
'id': video_id,
'title': video.find('title').text,
'url': video_url,
'thumbnail': video.find('thumb').text,
'description': video.find('description').text,
'uploader': config.find('blog/name').text,
'uploader_id': video.find('identifier').text,
'view_count': view_count,
}