about summary refs log tree commit diff
path: root/overlays/patches/youtube-dl/0002-bandcamp-use-unescapeHTML-instead-of-a-simple-replac.patch
blob: 649ca6477951377c502ff6d3cbb937743a3d4abe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 61b0809be0f6acb7b88ebb0146cb2a85bc41b805 Mon Sep 17 00:00:00 2001
From: Gilles Pietri <gilles@wolface.fr>
Date: Sat, 26 Sep 2020 17:34:35 +0200
Subject: [PATCH 2/8] [bandcamp] use unescapeHTML instead of a simple replace
 of quotes

From https://github.com/ytdl-org/youtube-dl/pull/26684.
---
 youtube_dl/extractor/bandcamp.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/youtube_dl/extractor/bandcamp.py b/youtube_dl/extractor/bandcamp.py
index ad1812320..55d110e28 100644
--- a/youtube_dl/extractor/bandcamp.py
+++ b/youtube_dl/extractor/bandcamp.py
@@ -92,10 +92,10 @@ class BandcampIE(InfoExtractor):
 
         formats = []
         trackinfo_block = self._search_regex(
-            r'trackinfo&quot;:\[\s*({.+?})\s*\],&quot;',
+            r'trackinfo(?:["\']|&quot;):\[\s*({.+?})\s*\],(?:["\']|&quot;)',
             webpage, 'track info', default='{}')
-        quoted_json = trackinfo_block.replace('&quot;', '"')
-        track_info = self._parse_json(quoted_json, title)
+        unescaped_json = unescapeHTML(trackinfo_block)
+        track_info = self._parse_json(unescaped_json, title)
         if track_info:
             file_ = track_info.get('file')
             if isinstance(file_, dict):
@@ -118,7 +118,7 @@ class BandcampIE(InfoExtractor):
 
         def extract(key):
             return self._search_regex(
-                r',&quot;%s&quot;:(&quot;)(?P<value>(?:(?!&quot;).)+)&quot;' % key,
+                r',(["\']|&quot;)%s\1:\1(?P<value>(?:(?!\1).)+)\1' % key,
                 webpage, key, default=None, group='value')
 
         artist = extract('artist')
-- 
2.27.0