From d6a5ac0d6d5934352027bc660fc31900817917ca Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 13 Oct 2019 19:21:10 -0400 Subject: [PATCH] [nbc] Hardcode v3.14 API to pick up recent programs (fixes #22693) Starting in Oct. 2019, queries to the "v3" API started omitting recent programs that are otherwise viewable for free on the NBC website, causing an IndexException deferencing `response['data'][0]`. API calls to "v3" are aliased to the v3.0.0 API, although the latest v3 API is v3.14, (per https://api.nbc.com/). Programs show up in the v3.0.0 API several hours or days after they are actually available, so there is no simple test case for this problem. This problem does not affect the v3.2 API or later. Hardcode the v3.14 API for now. (The latest API is v4.21.0, but we do not know how to use it.) --- youtube_dl/extractor/nbc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/nbc.py b/youtube_dl/extractor/nbc.py index 3282f84ee..65d3870d6 100644 --- a/youtube_dl/extractor/nbc.py +++ b/youtube_dl/extractor/nbc.py @@ -85,7 +85,9 @@ class NBCIE(AdobePassIE): permalink, video_id = re.match(self._VALID_URL, url).groups() permalink = 'http' + compat_urllib_parse_unquote(permalink) response = self._download_json( - 'https://api.nbc.com/v3/videos', video_id, query={ + # Hardcode the latest v3 API, because 'v3' aliases to v3.0.0 which + # does not return metadata for new programs until hours/days later. + 'https://api.nbc.com/v3.14/videos', video_id, query={ 'filter[permalink]': permalink, 'fields[videos]': 'description,entitlement,episodeNumber,guid,keywords,seasonNumber,title,vChipRating', 'fields[shows]': 'shortTitle',