X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fccc.py;h=6924eac704cd5cf02d266bd60125dad9cf13e765;hb=40101dc311909523852a88ba69df76be9b6bc920;hp=809725f1251ddffddca399dd3c36f6d873779ba1;hpb=46d9760f5ebd86ee5b34fd669f44b124f34fffc1;p=youtube-dl diff --git a/youtube_dl/extractor/ccc.py b/youtube_dl/extractor/ccc.py index 809725f12..6924eac70 100644 --- a/youtube_dl/extractor/ccc.py +++ b/youtube_dl/extractor/ccc.py @@ -1,46 +1,99 @@ -# encoding: utf-8 +from __future__ import unicode_literals + import re -import json from .common import InfoExtractor from ..utils import ( + int_or_none, + qualities, unified_strdate, ) -class ComCarCoffIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?comediansincarsgettingcoffee\.com/(?P[a-z0-9\-]+)/?' - _TESTS = [ - { - 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/', - 'info_dict': { - 'id': 'miranda-sings-happy-thanksgiving-miranda', - 'upload_date': '20141127', - 'title': 'Happy Thanksgiving Miranda', - 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.', - 'thumbnail': 'http://ccc.crackle.com/images/s5e4_thumb.jpg', - }, + +class CCCIE(InfoExtractor): + IE_NAME = 'media.ccc.de' + _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/[^?#]+/[^?#/]*?_(?P[0-9]{8,})._[^?#/]*\.html' + + _TEST = { + 'url': 'http://media.ccc.de/browse/congress/2013/30C3_-_5443_-_en_-_saal_g_-_201312281830_-_introduction_to_processor_design_-_byterazor.html#video', + 'md5': '3a1eda8f3a29515d27f5adb967d7e740', + 'info_dict': { + 'id': '20131228183', + 'ext': 'mp4', + 'title': 'Introduction to Processor Design', + 'description': 'md5:5ddbf8c734800267f2cee4eab187bc1b', + 'thumbnail': 're:^https?://.*\.jpg$', + 'view_count': int, + 'upload_date': '20131229', } - ] + } def _real_extract(self, url): - display_id = self._match_id(url) - webpage = self._download_webpage(url, display_id) + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + if self._downloader.params.get('prefer_free_formats'): + preference = qualities(['mp3', 'opus', 'mp4-lq', 'webm-lq', 'h264-sd', 'mp4-sd', 'webm-sd', 'mp4', 'webm', 'mp4-hd', 'h264-hd', 'webm-hd']) + else: + preference = qualities(['opus', 'mp3', 'webm-lq', 'mp4-lq', 'webm-sd', 'h264-sd', 'mp4-sd', 'webm', 'mp4', 'webm-hd', 'mp4-hd', 'h264-hd']) + + title = self._html_search_regex( + r'(?s)

(.*?)

', webpage, 'title') + description = self._html_search_regex( + r"(?s)

(.*?)

", + webpage, 'description', fatal=False) + upload_date = unified_strdate(self._html_search_regex( + r"(?s)(.*?)", + webpage, 'upload date', fatal=False)) + view_count = int_or_none(self._html_search_regex( + r"(?s)(.*?)", + webpage, 'view count', fatal=False)) + + matches = re.finditer(r'''(?xs) + <(?:span|div)\s+class='label\s+filetype'>(?P.*?)\s* + [^']+)'>\s* + (?: + .*? + [^']+\.torrent)' + )?''', webpage) + formats = [] + for m in matches: + format = m.group('format') + format_id = self._search_regex( + r'.*/([a-z0-9_-]+)/[^/]*$', + m.group('http_url'), 'format id', default=None) + vcodec = 'h264' if 'h264' in format_id else ( + 'none' if format_id in ('mp3', 'opus') else None + ) + formats.append({ + 'format_id': format_id, + 'format': format, + 'url': m.group('http_url'), + 'vcodec': vcodec, + 'preference': preference(format_id), + }) - full_data = json.loads(self._search_regex( - r'', - webpage, 'json')) + if m.group('torrent_url'): + formats.append({ + 'format_id': 'torrent-%s' % (format if format_id is None else format_id), + 'format': '%s (torrent)' % format, + 'proto': 'torrent', + 'format_note': '(unsupported; will just download the .torrent file)', + 'vcodec': vcodec, + 'preference': -100 + preference(format_id), + 'url': m.group('torrent_url'), + }) + self._sort_formats(formats) - video_id = full_data['activeVideo']['video'] - video_data = full_data['videos'][video_id] + thumbnail = self._html_search_regex( + r"