Repository: yt-dlp/yt-dlp

Issue:
Yle areena: some media are not supported 
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I remove or skip any mandatory\* field

### Checklist

- [X] I'm requesting a site-specific feature
- [X] I've verified that I'm running yt-dlp version **2022.11.11** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [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 I'm willing to share it if required

### Region

Europe

### Example URLs

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

### Provide a description that is worded well enough to be understood

Extractor fails if a video without episode_number defined in JSON metadate is downloaded.

At the same time, the extractor does not allow downloading videos marked as restricted.


### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', 'https://areena.yle.fi/1-4266128']
[debug] Encodings: locale cp1250, fs utf-8, pref cp1250, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.11.11 [8b644025b] (source)
[debug] Lazy loading extractors is disabled
[debug] Plugins: ['SamplePluginIE', 'SamplePluginPP']
[debug] Git HEAD: 0e96b408b
[debug] Python 3.11.0 (CPython AMD64 64bit) - Windows-10-10.0.18363-SP0 (OpenSSL 1.1.1q  5 Jul 2022)
[debug] exe versions: ffmpeg 4.4 (setts), ffprobe 4.4
[debug] Optional libraries: certifi-2022.09.24, sqlite3-2.6.0
[debug] Proxy map: {}
[debug] Loaded 1731 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.11.11, Current version: 2022.11.11
yt-dlp is up to date (2022.11.11)
[debug] [YleAreena] Extracting URL: https://areena.yle.fi/1-4266128
[YleAreena] 1-4266128: Downloading webpage
[YleAreena] 1-4266128: Downloading JSON metadata
ERROR: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Traceback (most recent call last):
  File "C:\yt-dlp\yt_dlp\YoutubeDL.py", line 1495, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\yt-dlp\yt_dlp\YoutubeDL.py", line 1571, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "C:\yt-dlp\yt_dlp\extractor\common.py", line 678, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\yt-dlp\yt_dlp\extractor\yle_areena.py", line 65, in _real_extract
    or int(season_number)),
       ^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/yle_areena.py b/yt_dlp/extractor/yle_areena.py
--- a/yt_dlp/extractor/yle_areena.py
+++ b/yt_dlp/extractor/yle_areena.py
@@ -1,40 +1,79 @@
 from .common import InfoExtractor
 from .kaltura import KalturaIE
-from ..utils import int_or_none, traverse_obj, url_or_none
+from ..utils import (
+    int_or_none,
+    smuggle_url,
+    traverse_obj,
+    unified_strdate,
+    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,
+    _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',
+                'release_date': '20190106',
+                'timestamp': 1543916210,
+                'subtitles': {'fin': [{'url': r're:^https?://', 'ext': 'srt'}]},
+                'age_limit': 7,
+                'webpage_url': 'https://areena.yle.fi/1-4371942'
+            }
+        },
+        {
+            'url': 'https://areena.yle.fi/1-2158940',
+            'md5': 'cecb603661004e36af8c5188b5212b12',
+            'info_dict': {
+                'id': '1_l38iz9ur',
+                'ext': 'mp4',
+                'title': 'Albi haluaa vessan',
+                'description': 'md5:15236d810c837bed861fae0e88663c33',
+                'series': 'Albi Lumiukko',
+                'season': None,
+                'season_number': None,
+                'episode': None,
+                'episode_number': None,
+                'thumbnail': 'http://cfvod.kaltura.com/p/1955031/sp/195503100/thumbnail/entry_id/1_l38iz9ur/version/100021',
+                'uploader_id': 'ovp@yle.fi',
+                'duration': 319,
+                'view_count': int,
+                'upload_date': '20211202',
+                'release_date': '20211215',
+                'timestamp': 1638448202,
+                'subtitles': {},
+                'age_limit': 0,
+                'webpage_url': 'https://areena.yle.fi/1-2158940'
+            }
         }
-    }]
+    ]
 
     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)
+            video_id, headers={
+                'origin': 'https://areena.yle.fi',
+                'referer': 'https://areena.yle.fi/',
+                'content-type': 'application/json'
+            })
 
         # Example title: 'K1, J2: Pouchit | Modernit miehet'
         series, season_number, episode_number, episode = self._search_regex(
@@ -54,7 +93,9 @@ def _real_extract(self, url):
 
         return {
             '_type': 'url_transparent',
-            'url': 'kaltura:1955031:%s' % traverse_obj(video_data, ('data', 'ongoing_ondemand', 'kaltura', 'id')),
+            'url': smuggle_url(
+                f'kaltura:1955031:{video_data["data"]["ongoing_ondemand"]["kaltura"]["id"]}',
+                {'source_url': url}),
             'ie_key': KalturaIE.ie_key(),
             'title': (traverse_obj(video_data, ('data', 'ongoing_ondemand', 'title', 'fin'), expected_type=str)
                       or episode or info.get('title')),
@@ -62,10 +103,11 @@ def _real_extract(self, url):
             '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)),
+                              or int_or_none(season_number)),
             'episode_number': (traverse_obj(video_data, ('data', 'ongoing_ondemand', 'episode_number'), expected_type=int_or_none)
-                               or int(episode_number)),
+                               or int_or_none(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,
+            'release_date': unified_strdate(traverse_obj(video_data, ('data', 'ongoing_ondemand', 'start_time'), expected_type=str)),
         }


Test patch: