1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-30 11:23:02 +08:00
youtube-dl/youtube_dl/extractor/clipfish.py

54 lines
1.6 KiB
Python
Raw Normal View History

2014-03-25 05:30:32 +08:00
from __future__ import unicode_literals
2013-11-24 14:51:44 +08:00
import re
import time
import xml.etree.ElementTree
2013-11-24 14:51:44 +08:00
from .common import InfoExtractor
2014-03-25 05:30:32 +08:00
from ..utils import (
ExtractorError,
parse_duration,
)
2013-11-24 14:51:44 +08:00
class ClipfishIE(InfoExtractor):
2014-03-25 05:30:32 +08:00
IE_NAME = 'clipfish'
2013-11-24 14:51:44 +08:00
_VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/'
_TEST = {
2014-03-25 05:30:32 +08:00
'url': 'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/',
'md5': '2521cd644e862936cf2e698206e47385',
'info_dict': {
'id': '3966754',
'ext': 'mp4',
'title': 'FIFA 14 - E3 2013 Trailer',
'duration': 82,
2013-12-01 08:16:20 +08:00
},
2014-11-26 20:06:02 +08:00
'skip': 'Blocked in the US'
2013-11-24 14:51:44 +08:00
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group(1)
info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' %
(video_id, int(time.time())))
doc = self._download_xml(
2014-11-26 20:06:02 +08:00
info_url, video_id, note='Downloading info page')
2013-11-24 14:51:44 +08:00
title = doc.find('title').text
video_url = doc.find('filename').text
if video_url is None:
xml_bytes = xml.etree.ElementTree.tostring(doc)
2014-03-25 05:30:32 +08:00
raise ExtractorError('Cannot find video URL in document %r' %
xml_bytes)
2013-11-24 14:51:44 +08:00
thumbnail = doc.find('imageurl').text
2014-03-25 05:30:32 +08:00
duration = parse_duration(doc.find('duration').text)
2013-11-24 14:51:44 +08:00
return {
'id': video_id,
'title': title,
'url': video_url,
'thumbnail': thumbnail,
'duration': duration,
}