[videomega] Simplify (#3786)
authorPhilipp Hagemeister <phihag@phihag.de>
Wed, 17 Sep 2014 22:18:27 +0000 (00:18 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Wed, 17 Sep 2014 22:19:08 +0000 (00:19 +0200)
* Use raw strings (r'foo') for regular expressions (enables highlighting and avoids some errors).
* title is always true-ish

youtube_dl/extractor/videomega.py

index 1b6b658398874c175e9253ff9e9ac31c0be1b6d7..29c4e0101ec21eb59c22de9739a516b9f96c0e0f 100644 (file)
@@ -34,22 +34,20 @@ class VideoMegaIE(InfoExtractor):
         webpage = self._download_webpage(url, video_id)
 
         escaped_data = self._search_regex(
-            'unescape\("([^"]+)"\)', webpage, 'escaped data')
+            r'unescape\("([^"]+)"\)', webpage, 'escaped data')
         playlist = compat_urllib_parse.unquote(escaped_data)
 
         thumbnail = self._search_regex(
             r'image:\s*"([^"]+)"', playlist, 'thumbnail', fatal=False)
         url = self._search_regex(r'file:\s*"([^"]+)"', playlist, 'URL')
-        title = self._html_search_regex(
-            r'<title>(.*?)</title>', webpage, 'title')
-        if title:
-            title = remove_start(title, 'VideoMega.tv - ')
+        title = remove_start(self._html_search_regex(
+            r'<title>(.*?)</title>', webpage, 'title'), 'VideoMega.tv - ')
 
-        formats = []
-        formats.append({
+        formats = [{
             'format_id': 'sd',
             'url': url,
-        })
+        }]
+        self._sort_formats(formats)
 
         return {
             'id': video_id,