Repository: yt-dlp/yt-dlp

Issue:
[Broken] PolskieRadio and PolskieRadioCategory
<!--

######################################################################
  WARNING!
  IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
######################################################################

-->


## Checklist

<!--
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of yt-dlp:
- First of, make sure you are using the latest version of yt-dlp. Run `yt-dlp --version` and ensure your version is 2021.09.02. If it's not, see https://github.com/yt-dlp/yt-dlp on how to update. Issues with outdated version will be REJECTED.
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in https://github.com/yt-dlp/yt-dlp.
- Search the bugtracker for similar issues: https://github.com/yt-dlp/yt-dlp. DO NOT post duplicates.
- Finally, put x into all relevant boxes like this [x] (Dont forget to delete the empty space)
-->

- [x] I'm reporting a broken site support
- [x] I've verified that I'm running yt-dlp version **2021.09.02**
- [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
- [x] I've searched the bugtracker for similar issues including closed ones


## Verbose log

<!--
Provide the complete verbose output of yt-dlp that clearly demonstrates the problem.
Add the `-v` flag to your command line you run yt-dlp with (`yt-dlp -v <your command line>`), copy the WHOLE output and insert it below. It should look similar to this:
 [debug] System config: []
 [debug] User config: []
 [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKc']
 [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
 [debug] yt-dlp version 2021.09.02
 [debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
 [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
 [debug] Proxy map: {}
 <more lines>
-->

```
**PolskieRadio**

yt-dlp -v https://www.polskieradio.pl/8/406/Artykul/2773032,Surowy-autoportret-Jan-van-Eyck
[debug] Command-line config: ['-v', 'https://www.polskieradio.pl/8/406/Artykul/2773032,Surowy-autoportret-Jan-van-Eyck']
[debug] Encodings: locale cp1250, fs utf-8, out utf-8, pref cp1250
[debug] yt-dlp version 2021.09.02
[debug] Python version 3.8.3 (CPython 64bit) - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 4.2.3, ffprobe git-2020-06-28-4cfcfb3
[debug] Optional libraries: mutagen, pycryptodome, sqlite, websockets
[debug] Proxy map: {}
[debug] [PolskieRadio] Extracting URL: https://www.polskieradio.pl/8/406/Artykul/2773032,Surowy-autoportret-Jan-van-Eyck
[PolskieRadio] 2773032: Downloading webpage
[download] Downloading playlist: Surowy autoportret. Jan van Eyck
[PolskieRadio] playlist Surowy autoportret. Jan van Eyck: Collected 0 videos; downloading 0 of them
[download] Finished downloading playlist: Surowy autoportret. Jan van Eyck

And 
**PolskieRadioCategory**

yt-dlp -v https://www.polskieradio.pl/8/406
[debug] Command-line config: ['-v', 'https://www.polskieradio.pl/8/406']
[debug] Encodings: locale cp1250, fs utf-8, out utf-8, pref cp1250
[debug] yt-dlp version 2021.09.02
[debug] Python version 3.8.3 (CPython 64bit) - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 4.2.3, ffprobe git-2020-06-28-4cfcfb3
[debug] Optional libraries: mutagen, pycryptodome, sqlite, websockets
[debug] Proxy map: {}
[debug] [PolskieRadioCategory] Extracting URL: https://www.polskieradio.pl/8/406
[PolskieRadioCategory] 406: Downloading webpage
[download] Downloading playlist: Jest taki obraz
[PolskieRadioCategory] playlist Jest taki obraz: Downloading 12 videos
[download] Downloading video 1 of 12
[debug] [PolskieRadio] Extracting URL: https://www.polskieradio.pl/8/406/Artykul/2807852,Milosc-ziemska-i-niebianska-wedlug-Tycjana
[PolskieRadio] 2807852: Downloading webpage
[download] Downloading playlist: "Miłość ziemska i niebiańska" według Tycjana
[PolskieRadio] playlist "Miłość ziemska i niebiańska" według Tycjana: Collected 0 videos; downloading 0 of them
[download] Finished downloading playlist: "Miłość ziemska i niebiańska" według Tycjana
[download] Downloading video 2 of 12
[debug] [PolskieRadio] Extracting URL: https://www.polskieradio.pl/8/406/Artykul/2803302,Meduzy-Potwory-Rubensa-i-Caravaggia
[PolskieRadio] 2803302: Downloading webpage
[download] Downloading playlist: Meduzy. Potwory Rubensa i Caravaggia
[PolskieRadio] playlist Meduzy. Potwory Rubensa i Caravaggia: Collected 0 videos; downloading 0 of them
[download] Finished downloading playlist: Meduzy. Potwory Rubensa i Caravaggia
[...]
[download] Downloading video 12 of 12
[debug] [PolskieRadio] Extracting URL: https://www.polskieradio.pl/8/406/Artykul/2765844,Matka-Boska-Czula-Obraz-Andrei-Mantegni
[PolskieRadio] 2765844: Downloading webpage
[download] Downloading playlist: Matka Boska Czuła. Obraz Andrei Mantegni
[PolskieRadio] playlist Matka Boska Czuła. Obraz Andrei Mantegni: Collected 0 videos; downloading 0 of them
[download] Finished downloading playlist: Matka Boska Czuła. Obraz Andrei Mantegni
[download] Finished downloading playlist: Jest taki obraz

```
<!--
Do not remove the above ```
-->


## Description

<!--
Provide an explanation of your issue in an arbitrary form. Provide any additional information, suggested solution and as much context and examples as possible.
If work on your issue requires account credentials, please provide them or explain how one can obtain them.
-->

Broken download possibility, due to change in site structure. It is listing etc but not downloading.
It was reported already in 2020 - and here is a fix contribution from original author: 
https://github.com/ytdl-org/youtube-dl/pull/26069 
But unfortunately the fix was never added to youtube-dl. :( 
Please help.



Discussion:
@jakubadamw, would you be willing to bring this PR over here?

Resolving patch:
diff --git a/yt_dlp/extractor/polskieradio.py b/yt_dlp/extractor/polskieradio.py
--- a/yt_dlp/extractor/polskieradio.py
+++ b/yt_dlp/extractor/polskieradio.py
@@ -15,12 +15,13 @@
     int_or_none,
     strip_or_none,
     unified_timestamp,
+    unescapeHTML,
 )
 
 
 class PolskieRadioIE(InfoExtractor):
     _VALID_URL = r'https?://(?:www\.)?polskieradio\.pl/\d+/\d+/Artykul/(?P<id>[0-9]+)'
-    _TESTS = [{
+    _TESTS = [{  # Old-style single broadcast.
         'url': 'http://www.polskieradio.pl/7/5102/Artykul/1587943,Prof-Andrzej-Nowak-o-historii-nie-da-sie-myslec-beznamietnie',
         'info_dict': {
             'id': '1587943',
@@ -39,14 +40,41 @@ class PolskieRadioIE(InfoExtractor):
                 'thumbnail': r're:^https?://static\.prsa\.pl/images/.*\.jpg$'
             },
         }],
-    }, {
-        'url': 'http://www.polskieradio.pl/265/5217/Artykul/1635803,Euro-2016-nie-ma-miejsca-na-blad-Polacy-graja-ze-Szwajcaria-o-cwiercfinal',
+    }, {  # New-style single broadcast.
+        'url': 'https://www.polskieradio.pl/8/2382/Artykul/2534482,Zagarysci-Poezja-jak-spoiwo',
+        'info_dict': {
+            'id': '2534482',
+            'title': 'Żagaryści. Poezja jak spoiwo',
+            'description': 'md5:f18d95d5dcba747a09b635e21a4c0695',
+        },
+        'playlist': [{
+            'md5': 'd07559829f61d5a93a75755987ded760',
+            'info_dict': {
+                'id': '2516679',
+                'ext': 'mp3',
+                'title': 'md5:c6e1234e0b747ad883cb91b7ad06b98c',
+                'timestamp': 1592654400,
+                'upload_date': '20200620',
+                'duration': 1430,
+                'thumbnail': r're:^https?://static\.prsa\.pl/images/.*\.jpg$'
+            },
+        }],
+    }, {  # Old-style multiple broadcast playlist.
+        'url': 'https://www.polskieradio.pl/8/4346/Artykul/2487823,Marek-Kondrat-czyta-Mistrza-i-Malgorzate',
+        'info_dict': {
+            'id': '2487823',
+            'title': 'Marek Kondrat czyta "Mistrza i Małgorzatę"',
+            'description': 'md5:8422a95cc83834f2aaeff9d82e9c8f39',
+        },
+        'playlist_mincount': 50,
+    }, {  # New-style multiple broadcast playlist.
+        'url': 'https://www.polskieradio.pl/8/4346/Artykul/2541317,Czytamy-Kalendarz-i-klepsydre-Tadeusza-Konwickiego',
         'info_dict': {
-            'id': '1635803',
-            'title': 'Euro 2016: nie ma miejsca na błąd. Polacy grają ze Szwajcarią o ćwierćfinał',
-            'description': 'md5:01cb7d0cad58664095d72b51a1ebada2',
+            'id': '2541317',
+            'title': 'Czytamy "Kalendarz i klepsydrę" Tadeusza Konwickiego',
+            'description': 'md5:0baeaa46d877f1351fb2eeed3e871f9f',
         },
-        'playlist_mincount': 12,
+        'playlist_mincount': 15,
     }, {
         'url': 'http://polskieradio.pl/9/305/Artykul/1632955,Bardzo-popularne-slowo-remis',
         'only_matching': True,
@@ -78,8 +106,8 @@ def _real_extract(self, url):
 
         media_urls = set()
 
-        for data_media in re.findall(r'<[^>]+data-media=({[^>]+})', content):
-            media = self._parse_json(data_media, playlist_id, fatal=False)
+        for data_media in re.findall(r'<[^>]+data-media="?({[^>]+})"?', content):
+            media = self._parse_json(data_media, playlist_id, transform_source=unescapeHTML, fatal=False)
             if not media.get('file') or not media.get('desc'):
                 continue
             media_url = self._proto_relative_url(media['file'], 'http:')
@@ -98,6 +126,7 @@ def _real_extract(self, url):
 
         title = self._og_search_title(webpage).strip()
         description = strip_or_none(self._og_search_description(webpage))
+        description = description.replace('\xa0', ' ') if description is not None else None
 
         return self.playlist_result(entries, playlist_id, title, description)
 


Test patch: