[multipart] add simple implementation for a multipart downloader
This commit is contained in:
parent
62b1a97496
commit
f48137f157
@ -9,6 +9,7 @@ from .http import HttpFD
|
|||||||
from .rtsp import RtspFD
|
from .rtsp import RtspFD
|
||||||
from .rtmp import RtmpFD
|
from .rtmp import RtmpFD
|
||||||
from .dash import DashSegmentsFD
|
from .dash import DashSegmentsFD
|
||||||
|
from .multipart import MultiPartFD
|
||||||
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_protocol,
|
determine_protocol,
|
||||||
@ -22,6 +23,7 @@ PROTOCOL_MAP = {
|
|||||||
'rtsp': RtspFD,
|
'rtsp': RtspFD,
|
||||||
'f4m': F4mFD,
|
'f4m': F4mFD,
|
||||||
'http_dash_segments': DashSegmentsFD,
|
'http_dash_segments': DashSegmentsFD,
|
||||||
|
'multipart': MultiPartFD,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
29
youtube_dl/downloader/multipart.py
Normal file
29
youtube_dl/downloader/multipart.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from .common import FileDownloader
|
||||||
|
|
||||||
|
from ..utils import prepend_extension
|
||||||
|
|
||||||
|
|
||||||
|
class MultiPartFD(FileDownloader):
|
||||||
|
|
||||||
|
FD_NAME = 'multipart'
|
||||||
|
|
||||||
|
def real_download(self, filename, info_dict):
|
||||||
|
parts = info_dict['parts']
|
||||||
|
self.to_screen('[%s] Total parts: %d' % (self.FD_NAME, len(parts)))
|
||||||
|
|
||||||
|
for i in range(len(parts)):
|
||||||
|
fd = get_suitable_downloader(parts[i], self.params)(self.ydl, self.params)
|
||||||
|
frag_filename = prepend_extension(filename, 'part%d' % i)
|
||||||
|
success = fd.download(frag_filename, parts[i])
|
||||||
|
if not success:
|
||||||
|
return False
|
||||||
|
# We only download the first fragment during the test
|
||||||
|
if self.params.get('test', False):
|
||||||
|
break
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
# workaround circular imports
|
||||||
|
from .__init__ import get_suitable_downloader
|
@ -1891,6 +1891,8 @@ def determine_protocol(info_dict):
|
|||||||
if protocol is not None:
|
if protocol is not None:
|
||||||
return protocol
|
return protocol
|
||||||
|
|
||||||
|
if 'parts' in info_dict:
|
||||||
|
return 'multipart'
|
||||||
url = info_dict['url']
|
url = info_dict['url']
|
||||||
if url.startswith('rtmp'):
|
if url.startswith('rtmp'):
|
||||||
return 'rtmp'
|
return 'rtmp'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user