aboutsummaryrefslogtreecommitdiffhomepage
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <[email protected]>2014-04-21 07:12:02 +0200
committerPhilipp Hagemeister <[email protected]>2014-04-21 07:12:02 +0200
commit478c2c619364f5fb0c1ee9e9489048ab4ae26521 (patch)
tree65cc0f7247d9d78bffc7e95ae5d19c11eb0849ac /youtube_dl
parentd2d6481afb064b6d809e3b131bd7365e2aeee1e1 (diff)
downloadyoutube-dl-478c2c619364f5fb0c1ee9e9489048ab4ae26521.tar.gz
youtube-dl-478c2c619364f5fb0c1ee9e9489048ab4ae26521.zip
[clubic] Add extractor (Fixes #2773)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/__init__.py1
-rw-r--r--youtube_dl/extractor/clubic.py58
-rw-r--r--youtube_dl/utils.py11
3 files changed, 70 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index e0ef1cd3e..8235d42b6 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -40,6 +40,7 @@ from .cinemassacre import CinemassacreIE
from .clipfish import ClipfishIE
from .cliphunter import CliphunterIE
from .clipsyndicate import ClipsyndicateIE
+from .clubic import ClubicIE
from .cmt import CMTIE
from .cnet import CNETIE
from .cnn import (
diff --git a/youtube_dl/extractor/clubic.py b/youtube_dl/extractor/clubic.py
new file mode 100644
index 000000000..14f215c5c
--- /dev/null
+++ b/youtube_dl/extractor/clubic.py
@@ -0,0 +1,58 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+import json
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ clean_html,
+ qualities,
+)
+
+
+class ClubicIE(InfoExtractor):
+ _VALID_URL = r'http://(?:www\.)?clubic\.com/video/[^/]+/video.*-(?P<id>[0-9]+)\.html'
+
+ _TEST = {
+ 'url': 'http://www.clubic.com/video/clubic-week/video-clubic-week-2-0-le-fbi-se-lance-dans-la-photo-d-identite-448474.html',
+ 'md5': '1592b694ba586036efac1776b0b43cd3',
+ 'info_dict': {
+ 'id': '448474',
+ 'ext': 'mp4',
+ 'title': 'Clubic Week 2.0 : le FBI se lance dans la photo d\u0092identité',
+ 'description': 're:Gueule de bois chez Nokia. Le constructeur a indiqué cette.*',
+ 'thumbnail': 're:^http://img\.clubic\.com/.*\.jpg$',
+ }
+ }
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ video_id = mobj.group('id')
+
+ player_url = 'http://player.m6web.fr/v1/player/clubic/%s.html' % video_id
+ player_page = self._download_webpage(player_url, video_id)
+
+ config_json = self._search_regex(
+ r'(?m)M6\.Player\.config\s*=\s*(\{.+?\});$', player_page,
+ 'configuration')
+ config = json.loads(config_json)
+
+ video_info = config['videoInfo']
+ sources = config['sources']
+ quality_order = qualities(['sd', 'hq'])
+
+ formats = [{
+ 'format_id': src['streamQuality'],
+ 'url': src['src'],
+ 'quality': quality_order(src['streamQuality']),
+ } for src in sources]
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'title': video_info['title'],
+ 'formats': formats,
+ 'description': clean_html(video_info.get('description')),
+ 'thumbnail': config.get('poster'),
+ }
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 116eb3610..d4df78071 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1406,3 +1406,14 @@ US_RATINGS = {
def strip_jsonp(code):
return re.sub(r'(?s)^[a-zA-Z_]+\s*\(\s*(.*)\);\s*?\s*$', r'\1', code)
+
+
+def qualities(quality_ids):
+ """ Get a numeric quality value out of a list of possible values """
+ def q(qid):
+ try:
+ return quality_ids.index(qid)
+ except ValueError:
+ return -1
+ return q
+