Explorar o código

[soundcloud] Support for listing of audio-only files

Philipp Hagemeister %!s(int64=11) %!d(string=hai) anos
pai
achega
fb04e40396
Modificáronse 2 ficheiros con 8 adicións e 1 borrados
  1. 4 1
      youtube_dl/YoutubeDL.py
  2. 4 0
      youtube_dl/extractor/soundcloud.py

+ 4 - 1
youtube_dl/YoutubeDL.py

@@ -875,6 +875,8 @@ class YoutubeDL(object):
 
 
     @staticmethod
     @staticmethod
     def format_resolution(format, default='unknown'):
     def format_resolution(format, default='unknown'):
+        if format.get('vcodec') == 'none':
+            return 'audio only'
         if format.get('_resolution') is not None:
         if format.get('_resolution') is not None:
             return format['_resolution']
             return format['_resolution']
         if format.get('height') is not None:
         if format.get('height') is not None:
@@ -891,7 +893,8 @@ class YoutubeDL(object):
             res = u''
             res = u''
             if fdict.get('format_note') is not None:
             if fdict.get('format_note') is not None:
                 res += fdict['format_note'] + u' '
                 res += fdict['format_note'] + u' '
-            if fdict.get('vcodec') is not None:
+            if (fdict.get('vcodec') is not None and
+                    fdict.get('vcodec') != 'none'):
                 res += u'%-5s' % fdict['vcodec']
                 res += u'%-5s' % fdict['vcodec']
             elif fdict.get('vbr') is not None:
             elif fdict.get('vbr') is not None:
                 res += u'video'
                 res += u'video'

+ 4 - 0
youtube_dl/extractor/soundcloud.py

@@ -100,6 +100,7 @@ class SoundcloudIE(InfoExtractor):
                 'format_id': 'download',
                 'format_id': 'download',
                 'ext': ext,
                 'ext': ext,
                 'url': format_url,
                 'url': format_url,
+                'vcodec': 'none',
             }]
             }]
         else:
         else:
             # We have to retrieve the url
             # We have to retrieve the url
@@ -115,6 +116,7 @@ class SoundcloudIE(InfoExtractor):
                         'format_id': key,
                         'format_id': key,
                         'ext': ext,
                         'ext': ext,
                         'url': stream_url,
                         'url': stream_url,
+                        'vcodec': 'none',
                     })
                     })
                 elif key.startswith(u'rtmp'):
                 elif key.startswith(u'rtmp'):
                     # The url doesn't have an rtmp app, we have to extract the playpath
                     # The url doesn't have an rtmp app, we have to extract the playpath
@@ -124,6 +126,7 @@ class SoundcloudIE(InfoExtractor):
                         'url': url,
                         'url': url,
                         'play_path': 'mp3:' + path,
                         'play_path': 'mp3:' + path,
                         'ext': ext,
                         'ext': ext,
+                        'vcodec': 'none',
                     })
                     })
 
 
             if not formats:
             if not formats:
@@ -133,6 +136,7 @@ class SoundcloudIE(InfoExtractor):
                     'format_id': u'fallback',
                     'format_id': u'fallback',
                     'url': info['stream_url'] + '?client_id=' + self._CLIENT_ID,
                     'url': info['stream_url'] + '?client_id=' + self._CLIENT_ID,
                     'ext': ext,
                     'ext': ext,
+                    'vcodec': 'none',
                 })
                 })
 
 
             def format_pref(f):
             def format_pref(f):