aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-01-07 08:07:46 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-01-07 08:07:46 +0100
commitc93c2ab1c3bc84f5525e2771c48bcd6d384d9dae (patch)
tree7bb30f77994873c30da3923db847074f251babef
parent7b09a4d847fae87b1b70cd44f2d1cbe7ada35db8 (diff)
[mpora] Add support (Fixes #2096)
-rw-r--r--youtube_dl/extractor/__init__.py1
-rw-r--r--youtube_dl/extractor/generic.py5
-rw-r--r--youtube_dl/extractor/mpora.py66
3 files changed, 72 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index f1167989e..009d3b60f 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -112,6 +112,7 @@ from .metacafe import MetacafeIE
from .metacritic import MetacriticIE
from .mit import TechTVMITIE, MITIE
from .mixcloud import MixcloudIE
+from .mpora import MporaIE
from .mofosex import MofosexIE
from .mtv import MTVIE
from .muzu import MuzuTVIE
diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py
index 7d0e117de..c1f393e39 100644
--- a/youtube_dl/extractor/generic.py
+++ b/youtube_dl/extractor/generic.py
@@ -307,6 +307,11 @@ class GenericIE(InfoExtractor):
if mobj is not None:
return self.url_result(mobj.group(1), 'Aparat')
+ # Look for MPORA videos
+ mobj = re.search(r'<iframe .*?src="(http://mpora.com/videos/[^"]+)"', webpage)
+ if mobj is not None:
+ return self.url_result(mobj.group(1), 'Mpora')
+
# Start with something easy: JW Player in SWFObject
mobj = re.search(r'flashvars: [\'"](?:.*&)?file=(http[^\'"&]*)', webpage)
if mobj is None:
diff --git a/youtube_dl/extractor/mpora.py b/youtube_dl/extractor/mpora.py
new file mode 100644
index 000000000..b4cdd2a1e
--- /dev/null
+++ b/youtube_dl/extractor/mpora.py
@@ -0,0 +1,66 @@
+from __future__ import unicode_literals
+
+import json
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+)
+
+
+class MporaIE(InfoExtractor):
+ _VALID_URL = r'^https?://(www\.)?mpora\.(?:com|de)/videos/(?P<id>[^?#/]+)'
+ _IE_NAME = 'MPORA'
+
+ _TEST = {
+ 'url': 'http://mpora.de/videos/AAdo8okx4wiz/embed?locale=de',
+ 'file': 'AAdo8okx4wiz.mp4',
+ 'md5': 'a7a228473eedd3be741397cf452932eb',
+ 'info_dict': {
+ 'title': 'Katy Curd - Winter in the Forest',
+ 'duration': 416,
+ 'uploader': 'petenewman',
+ },
+ }
+
+ def _real_extract(self, url):
+ m = re.match(self._VALID_URL, url)
+ video_id = m.group('id')
+
+ webpage = self._download_webpage(url, video_id)
+ data_json = self._search_regex(
+ r"new FM\.Player\('[^']+',\s*(\{.*?)\);\n", webpage, 'json')
+
+ data = json.loads(data_json)
+
+ uploader = data['info_overlay']['name']
+ duration = data['video']['duration'] // 1000
+ thumbnail = data['video']['encodings']['sd']['poster']
+ title = data['info_overlay']['title']
+
+ formats = []
+ for encoding_id, edata in data['video']['encodings'].items():
+ for src in edata['sources']:
+ width_str = self._search_regex(
+ r'_([0-9]+)\.[a-zA-Z0-9]+$', src['src'],
+ False, default=None)
+ vcodec = src['type'].partition('/')[2]
+
+ formats.append({
+ 'format_id': encoding_id + '-' + vcodec,
+ 'url': src['src'],
+ 'vcodec': vcodec,
+ 'width': int_or_none(width_str),
+ })
+
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'formats': formats,
+ 'uploader': uploader,
+ 'duration': duration,
+ 'thumbnail': thumbnail,
+ }