Repository: yt-dlp/yt-dlp

Issue:
[MLBArticle] An extractor error has occurred
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

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

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and 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

canada

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

Example URL: https://www.mlb.com/news/shohei-ohtani-rumors

u

### 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] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
yt-dlp.py -vU "https://www.mlb.com/news/shohei-ohtani-rumors"
[debug] Command-line config: ['-vU', 'https://www.mlb.com/news/shohei-ohtani-rumors']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2023.11.28.232715 from yt-dlp/yt-dlp-nightly-builds [15f22b488] (zip)
[debug] Python 3.10.5 (CPython AMD64 64bit) - Windows-10-10.0.14393-SP0 (OpenSSL 1.1.1n  15 Mar 2022)
[debug] exe versions: ffmpeg 6.1-full_build-www.gyan.dev (setts), ffprobe 4.3.2-2021-02-02-full_build-www.gyan.dev, rtmpdump 2.4
[debug] Optional libraries: sqlite3-3.37.2
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1792 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2023.11.28.232715 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2023.11.28.232715 from yt-dlp/yt-dlp-nightly-builds)
[MLBArticle] Extracting URL: https://www.mlb.com/news/shohei-ohtani-rumors
[MLBArticle] shohei-ohtani-rumors: Downloading webpage
ERROR: shohei-ohtani-rumors: An extractor error has occurred. (caused by KeyError(None)); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "C:\Transmogrifier\yt-dlp.py\yt_dlp\extractor\common.py", line 717, in extract
    ie_result = self._real_extract(url)
  File "C:\Transmogrifier\yt-dlp.py\yt_dlp\extractor\mlb.py", line 373, in _real_extract
    content_real_info = apollo_cache_json[content_data_id]
KeyError: None
```



Discussion:
The sites seems change the structure of the json that makes the extractor breaks. I didn't tested yet, but it seems the problem is in this line:

https://github.com/yt-dlp/yt-dlp/blob/8e6e3651727b0b85764857fc6329fe5e0a3f00de/yt_dlp/extractor/mlb.py#L370-L371

The sites is providing slug inside of `getArticle({\"language\":\"EN_US\",\"slug\":\"shohei-ohtani-rumors\"}) -> parts -> [] -> slug` instead of the old way in the `getForgeContent`

Resolving patch:
diff --git a/yt_dlp/extractor/mlb.py b/yt_dlp/extractor/mlb.py
--- a/yt_dlp/extractor/mlb.py
+++ b/yt_dlp/extractor/mlb.py
@@ -355,11 +355,11 @@ class MLBArticleIE(InfoExtractor):
         'info_dict': {
             'id': '36db7394-343c-4ea3-b8ca-ead2e61bca9a',
             'title': 'Machado\'s grab draws hilarious irate reaction',
-            'modified_timestamp': 1650130737,
+            'modified_timestamp': 1675888370,
             'description': 'md5:a19d4eb0487b2cb304e9a176f6b67676',
-            'modified_date': '20220416',
+            'modified_date': '20230208',
         },
-        'playlist_count': 2,
+        'playlist_mincount': 2,
     }]
 
     def _real_extract(self, url):
@@ -367,15 +367,13 @@ def _real_extract(self, url):
         webpage = self._download_webpage(url, display_id)
         apollo_cache_json = self._search_json(r'window\.initState\s*=', webpage, 'window.initState', display_id)['apolloCache']
 
-        content_data_id = traverse_obj(
-            apollo_cache_json, ('ROOT_QUERY', lambda k, _: k.startswith('getForgeContent'), 'id'), get_all=False)
-
-        content_real_info = apollo_cache_json[content_data_id]
+        content_real_info = traverse_obj(
+            apollo_cache_json, ('ROOT_QUERY', lambda k, _: k.startswith('getArticle')), get_all=False)
 
         return self.playlist_from_matches(
-            traverse_obj(content_real_info, ('parts', lambda _, v: v['typename'] == 'Video', 'id')),
-            getter=lambda x: f'https://www.mlb.com/video/{apollo_cache_json[x]["slug"]}',
-            ie=MLBVideoIE, playlist_id=content_real_info.get('_translationId'),
+            traverse_obj(content_real_info, ('parts', lambda _, v: v['__typename'] == 'Video' or v['type'] == 'video')),
+            getter=lambda x: f'https://www.mlb.com/video/{x["slug"]}',
+            ie=MLBVideoIE, playlist_id=content_real_info.get('translationId'),
             title=self._html_search_meta('og:title', webpage),
             description=content_real_info.get('summary'),
             modified_timestamp=parse_iso8601(content_real_info.get('lastUpdatedDate')))


Test patch: