1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-31 22:55:18 +00:00

[ruutu] Detect embeds (#3294)

Authored by: tpikonen
This commit is contained in:
Teemu Ikonen
2022-04-05 15:15:47 +03:00
committed by GitHub
parent f4d706a931
commit 0a8a7e68fa
2 changed files with 40 additions and 1 deletions

View File

@@ -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)