mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 00:00:43 +01:00
[f4m] Tolerate missed fragments on live streams
This commit is contained in:
parent
c4f8c453ae
commit
5eaaeb7c31
@ -11,6 +11,7 @@ from .common import FileDownloader
|
|||||||
from .http import HttpFD
|
from .http import HttpFD
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
|
compat_urllib_error,
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
struct_pack,
|
struct_pack,
|
||||||
@ -389,6 +390,7 @@ class F4mFD(FileDownloader):
|
|||||||
if akamai_pv:
|
if akamai_pv:
|
||||||
url += '?' + akamai_pv.strip(';')
|
url += '?' + akamai_pv.strip(';')
|
||||||
frag_filename = '%s-%s' % (tmpfilename, name)
|
frag_filename = '%s-%s' % (tmpfilename, name)
|
||||||
|
try:
|
||||||
success = http_dl.download(frag_filename, {'url': url})
|
success = http_dl.download(frag_filename, {'url': url})
|
||||||
if not success:
|
if not success:
|
||||||
return False
|
return False
|
||||||
@ -400,11 +402,26 @@ class F4mFD(FileDownloader):
|
|||||||
if box_type == b'mdat':
|
if box_type == b'mdat':
|
||||||
dest_stream.write(box_data)
|
dest_stream.write(box_data)
|
||||||
break
|
break
|
||||||
|
if live:
|
||||||
|
os.remove(frag_filename)
|
||||||
|
else:
|
||||||
frags_filenames.append(frag_filename)
|
frags_filenames.append(frag_filename)
|
||||||
|
except (compat_urllib_error.HTTPError, ) as err:
|
||||||
|
if live and (err.code == 404 or err.code == 410):
|
||||||
|
# We didn't keep up with the live window. Continue
|
||||||
|
# with the next available fragment.
|
||||||
|
msg = 'Fragment %d unavailable' % frag_i
|
||||||
|
self.report_warning(msg)
|
||||||
|
fragments_list = []
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
if not fragments_list and live and bootstrap_url:
|
if not fragments_list and live and bootstrap_url:
|
||||||
fragments_list = self._update_live_fragments(bootstrap_url, frag_i)
|
fragments_list = self._update_live_fragments(bootstrap_url, frag_i)
|
||||||
self.to_screen('Updated available fragments: %d' % len(fragments_list))
|
total_frags += len(fragments_list)
|
||||||
|
if fragments_list and (fragments_list[0][1] > frag_i + 1):
|
||||||
|
msg = 'Missed %d fragments' % (fragments_list[0][1] - (frag_i + 1))
|
||||||
|
self.report_warning(msg)
|
||||||
|
|
||||||
dest_stream.close()
|
dest_stream.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user