Repository: yt-dlp/yt-dlp

Issue:
YLE (Finland) as new indexer or support to pass through to downloader
### Checklist

- [X] I'm reporting a new site support request
- [X] I've verified that I'm running yt-dlp version **2022.01.21**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that none of provided URLs [violate any copyrights](https://github.com/ytdl-org/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and am willing to share it if required

### Region

Finland

### Example URLs

https://areena.yle.fi/1-4371942


### Description

It would be good if support could be provided **OR** support given to the existing yle-dl application (https://aajanki.github.io/yle-dl/index-en.html) as a passthrough.

First I confirm it does not work with yt-dlp: 
```
% yt-dlp --downloader yle-dl https://areena.yle.fi/1-4371942   
[generic] 1-4371942: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] 1-4371942: Downloading webpage
[generic] 1-4371942: Extracting information
ERROR: Unsupported URL: https://areena.yle.fi/1-4371942

```
Then I confirm the pass through is not supported (to be fair, the documentation does not claim it is supported).

```
yt-dlp --downloader yle-dl https://areena.yle.fi/1-4371942   
[generic] 1-4371942: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] 1-4371942: Downloading webpage
[generic] 1-4371942: Extracting information
ERROR: Unsupported URL: https://areena.yle.fi/1-4371942
```
Then I confirm the yle-dl can download the file

```
% yle-dl https://areena.yle.fi/1-4371942
yle-dl 20210917: Download media files from Yle Areena and Elävä Arkisto
Copyright (C) 2009-2021 Antti Ajanki <antti.ajanki@iki.fi>, license: GPLv3

Output file: Modernit miehet: Pouchit: S01E02-2019-01-06T00:01.mkv
[webvtt @ 0x7f91e6008200] Dropping 94 duplicated subtitle events
frame=35882 fps=1815 q=-1.0 Lsize=  703971kB time=00:23:55.31 bitrate=4017.9kbits/s speed=72.6x    
Stream saved to Modernit miehet: Pouchit: S01E02-2019-01-06T00:01.mkv

```
Then the metadata (I don't understand...)
```
yle-dl https://areena.yle.fi/1-4371942 --showmetadata
[
  {
    "program_id": "1-4371942",
    "webpage": "https://areena.yle.fi/1-4371942",
    "title": "Modernit miehet: Pouchit: S01E02-2019-01-06T00:01",
    "description": "Kausi 1, 2/12. Pete saa tarpeekseen Pihlan ja Tuomaksen suhteesta. Jarkko pelk\u00e4\u00e4 paljastuvansa \u00f6isin ajavaksi taksikuskiksi. Husqvarna TS 242 ruohonleikkuri lunastaa Tuomaksen miehuuden takaisin. (U)",
    "filename": "Modernit miehet: Pouchit: S01E02-2019-01-06T00:01.mkv",
    "flavors": [
      {
        "media_type": "video",
        "height": 176,
        "width": 320,
        "bitrate": 130,
        "backends": [
          "ffmpeg"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_h1mzm3k2/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      },
      {
        "media_type": "video",
        "height": 360,
        "width": 640,
        "bitrate": 466,
        "backends": [
          "ffmpeg",
          "wget"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_v6f2yuyi/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      },
      {
        "media_type": "video",
        "height": 360,
        "width": 640,
        "bitrate": 665,
        "backends": [
          "ffmpeg",
          "wget"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_nk6e8tm7/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      },
      {
        "media_type": "video",
        "height": 360,
        "width": 640,
        "bitrate": 940,
        "backends": [
          "ffmpeg",
          "wget"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_wc1a4ocw/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      },
      {
        "media_type": "video",
        "height": 720,
        "width": 1280,
        "bitrate": 1445,
        "backends": [
          "ffmpeg",
          "wget"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_7djfui4l/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      },
      {
        "media_type": "video",
        "height": 720,
        "width": 1280,
        "bitrate": 2565,
        "backends": [
          "ffmpeg",
          "wget"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_q9fq5doj/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      },
      {
        "media_type": "video",
        "height": 1080,
        "width": 1920,
        "bitrate": 4019,
        "backends": [
          "ffmpeg",
          "wget"
        ],
        "url": "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_s3dr9u33/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
      }
    ],
    "duration_seconds": 1435,
    "embedded_subtitles": [
      {
        "language": "fin",
        "category": "ohjelmatekstitys"
      }
    ],
    "subtitles": [
      {
        "language": "fin",
        "url": "https://cdnapi-legacy.kaltura.com/api_v3/index.php/service/caption_captionAsset/action/serve/captionAssetId/1_6cggt9b7/ks/NzZlMjZmYjYxYjIzMTdjZDhlNDA4YTVlYTFkMWNjNjk1NDJjODMyZXwxOTU1MDMxOzE5NTUwMzE7MTY0MzMwNzk1ODswOzE1MDIzO292cEB5bGUuZmk7ZG93bmxvYWQ6MF9hM3RqazkyYw==",
        "category": "ohjelmatekstitys"
      }
    ],
    "region": "World",
    "publish_timestamp": "2019-01-06T00:01:00+02:00"
```






### Verbose log

```shell
yt-dlp https://areena.yle.fi/1-4371942 -vU           
[debug] Command-line config: ['https://areena.yle.fi/1-4371942', '-vU']
[debug] System config "/etc/yt-dlp.conf": ['--download-archive', '/volumes/appdata/YT_Downloader/Config/downloaded.txt', '--restrict-filenames', '--prefer-ffmpeg', '--merge-output-format', 'mkv', '--cookies=/volumes/appdata/YT_Downloader/Config/cookiex.txt', '--format-sort', '+res', '--sponsorblock-remove', 'sponsor,selfpromo,interaction']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.01.21 [f20d607b0]
[debug] Python version 3.9.5 (CPython 64bit) - macOS-10.15.7-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.4.1 (setts), ffprobe 4.4.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] Loading archive file '/volumes/appdata/YT_Downloader/Config/downloaded.txt'
Latest version: 2022.01.21, Current version: 2022.01.21
yt-dlp is up to date (2022.01.21)
[debug] [generic] Extracting URL: https://areena.yle.fi/1-4371942
[generic] 1-4371942: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] 1-4371942: Downloading webpage
[generic] 1-4371942: Extracting information
[debug] Looking for video embeds
ERROR: Unsupported URL: https://areena.yle.fi/1-4371942
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 1367, in wrapper
    return func(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 1437, in __extract_info
    ie_result = ie.extract(url)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yt_dlp/extractor/common.py", line 612, in extract
    ie_result = self._real_extract(url)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yt_dlp/extractor/generic.py", line 3966, in _real_extract
    raise UnsupportedError(url)
```



Discussion:
After submitting and looking at the metadata, I tried as a whim one of the addresses found and yt-dlp at least would grab that.

```
yt-dlp "https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/0_a3tjk92c/flavorId/1_v6f2yuyi/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4"
[generic] a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtNDM3MTk0Mg==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39: Requesting header
[redirect] Following redirect to https://ylekaodamd.akamaized.net/s/fhls/p/1955031/sp/195503100/serveFlavor/entryId/0_a3tjk92c/v/1,1/ev/15/flavorId/1_v6f2yuyi,/ev/15/flavorId/1_6cggt9b7,/name/a.mp4/index.m3u8.urlset/master.m3u8?__hdnea__=st=1643286491~exp=1643300891~acl=/s/fhls/p/1955031/sp/195503100/serveFlavor/entryId/0_a3tjk92c/v/1*~hmac=fe07c8e474caf6f2910436d1f416748e8205797af7f1b09c499d09dd2c4f73b0
[generic] 1*~hmac=fe07c8e474caf6f2910436d1f416748e8205797af7f1b09c499d09dd2c4f73b0: Requesting header
[generic] 1*~hmac=fe07c8e474caf6f2910436d1f416748e8205797af7f1b09c499d09dd2c4f73b0: Downloading m3u8 information
[SponsorBlock] SponsorBlock is not supported for Generic
[info] 1*~hmac=fe07c8e474caf6f2910436d1f416748e8205797af7f1b09c499d09dd2c4f73b0: Downloading 1 format(s): 460
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 147
[download] Destination: master-[1_~hmac=fe07c8e474caf6f2910436d1f416748e8205797af7f1b09c499d09dd2c4f73b0].mp4
[download] 100% of 86.26MiB in 00:31
[FixupM3u8] Fixing MPEG-TS in MP4 container of "master-[1_~hmac=fe07c8e474caf6f2910436d1f416748e8205797af7f1b09c499d09dd2c4f73b0].mp4"
[ModifyChapters] SponsorBlock information is unavailable
```


For devs:

1. Make a GET request to `https://player.api.yle.fi/v1/preview/<id in url>.json?app_id=player_static_prod&app_key=8930d72170e48303cf5f3867780d549b`. 
    - This returns useful metadata about the video
    - Seems like the app_id and app_key are the only required parameters. Probably fine to hard-code.
2. Since this is a Kaltura video, you want to pass handling off to the Kaltura extractor. 
    - i.e. pass a `url_transparent`r esult with a url like `kaltura:<partner id>:<kaltura video id>`, with metadata from above response.
    - the kaltura video id is under data->ongoing_demand->kaltura->id in the above response
    - the partner id is 1955031. Probably fine to hard-code, but if you want to it shows up in the `manifest_url` in the above response.

Resolving patch:
diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py
--- a/yt_dlp/extractor/_extractors.py
+++ b/yt_dlp/extractor/_extractors.py
@@ -2233,6 +2233,7 @@
 from .yapfiles import YapFilesIE
 from .yesjapan import YesJapanIE
 from .yinyuetai import YinYueTaiIE
+from .yle_areena import YleAreenaIE
 from .ynet import YnetIE
 from .youjizz import YouJizzIE
 from .youku import (
diff --git a/yt_dlp/extractor/yle_areena.py b/yt_dlp/extractor/yle_areena.py
new file mode 100644
--- /dev/null
+++ b/yt_dlp/extractor/yle_areena.py
@@ -0,0 +1,71 @@
+from .common import InfoExtractor
+from .kaltura import KalturaIE
+from ..utils import int_or_none, traverse_obj, url_or_none
+
+
+class YleAreenaIE(InfoExtractor):
+    _VALID_URL = r'https?://areena\.yle\.fi/(?P<id>[\d-]+)'
+    _TESTS = [{
+        'url': 'https://areena.yle.fi/1-4371942',
+        'md5': '932edda0ecf5dfd6423804182d32f8ac',
+        'info_dict': {
+            'id': '0_a3tjk92c',
+            'ext': 'mp4',
+            'title': 'Pouchit',
+            'description': 'md5:d487309c3abbe5650265bbd1742d2f82',
+            'series': 'Modernit miehet',
+            'season': 'Season 1',
+            'season_number': 1,
+            'episode': 'Episode 2',
+            'episode_number': 2,
+            'thumbnail': 'http://cfvod.kaltura.com/p/1955031/sp/195503100/thumbnail/entry_id/0_a3tjk92c/version/100061',
+            'uploader_id': 'ovp@yle.fi',
+            'duration': 1435,
+            'view_count': int,
+            'upload_date': '20181204',
+            'timestamp': 1543916210,
+            'subtitles': {'fin': [{'url': r're:^https?://', 'ext': 'srt'}]},
+            'age_limit': 7,
+        }
+    }]
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        info = self._search_json_ld(self._download_webpage(url, video_id), video_id, default={})
+        video_data = self._download_json(
+            f'https://player.api.yle.fi/v1/preview/{video_id}.json?app_id=player_static_prod&app_key=8930d72170e48303cf5f3867780d549b',
+            video_id)
+
+        # Example title: 'K1, J2: Pouchit | Modernit miehet'
+        series, season_number, episode_number, episode = self._search_regex(
+            r'K(?P<season_no>[\d]+),\s*J(?P<episode_no>[\d]+):?\s*\b(?P<episode>[^|]+)\s*|\s*(?P<series>.+)',
+            info.get('title') or '', 'episode metadata', group=('season_no', 'episode_no', 'episode', 'series'),
+            default=(None, None, None, None))
+        description = traverse_obj(video_data, ('data', 'ongoing_ondemand', 'description', 'fin'), expected_type=str)
+
+        subtitles = {}
+        for sub in traverse_obj(video_data, ('data', 'ongoing_ondemand', 'subtitles', ...)):
+            if url_or_none(sub.get('uri')):
+                subtitles.setdefault(sub.get('language') or 'und', []).append({
+                    'url': sub['uri'],
+                    'ext': 'srt',
+                    'name': sub.get('kind'),
+                })
+
+        return {
+            '_type': 'url_transparent',
+            'url': 'kaltura:1955031:%s' % traverse_obj(video_data, ('data', 'ongoing_ondemand', 'kaltura', 'id')),
+            'ie_key': KalturaIE.ie_key(),
+            'title': (traverse_obj(video_data, ('data', 'ongoing_ondemand', 'title', 'fin'), expected_type=str)
+                      or episode or info.get('title')),
+            'description': description,
+            'series': (traverse_obj(video_data, ('data', 'ongoing_ondemand', 'series', 'title', 'fin'), expected_type=str)
+                       or series),
+            'season_number': (int_or_none(self._search_regex(r'Kausi (\d+)', description, 'season number', default=None))
+                              or int(season_number)),
+            'episode_number': (traverse_obj(video_data, ('data', 'ongoing_ondemand', 'episode_number'), expected_type=int_or_none)
+                               or int(episode_number)),
+            'thumbnails': traverse_obj(info, ('thumbnails', ..., {'url': 'url'})),
+            'age_limit': traverse_obj(video_data, ('data', 'ongoing_ondemand', 'content_rating', 'age_restriction'), expected_type=int_or_none),
+            'subtitles': subtitles,
+        }


Test patch: