]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[YoutubeDL] Ignore duplicates in --playlist-items
authorSergey M․ <dstftw@gmail.com>
Fri, 6 Oct 2017 16:46:57 +0000 (23:46 +0700)
committerSergey M․ <dstftw@gmail.com>
Fri, 6 Oct 2017 16:50:34 +0000 (23:50 +0700)
E.g. '--playlist-items 2-4,3-4,3' should result in '[2,3,4]', not '[2,3,4,3,4,3]'

test/test_YoutubeDL.py
youtube_dl/YoutubeDL.py

index 5ac34e6635102092936cfdefd8f4b62a75eeeae0..db936bfb88d4bd0a05be1cc6fd7d1b18ce3a72b6 100644 (file)
@@ -773,6 +773,9 @@ class TestYoutubeDL(unittest.TestCase):
         result = get_ids({'playlist_items': '3-10'})
         self.assertEqual(result, [3, 4])
 
+        result = get_ids({'playlist_items': '2-4,3-4,3'})
+        self.assertEqual(result, [2, 3, 4])
+
     def test_urlopen_no_file_protocol(self):
         # see https://github.com/rg3/youtube-dl/issues/8227
         ydl = YDL()
index 9036f0f94b8eb3259dcc3eb22b56e96b8371ee9c..855d6b8e52a62fd1b33cb909c25694d426452033 100755 (executable)
@@ -65,6 +65,7 @@ from .utils import (
     locked_file,
     make_HTTPS_handler,
     MaxDownloadsReached,
+    orderedSet,
     PagedList,
     parse_filesize,
     PerRequestProxyHandler,
@@ -908,7 +909,7 @@ class YoutubeDL(object):
                                 yield int(item)
                         else:
                             yield int(string_segment)
-                playlistitems = iter_playlistitems(playlistitems_str)
+                playlistitems = orderedSet(iter_playlistitems(playlistitems_str))
 
             ie_entries = ie_result['entries']