Repository: yt-dlp/yt-dlp

Issue:
CBC/Gem cannot find URL error
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2021.10.22**. ([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 all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#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 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

### Description

(have looked at the CBC entries in the bugtracker and don't recognise them as matching this).

Situation: URL claiming not to exist when it is shown as working in a browser. Running from a Canadian IP.

Example usage: yt-dlp "https://gem.cbc.ca/media/absolutely-canadian/s21"



### Verbose log

```shell
di@localhost:~/YTdl$ yt-dlp -Uv "https://gem.cbc.ca/media/absolutely-canadian/s21"
[debug] Command-line config: ['-Uv', 'https://gem.cbc.ca/media/absolutely-canadian/s21']
[debug] System config file: /etc/yt-dlp.conf
[debug] System config: ['--download-archive', '/home/di/YTdl/downloaded.txt', '--format', 'bestvideo[height<=720]+bestaudio/best[height<=720]', '--merge-output-format', 'mp4']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8[debug] yt-dlp version 2021.10.22
[debug] Python version 3.10.0 (CPython 64bit) - Linux-4.19.0-18-amd64-x86_64-with-glibc2.28
[debug] exe versions: ffmpeg 4.4, ffprobe 4.4
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] Loading archive file '/home/di/YTdl/downloaded.txt'
yt-dlp is up to date (2021.10.22)
[debug] [gem.cbc.ca:playlist] Extracting URL: https://gem.cbc.ca/media/absolutely-canadian/s21
[gem.cbc.ca:playlist] absolutely-canadian/s21: Downloading JSON metadata
ERROR: [gem.cbc.ca:playlist] absolutely-canadian/s21: Couldn't find season 21 of absolutely-canadian; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 593, in extract
    ie_result = self._real_extract(url)
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/extractor/cbc.py", line 396, in _real_extract
    raise ExtractorError(f'Couldn\'t find season {season} of {show}')
yt_dlp.utils.ExtractorError: Couldn't find season 21 of absolutely-canadian; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 593, in extract
    ie_result = self._real_extract(url)
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/extractor/cbc.py", line 396, in _real_extract
    raise ExtractorError(f'Couldn\'t find season {season} of {show}')
yt_dlp.utils.ExtractorError: Couldn't find season 21 of absolutely-canadian; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1280, in wrapper
    return func(self, *args, **kwargs)
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1305, in __extract_info
    ie_result = ie.extract(url)
  File "/home/di/.linuxbrew/Cellar/yt-dlp/2021.10.22/libexec/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 609, in extract
    raise ExtractorError(
yt_dlp.utils.ExtractorError: [gem.cbc.ca:playlist] absolutely-canadian/s21: Couldn't find season 21 of absolutely-canadian; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
```



Discussion:
I believe https://gem.cbc.ca/media/absolutely-canadian/s21 is just the main "landing page" for the season 21 of the show.  
Click the link for the episod you wish to download and copy the actual video URL.

When I send any individual episode to yt-dlp it downloads successfully:
https://gem.cbc.ca/media/absolutely-canadian/s21e01
or
https://gem.cbc.ca/media/absolutely-canadian/s14e03






Yes, it is the landing page. But YT-dlp works with many landing pages. It even works with:

https://gem.cbc.ca/media/absolutely-canadian/s10

So

yt-dlp 'https://gem.cbc.ca/media/absolutely-canadian/s10'

So I Don;’t understand the error on other series?




—- 
Via iPad. Hopefully with not too many typos. 


> On 8. Nov 2021, at 18.19, RingoTheDog ***@***.***> wrote:
> 
> ﻿
> I believe https://gem.cbc.ca/media/absolutely-canadian/s21 is just the main "landing page" for the season 21 of the show.
> 
> When I send any individual episode to yt-dlp it downloads successfully:
> https://gem.cbc.ca/media/absolutely-canadian/s21e01
> or
> https://gem.cbc.ca/media/absolutely-canadian/s14e03
> 
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub, or unsubscribe.
> Triage notifications on the go with GitHub Mobile for iOS or Android. 

I found a problem before with seasons >15 I think. for example Dragon's den, just no time to detail it out.
I was the one who contributed the current CBC Gem code. I will take a look at this. Feel free to tag me for any future CBC Gem issues.
Ah, OK, thank you for your efforts! I will try and remember to ping you
should I notice any other issues going forward.

Would there be scope to possibly increase the detection abilities of the
script (I don't know if that is an element of what you have produced, or
YT-dlp). I've noticed not all "landing pages" or series pages will download
all items. Maybe that is a Javascript menu?



‌


On Wed, 10 Nov 2021 at 06:54, makeworld ***@***.***> wrote:

> I was the one who contributed the current CBC Gem code. I will take a look
> at this. Feel free to tag me for any future CBC Gem issues.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/yt-dlp/yt-dlp/issues/1594#issuecomment-964787082>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABV5MACKUWCUNZEAPAYEZR3ULH3JLANCNFSM5HSOY6QQ>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>

> I've noticed not all "landing pages" or series pages will download all items. Maybe that is a Javascript menu?

I would like to try and get all CBC Gem series pages to work. You mentioned `https://gem.cbc.ca/media/absolutely-canadian/s21` is broken so I will look into that one, free free to post any others that you've noticed don't work.

I won't be supporting any pages that have changing content, like the home page or documentaries page, etc.

Resolving patch:
diff --git a/yt_dlp/extractor/cbc.py b/yt_dlp/extractor/cbc.py
--- a/yt_dlp/extractor/cbc.py
+++ b/yt_dlp/extractor/cbc.py
@@ -390,7 +390,8 @@ def _real_extract(self, url):
         show = match.group('show')
         show_info = self._download_json(self._API_BASE + show, season_id)
         season = int(match.group('season'))
-        season_info = try_get(show_info, lambda x: x['seasons'][season - 1])
+
+        season_info = next((s for s in show_info['seasons'] if s.get('season') == season), None)
 
         if season_info is None:
             raise ExtractorError(f'Couldn\'t find season {season} of {show}')


Test patch: