NJoy: improve extraction of NDR id, description, etc with current page formats
authordirkf <fieldhouse@gmx.net>
Mon, 17 Jan 2022 03:22:32 +0000 (03:22 +0000)
committerdirkf <fieldhouse@gmx.net>
Sat, 5 Feb 2022 02:12:44 +0000 (02:12 +0000)
youtube_dl/extractor/ndr.py

index a0d553f00b9ae45de335cb7eef6bcbb6d324d268..0a723e3b05ab191bb98c9be9f5505bbbb770a43e 100644 (file)
@@ -196,18 +196,25 @@ class NJoyIE(NDRBaseIE):
         'only_matching': True,
     }]
 
-    def _extract_embed(self, webpage, display_id):
+    def _extract_embed(self, webpage, display_id, url=None):
+        # find tell-tale URL with the actual ID, or ...
         video_id = self._search_regex(
-            r'<iframe[^>]+id="pp_([\da-z]+)"', webpage, 'embed id')
-        description = self._search_regex(
+            (r'''\bsrc\s*=\s*(?:"|')?(?:/\w+)+/([a-z]+\d+)(?!\.)\b''',
+             r'<iframe[^>]+id="pp_([\da-z]+)"', ),
+            webpage, 'NDR id', default=None)
+
+        description = (
+            self._html_search_meta('description', webpage)
+            or self._search_regex(
                 r'<div[^>]+class="subline"[^>]*>[^<]+</div>\s*<p>([^<]+)</p>',
-            webpage, 'description', fatal=False)
+                webpage, 'description', fatal=False))
         return {
             '_type': 'url_transparent',
             'ie_key': 'NDREmbedBase',
             'url': 'ndr:%s' % video_id,
             'display_id': display_id,
             'description': description,
+            'title': display_id.replace('-', ' ').strip(),
         }