Add a duplicate check to /extractor/common.py playlist_result function
authoranovicecodemonkey <anovicecodemonkey13435@mailinator.com>
Wed, 21 May 2014 09:34:55 +0000 (19:04 +0930)
committeranovicecodemonkey <anovicecodemonkey13435@mailinator.com>
Wed, 21 May 2014 09:34:55 +0000 (19:04 +0930)
youtube_dl/extractor/common.py

index db472aace8faabb465e9c93b7ff6013ccece4e8e..26dd9882f80ad1b2feea0f9ed6bf45718b4311af 100644 (file)
@@ -343,6 +343,16 @@ class InfoExtractor(object):
     @staticmethod
     def playlist_result(entries, playlist_id=None, playlist_title=None):
         """Returns a playlist"""
+        # Ensure we don't have any duplicates in the playlist
+        seen = set()
+        new_list = []
+        for url in entries:
+            theurl = tuple(url.items())
+            if theurl not in seen:
+             seen.add(theurl)
+             new_list.append(url)
+             entries = new_list
+
         video_info = {'_type': 'playlist',
                       'entries': entries}
         if playlist_id: