mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 16:36:48 +00:00
[mixcloud] Output downloading progress
This commit is contained in:
parent
5f58165def
commit
62a164e713
@ -33,22 +33,22 @@ class MixcloudIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_urls(self, url_list):
|
def _get_url(self, track_id, template_url):
|
||||||
"""Returns 1st active url from list"""
|
server_count = 30
|
||||||
for url in url_list:
|
for i in range(server_count):
|
||||||
|
url = template_url % i
|
||||||
try:
|
try:
|
||||||
# We only want to know if the request succeed
|
# We only want to know if the request succeed
|
||||||
# don't download the whole file
|
# don't download the whole file
|
||||||
self._request_webpage(HEADRequest(url), None, False)
|
self._request_webpage(
|
||||||
|
HEADRequest(url), track_id,
|
||||||
|
'Checking URL %d/%d ...' % (i + 1, server_count + 1))
|
||||||
return url
|
return url
|
||||||
except ExtractorError:
|
except ExtractorError:
|
||||||
url = None
|
pass
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_url(self, template_url):
|
|
||||||
return self.check_urls(template_url % i for i in range(30))
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
uploader = mobj.group(1)
|
uploader = mobj.group(1)
|
||||||
@ -61,11 +61,11 @@ class MixcloudIE(InfoExtractor):
|
|||||||
r'\s(?:data-preview-url|m-preview)="(.+?)"', webpage, 'preview url')
|
r'\s(?:data-preview-url|m-preview)="(.+?)"', webpage, 'preview url')
|
||||||
song_url = preview_url.replace('/previews/', '/c/originals/')
|
song_url = preview_url.replace('/previews/', '/c/originals/')
|
||||||
template_url = re.sub(r'(stream\d*)', 'stream%d', song_url)
|
template_url = re.sub(r'(stream\d*)', 'stream%d', song_url)
|
||||||
final_song_url = self._get_url(template_url)
|
final_song_url = self._get_url(track_id, template_url)
|
||||||
if final_song_url is None:
|
if final_song_url is None:
|
||||||
self.to_screen('Trying with m4a extension')
|
self.to_screen('Trying with m4a extension')
|
||||||
template_url = template_url.replace('.mp3', '.m4a').replace('originals/', 'm4a/64/')
|
template_url = template_url.replace('.mp3', '.m4a').replace('originals/', 'm4a/64/')
|
||||||
final_song_url = self._get_url(template_url)
|
final_song_url = self._get_url(track_id, template_url)
|
||||||
if final_song_url is None:
|
if final_song_url is None:
|
||||||
raise ExtractorError('Unable to extract track url')
|
raise ExtractorError('Unable to extract track url')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user