0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-04 23:35:04 +00:00
yt-dlp/youtube_dl/extractor/clipfish.py

54 lines
1.6 KiB
Python
Raw Normal View History

2014-03-24 21:30:32 +00:00
from __future__ import unicode_literals
2013-11-24 06:51:44 +00:00
import re
import time
import xml.etree.ElementTree
2013-11-24 06:51:44 +00:00
from .common import InfoExtractor
2014-03-24 21:30:32 +00:00
from ..utils import (
ExtractorError,
parse_duration,
)
2013-11-24 06:51:44 +00:00
class ClipfishIE(InfoExtractor):
2014-03-24 21:30:32 +00:00
IE_NAME = 'clipfish'
2013-11-24 06:51:44 +00:00
_VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/'
_TEST = {
2014-03-24 21:30:32 +00: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 00:16:20 +00:00
},
2014-11-26 12:06:02 +00:00
'skip': 'Blocked in the US'
2013-11-24 06:51:44 +00: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 12:06:02 +00:00
info_url, video_id, note='Downloading info page')
2013-11-24 06:51:44 +00: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-24 21:30:32 +00:00
raise ExtractorError('Cannot find video URL in document %r' %
xml_bytes)
2013-11-24 06:51:44 +00:00
thumbnail = doc.find('imageurl').text
2014-03-24 21:30:32 +00:00
duration = parse_duration(doc.find('duration').text)
2013-11-24 06:51:44 +00:00
return {
'id': video_id,
'title': title,
'url': video_url,
'thumbnail': thumbnail,
'duration': duration,
}