From ff1c7fc9d3e54c3584117ce76e2b6ce9da030af2 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 25 Sep 2021 03:31:35 +0530 Subject: [PATCH] Allow `0` in `--playlist-items` --- test/test_YoutubeDL.py | 1 + yt_dlp/YoutubeDL.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index 210bf441c..6feca2ce2 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -1000,6 +1000,7 @@ class TestYoutubeDL(unittest.TestCase): test_selection({'playlist_items': '2-4'}, [2, 3, 4]) test_selection({'playlist_items': '2,4'}, [2, 4]) test_selection({'playlist_items': '10'}, []) + test_selection({'playlist_items': '0'}, []) # Tests for https://github.com/ytdl-org/youtube-dl/issues/10591 test_selection({'playlist_items': '2-4,3-4,3'}, [2, 3, 4]) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 2258e22af..11371fa86 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1464,7 +1464,10 @@ class YoutubeDL(object): )(self, i) entries = [] - for i in playlistitems or itertools.count(playliststart): + items = playlistitems if playlistitems is not None else itertools.count(playliststart) + for i in items: + if i == 0: + continue if playlistitems is None and playlistend is not None and playlistend < i: break entry = None