[moviefap] Explicitly sort formats to handle possible site changes
authorGeorge Brighton <george@gebn.co.uk>
Sat, 27 Jun 2015 21:27:06 +0000 (22:27 +0100)
committerGeorge Brighton <george@gebn.co.uk>
Sat, 27 Jun 2015 21:28:17 +0000 (22:28 +0100)
youtube_dl/extractor/moviefap.py

index 20a78f3b2ba62a36cfd284c3cd210f99fb2db218..295bfe3f02b5f468246e626d0bec9fce077a90ac 100644 (file)
@@ -111,11 +111,14 @@ class MovieFapIE(InfoExtractor):
             # multiple formats available
             info['formats'] = []
 
-            # N.B. formats are already in ascending order of quality
             for item in xml.find('quality').findall('item'):
+                resolution = xpath_text(item, 'res', 'resolution', True)  # 480p etc.
                 info['formats'].append({
                     'url': xpath_text(item, 'videoLink', 'url', True),
-                    'resolution': xpath_text(item, 'res', 'resolution', True)  # 480p etc.
+                    'resolution': resolution,
+                    'height': int(re.findall(r'\d+', resolution)[0])
                 })
 
+            self._sort_formats(info['formats'])
+
         return info