]>
jfr.im git - yt-dlp.git/blob - yt_dlp/downloader/dash.py
881ef3a1d3d6380c398689c1885d3f8c285dd8a9
1 from __future__
import unicode_literals
3 from ..downloader
import get_suitable_downloader
4 from .fragment
import FragmentFD
6 from ..utils
import urljoin
9 class DashSegmentsFD(FragmentFD
):
11 Download segments in a DASH manifest. External downloaders can take over
12 the fragment downloads by supporting the 'dash_frag_urls' protocol
15 FD_NAME
= 'dashsegments'
17 def real_download(self
, filename
, info_dict
):
18 if info_dict
.get('is_live'):
19 self
.report_error('Live DASH videos are not supported')
21 fragment_base_url
= info_dict
.get('fragment_base_url')
22 fragments
= info_dict
['fragments'][:1] if self
.params
.get(
23 'test', False) else info_dict
['fragments']
25 real_downloader
= get_suitable_downloader(
26 info_dict
, self
.params
, None, protocol
='dash_frag_urls', to_stdout
=(filename
== '-'))
30 'total_frags': len(fragments
),
34 self
._prepare
_external
_frag
_download
(ctx
)
36 self
._prepare
_and
_start
_frag
_download
(ctx
, info_dict
)
38 fragments_to_download
= []
40 for i
, fragment
in enumerate(fragments
):
42 if frag_index
<= ctx
['fragment_index']:
44 fragment_url
= fragment
.get('url')
46 assert fragment_base_url
47 fragment_url
= urljoin(fragment_base_url
, fragment
['path'])
49 fragments_to_download
.append({
50 'frag_index': frag_index
,
57 '[%s] Fragment downloads will be delegated to %s' % (self
.FD_NAME
, real_downloader
.get_basename()))
58 info_copy
= info_dict
.copy()
59 info_copy
['fragments'] = fragments_to_download
60 fd
= real_downloader(self
.ydl
, self
.params
)
61 return fd
.real_download(filename
, info_copy
)
63 return self
.download_and_append_fragments(ctx
, fragments_to_download
, info_dict
)