Repository: yt-dlp
Issue: Fix radio-canada.ca support (and maybe OHdio?)
Labels: site-bug,triage

### 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 a new site support request
- [X] I've verified that I'm running yt-dlp version **2023.03.04** ([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 checked that none of provided URLs [violate any copyrights](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-website-primarily-used-for-piracy) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [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 am willing to share it if required

### Region

Canada

### Example URLs

- Single video: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/episodes/668947/farine-agatha-invention-galaxie/emission
- Video Playlist: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/tout

- Single audio: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/episodes/450998/science-fiction-jeunesse-enfants-livre/7228/audios
- Audio playlist: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios

### Provide a description that is worded well enough to be understood

radio-canada used to provide actual RSS feeds for their shows, but switched to using a rather idiotic [OHdio](https://ici.radio-canada.ca/ohdio) thing that is both an app and a website. Confusingly, other things are still available *outside* of that site. 

The above URLs give an example of videos that are available outside of OHdio, but presumably some work could be done to support OHdio-only sites as well. I have also provided an example of an audio track that I've actually been able to download myself, after much head banging and hair-splitting. That is, of course, after a friend told me "oh you should just write a yt-dlp extractor" and I found out (much too late) about [this documentation](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#developer-instructions) and the [plugin stuff](https://github.com/yt-dlp/yt-dlp/wiki/Plugin-Development).

In any case, what i did is this rather nasty shell script:

```sh
#!/bin/sh

# ridiculous scraper for radio-canada audio shows
#
# many limitations:
# - hardcodes URL
# - probably brittle
# - untested on other shows, let alone videos and especially not OHdio
# - doesn't add proper tags to the audio file (artist, album, etc)
# - should be a yt-dlp extractor instead, see https://github.com/yt-dlp/yt-dlp/issues/6678

set -e

#set -x

BaseURL='https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios'

curl -s "$BaseURL" | sed -n '/medianet-content/{s/.*href="/https:\/\/ici.radio-canada.ca/;s/".*//;p}' | while read EpUrl; do

    #EpUrl='https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/episodes/456610/neo-agence-cheffe-sauver-monde-ennemie/7228/audios'
    # look for a <script .*type=consolevideo+json>, it's our magic JSON blob
    #IdMedia=$(curl -s "$EpUrl" | grep -Po '"IdMedia":"\d+"' | grep -Po '\d+')
    JSON_BLOB=$(curl -s "$EpUrl" | sed -n '/<script[^>]*application[^>]*>/,/<\/script>/p' | sed -e '/<\/\?script/d')

    IdMedia=$(
        jq -r .Media.IdMedia <<EOF
$JSON_BLOB
EOF
           )
    Title=$(
        jq -r .Title <<EOF
$JSON_BLOB
EOF
         )
    m3u_url=$(curl -s 'https://services.radio-canada.ca/media/validation/v2/?appCode=medianet&connectionType=hd&deviceType=ipad&idMedia='"$IdMedia"'&multibitrate=true&output=json&tech=hls' | jq -r .url)
    yt-dlp -o "$Title".mp4 "$m3u_url"
done
```

Basically the trick is that you can enumerate the audio tracks from the "playlist" URL above, then from there you need to find and load a small JSON blob that gives you the unique ID for a HLS stream that yt-dlp is then quite happy to slurp down. It's missing author/title/genre kind of metadata in the mp4 and doesn't pull the covers, but that would probably be easier to implement in yt-dlp than going any further ahead in that horrible script.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] 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
anarcat@angela:tmp$ yt-dlp -vU 'https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios'
[debug] Command-line config: ['-vU', 'https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (debian*)
[debug] Python 3.11.2 (CPython x86_64 64bit) - Linux-6.1.0-6-amd64-x86_64-with-glibc2.36 (OpenSSL 3.0.8 7 Feb 2023, glibc 2.36)
[debug] exe versions: ffmpeg 5.1.2-3 (setts), ffprobe 5.1.2-3, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.11.0, brotli-1.0.9, certifi-2022.09.24, mutagen-1.46.0, pyxattr-0.8.0, secretstorage-3.3.3, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1786 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.03.04, Current version: stable@2023.03.04
yt-dlp is up to date (stable@2023.03.04)
[generic] Extracting URL: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios
[generic] audios: Downloading webpage
WARNING: [generic] Falling back on generic information extractor
[generic] audios: Extracting information
[debug] Looking for embeds
ERROR: Unsupported URL: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/yt_dlp/YoutubeDL.py", line 1518, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yt_dlp/YoutubeDL.py", line 1594, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yt_dlp/extractor/common.py", line 694, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yt_dlp/extractor/generic.py", line 2510, in _real_extract
    raise UnsupportedError(url)
yt_dlp.utils.UnsupportedError: Unsupported URL: https://ici.radio-canada.ca/jeunesse/scolaire/emissions/5615/lagent-jean/contenu/audios
```