Fixed groups() call on potentially empty regex search object (#30676)
authordirkf <fieldhouse@gmx.net>
Thu, 24 Feb 2022 18:26:58 +0000 (18:26 +0000)
committerGitHub <noreply@github.com>
Thu, 24 Feb 2022 18:26:58 +0000 (18:26 +0000)
* Fixed groups() call on potentially empty regex search object.
- https://github.com/ytdl-org/youtube-dl/issues/30521

* minimising lines changed

Co-authored-by: yayorbitgum <50963144+yayorbitgum@users.noreply.github.com>
youtube_dl/extractor/myspass.py

index db7ebc94ca7305dfb61cafd46679689906019ceb..f540c52ee68aa20044820b2c8a41763e51eaf8c2 100644 (file)
@@ -35,7 +35,9 @@ class MySpassIE(InfoExtractor):
         title = xpath_text(metadata, 'title', fatal=True)
         video_url = xpath_text(metadata, 'url_flv', 'download url', True)
         video_id_int = int(video_id)
-        for group in re.search(r'/myspass2009/\d+/(\d+)/(\d+)/(\d+)/', video_url).groups():
+
+        grps = re.search(r'/myspass2009/\d+/(\d+)/(\d+)/(\d+)/', video_url)
+        for group in grps.groups() if grps else []:
             group_int = int(group)
             if group_int > video_id_int:
                 video_url = video_url.replace(