aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/extractor/ruutu.py
diff options
context:
space:
mode:
Diffstat (limited to 'hypervideo_dl/extractor/ruutu.py')
-rw-r--r--hypervideo_dl/extractor/ruutu.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/hypervideo_dl/extractor/ruutu.py b/hypervideo_dl/extractor/ruutu.py
index d9cf39d..5a30e33 100644
--- a/hypervideo_dl/extractor/ruutu.py
+++ b/hypervideo_dl/extractor/ruutu.py
@@ -1,6 +1,9 @@
# coding: utf-8
from __future__ import unicode_literals
+import json
+import re
+
from .common import InfoExtractor
from ..compat import compat_urllib_parse_urlparse
from ..utils import (
@@ -8,6 +11,8 @@ from ..utils import (
ExtractorError,
find_xpath_attr,
int_or_none,
+ traverse_obj,
+ try_call,
unified_strdate,
url_or_none,
xpath_attr,
@@ -123,6 +128,16 @@ class RuutuIE(InfoExtractor):
]
_API_BASE = 'https://gatling.nelonenmedia.fi'
+ @classmethod
+ def _extract_url(cls, webpage):
+ settings = try_call(
+ lambda: json.loads(re.search(
+ r'jQuery\.extend\(Drupal\.settings, ({.+?})\);', webpage).group(1), strict=False))
+ video_id = traverse_obj(settings, (
+ 'mediaCrossbowSettings', 'file', 'field_crossbow_video_id', 'und', 0, 'value'))
+ if video_id:
+ return f'http://www.ruutu.fi/video/{video_id}'
+
def _real_extract(self, url):
video_id = self._match_id(url)