1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-26 04:02:11 +00:00

Merge branch 'master' of github.com:rg3/youtube-dl

This commit is contained in:
Philipp Hagemeister 2014-02-27 07:22:22 +01:00
commit f3783d4b77
3 changed files with 135 additions and 118 deletions

View file

@ -73,7 +73,6 @@ class MITIE(TechTVMITIE):
_TEST = { _TEST = {
'url': 'http://video.mit.edu/watch/the-government-is-profiling-you-13222/', 'url': 'http://video.mit.edu/watch/the-government-is-profiling-you-13222/',
'file': '.mp4',
'md5': '7db01d5ccc1895fc5010e9c9e13648da', 'md5': '7db01d5ccc1895fc5010e9c9e13648da',
'info_dict': { 'info_dict': {
'id': '21783', 'id': '21783',

View file

@ -1,148 +1,165 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
clean_html,
ExtractorError, ExtractorError,
clean_html,
unified_strdate,
int_or_none,
) )
class RTLnowIE(InfoExtractor): class RTLnowIE(InfoExtractor):
"""Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW""" """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
_VALID_URL = r'(?:http://)?(?P<url>(?P<domain>rtl-now\.rtl\.de|rtl2now\.rtl2\.de|(?:www\.)?voxnow\.de|(?:www\.)?rtlnitronow\.de|(?:www\.)?superrtlnow\.de|(?:www\.)?n-tvnow\.de)/+[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?(?:container_id|film_id)=(?P<video_id>[0-9]+)&player=1(?:&season=[0-9]+)?(?:&.*)?)' _VALID_URL = r'''(?x)
_TESTS = [{ (?:https?://)?
'url': 'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1', (?P<url>
'file': '90419.flv', (?P<domain>
'info_dict': { rtl-now\.rtl\.de|
'upload_date': '20070416', rtl2now\.rtl2\.de|
'title': 'Ahornallee - Folge 1 - Der Einzug', (?:www\.)?voxnow\.de|
'description': 'Folge 1 - Der Einzug', (?:www\.)?rtlnitronow\.de|
(?:www\.)?superrtlnow\.de|
(?:www\.)?n-tvnow\.de)
/+[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\?
(?:container_id|film_id)=(?P<video_id>[0-9]+)&
player=1(?:&season=[0-9]+)?(?:&.*)?
)'''
_TESTS = [
{
'url': 'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1',
'info_dict': {
'id': '90419',
'ext': 'flv',
'title': 'Ahornallee - Folge 1 - Der Einzug',
'description': 'md5:ce843b6b5901d9a7f7d04d1bbcdb12de',
'upload_date': '20070416',
'duration': 1685,
},
'params': {
'skip_download': True,
},
'skip': 'Only works from Germany',
}, },
'params': { {
'skip_download': True, 'url': 'http://rtl2now.rtl2.de/aerger-im-revier/episode-15-teil-1.php?film_id=69756&player=1&season=2&index=5',
'info_dict': {
'id': '69756',
'ext': 'flv',
'title': 'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit u.a.',
'description': 'md5:3fb247005ed21a935ffc82b7dfa70cf0',
'thumbnail': 'http://autoimg.static-fra.de/rtl2now/219850/1500x1500/image2.jpg',
'upload_date': '20120519',
'duration': 1245,
},
'params': {
'skip_download': True,
},
'skip': 'Only works from Germany',
}, },
'skip': 'Only works from Germany', {
}, 'url': 'http://www.voxnow.de/voxtours/suedafrika-reporter-ii.php?film_id=13883&player=1&season=17',
{ 'info_dict': {
'url': 'http://rtl2now.rtl2.de/aerger-im-revier/episode-15-teil-1.php?film_id=69756&player=1&season=2&index=5', 'id': '13883',
'file': '69756.flv', 'ext': 'flv',
'info_dict': { 'title': 'Voxtours - Südafrika-Reporter II',
'upload_date': '20120519', 'description': 'md5:de7f8d56be6fd4fed10f10f57786db00',
'title': 'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit...', 'upload_date': '20090627',
'description': 'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit u.a.', 'duration': 1800,
'thumbnail': 'http://autoimg.static-fra.de/rtl2now/219850/1500x1500/image2.jpg', },
'params': {
'skip_download': True,
},
}, },
'params': { {
'skip_download': True, 'url': 'http://superrtlnow.de/medicopter-117/angst.php?film_id=99205&player=1',
'info_dict': {
'id': '99205',
'ext': 'flv',
'title': 'Medicopter 117 - Angst!',
'description': 'md5:895b1df01639b5f61a04fc305a5cb94d',
'thumbnail': 'http://autoimg.static-fra.de/superrtlnow/287529/1500x1500/image2.jpg',
'upload_date': '20080928',
'duration': 2691,
},
'params': {
'skip_download': True,
},
}, },
'skip': 'Only works from Germany', {
}, 'url': 'http://www.n-tvnow.de/deluxe-alles-was-spass-macht/thema-ua-luxushotel-fuer-vierbeiner.php?container_id=153819&player=1&season=0',
{ 'info_dict': {
'url': 'http://www.voxnow.de/voxtours/suedafrika-reporter-ii.php?film_id=13883&player=1&season=17', 'id': '153819',
'file': '13883.flv', 'ext': 'flv',
'info_dict': { 'title': 'Deluxe - Alles was Spaß macht - Thema u.a.: Luxushotel für Vierbeiner',
'upload_date': '20090627', 'description': 'md5:c3705e1bb32e1a5b2bcd634fc065c631',
'title': 'Voxtours - Südafrika-Reporter II', 'thumbnail': 'http://autoimg.static-fra.de/ntvnow/383157/1500x1500/image2.jpg',
'description': 'Südafrika-Reporter II', 'upload_date': '20140221',
'duration': 2429,
},
'skip': 'Only works from Germany',
}, },
'params': { ]
'skip_download': True,
},
},
{
'url': 'http://superrtlnow.de/medicopter-117/angst.php?film_id=99205&player=1',
'file': '99205.flv',
'info_dict': {
'upload_date': '20080928',
'title': 'Medicopter 117 - Angst!',
'description': 'Angst!',
'thumbnail': 'http://autoimg.static-fra.de/superrtlnow/287529/1500x1500/image2.jpg'
},
'params': {
'skip_download': True,
},
},
{
'url': 'http://www.n-tvnow.de/top-gear/episode-1-2013-01-01-00-00-00.php?film_id=124903&player=1&season=10',
'file': '124903.flv',
'info_dict': {
'upload_date': '20130101',
'title': 'Top Gear vom 01.01.2013',
'description': 'Episode 1',
},
'params': {
'skip_download': True,
},
'skip': 'Only works from Germany',
}]
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_page_url = 'http://%s/' % mobj.group('domain')
webpage_url = 'http://' + mobj.group('url')
video_page_url = 'http://' + mobj.group('domain') + '/'
video_id = mobj.group('video_id') video_id = mobj.group('video_id')
webpage = self._download_webpage(webpage_url, video_id) webpage = self._download_webpage('http://' + mobj.group('url'), video_id)
note_m = re.search(r'''(?sx) mobj = re.search(r'(?s)<div style="margin-left: 20px; font-size: 13px;">(.*?)<div id="playerteaser">', webpage)
<div[ ]style="margin-left:[ ]20px;[ ]font-size:[ ]13px;">(.*?) if mobj:
<div[ ]id="playerteaser">''', webpage) raise ExtractorError(clean_html(mobj.group(1)), expected=True)
if note_m:
msg = clean_html(note_m.group(1)) title = self._og_search_title(webpage)
raise ExtractorError(msg) description = self._og_search_description(webpage)
thumbnail = self._og_search_thumbnail(webpage, default=None)
upload_date = unified_strdate(self._html_search_meta('uploadDate', webpage, 'upload date'))
mobj = re.search(r'<meta itemprop="duration" content="PT(?P<seconds>\d+)S" />', webpage)
duration = int(mobj.group('seconds')) if mobj else None
video_title = self._html_search_regex(
r'<title>(?P<title>[^<]+?)( \| [^<]*)?</title>',
webpage, 'title')
playerdata_url = self._html_search_regex( playerdata_url = self._html_search_regex(
r'\'playerdata\': \'(?P<playerdata_url>[^\']+)\'', r"'playerdata': '(?P<playerdata_url>[^']+)'", webpage, 'playerdata_url')
webpage, 'playerdata_url')
playerdata = self._download_webpage(playerdata_url, video_id) playerdata = self._download_xml(playerdata_url, video_id, 'Downloading player data XML')
mobj = re.search(r'<title><!\[CDATA\[(?P<description>.+?)(?:\s+- (?:Sendung )?vom (?P<upload_date_d>[0-9]{2})\.(?P<upload_date_m>[0-9]{2})\.(?:(?P<upload_date_Y>[0-9]{4})|(?P<upload_date_y>[0-9]{2})) [0-9]{2}:[0-9]{2} Uhr)?\]\]></title>', playerdata)
if mobj: videoinfo = playerdata.find('./playlist/videoinfo')
video_description = mobj.group('description')
if mobj.group('upload_date_Y'): formats = []
video_upload_date = mobj.group('upload_date_Y') for filename in videoinfo.findall('filename'):
elif mobj.group('upload_date_y'): mobj = re.search(r'(?P<url>rtmpe://(?:[^/]+/){2})(?P<play_path>.+)', filename.text)
video_upload_date = '20' + mobj.group('upload_date_y') if mobj:
fmt = {
'url': mobj.group('url'),
'play_path': 'mp4:' + mobj.group('play_path'),
'page_url': video_page_url,
'player_url': video_page_url + 'includes/vodplayer.swf',
}
else: else:
video_upload_date = None fmt = {
if video_upload_date: 'url': filename.text,
video_upload_date += mobj.group('upload_date_m') + mobj.group('upload_date_d') }
else: fmt.update({
video_description = None 'width': int_or_none(filename.get('width')),
video_upload_date = None 'height': int_or_none(filename.get('height')),
self._downloader.report_warning('Unable to extract description and upload date') 'vbr': int_or_none(filename.get('bitrate')),
'ext': 'flv',
# Thumbnail: not every video has an thumbnail })
mobj = re.search(r'<meta property="og:image" content="(?P<thumbnail>[^"]+)">', webpage) formats.append(fmt)
if mobj:
video_thumbnail = mobj.group('thumbnail')
else:
video_thumbnail = None
mobj = re.search(r'<filename [^>]+><!\[CDATA\[(?P<url>rtmpe://(?:[^/]+/){2})(?P<play_path>[^\]]+)\]\]></filename>', playerdata)
if mobj is None:
raise ExtractorError('Unable to extract media URL')
video_url = mobj.group('url')
video_play_path = 'mp4:' + mobj.group('play_path')
video_player_url = video_page_url + 'includes/vodplayer.swf'
return { return {
'id': video_id, 'id': video_id,
'url': video_url, 'title': title,
'play_path': video_play_path, 'description': description,
'page_url': video_page_url, 'thumbnail': thumbnail,
'player_url': video_player_url, 'upload_date': upload_date,
'ext': 'flv', 'duration': duration,
'title': video_title, 'formats': formats,
'description': video_description, }
'upload_date': video_upload_date,
'thumbnail': video_thumbnail,
}

View file

@ -103,6 +103,7 @@ class XHamsterIE(InfoExtractor):
}] }]
if not hd: if not hd:
mrss_url = self._search_regex(r'<link rel="canonical" href="([^"]+)', webpage, 'mrss_url')
webpage = self._download_webpage(mrss_url + '?hd', video_id, note='Downloading HD webpage') webpage = self._download_webpage(mrss_url + '?hd', video_id, note='Downloading HD webpage')
if is_hd(webpage): if is_hd(webpage):
video_url = extract_video_url(webpage) video_url = extract_video_url(webpage)