|
|
@ -24,7 +24,6 @@ from ..utils import (
|
|
|
|
DownloadError,
|
|
|
|
DownloadError,
|
|
|
|
error_to_compat_str,
|
|
|
|
error_to_compat_str,
|
|
|
|
encodeFilename,
|
|
|
|
encodeFilename,
|
|
|
|
sanitize_open,
|
|
|
|
|
|
|
|
sanitized_Request,
|
|
|
|
sanitized_Request,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -96,7 +95,7 @@ class FragmentFD(FileDownloader):
|
|
|
|
|
|
|
|
|
|
|
|
def _read_ytdl_file(self, ctx):
|
|
|
|
def _read_ytdl_file(self, ctx):
|
|
|
|
assert 'ytdl_corrupt' not in ctx
|
|
|
|
assert 'ytdl_corrupt' not in ctx
|
|
|
|
stream, _ = sanitize_open(self.ytdl_filename(ctx['filename']), 'r')
|
|
|
|
stream, _ = self.sanitize_open(self.ytdl_filename(ctx['filename']), 'r')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
ytdl_data = json.loads(stream.read())
|
|
|
|
ytdl_data = json.loads(stream.read())
|
|
|
|
ctx['fragment_index'] = ytdl_data['downloader']['current_fragment']['index']
|
|
|
|
ctx['fragment_index'] = ytdl_data['downloader']['current_fragment']['index']
|
|
|
@ -108,7 +107,7 @@ class FragmentFD(FileDownloader):
|
|
|
|
stream.close()
|
|
|
|
stream.close()
|
|
|
|
|
|
|
|
|
|
|
|
def _write_ytdl_file(self, ctx):
|
|
|
|
def _write_ytdl_file(self, ctx):
|
|
|
|
frag_index_stream, _ = sanitize_open(self.ytdl_filename(ctx['filename']), 'w')
|
|
|
|
frag_index_stream, _ = self.sanitize_open(self.ytdl_filename(ctx['filename']), 'w')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
downloader = {
|
|
|
|
downloader = {
|
|
|
|
'current_fragment': {
|
|
|
|
'current_fragment': {
|
|
|
@ -140,7 +139,7 @@ class FragmentFD(FileDownloader):
|
|
|
|
return True, self._read_fragment(ctx)
|
|
|
|
return True, self._read_fragment(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
def _read_fragment(self, ctx):
|
|
|
|
def _read_fragment(self, ctx):
|
|
|
|
down, frag_sanitized = sanitize_open(ctx['fragment_filename_sanitized'], 'rb')
|
|
|
|
down, frag_sanitized = self.sanitize_open(ctx['fragment_filename_sanitized'], 'rb')
|
|
|
|
ctx['fragment_filename_sanitized'] = frag_sanitized
|
|
|
|
ctx['fragment_filename_sanitized'] = frag_sanitized
|
|
|
|
frag_content = down.read()
|
|
|
|
frag_content = down.read()
|
|
|
|
down.close()
|
|
|
|
down.close()
|
|
|
@ -216,7 +215,7 @@ class FragmentFD(FileDownloader):
|
|
|
|
self._write_ytdl_file(ctx)
|
|
|
|
self._write_ytdl_file(ctx)
|
|
|
|
assert ctx['fragment_index'] == 0
|
|
|
|
assert ctx['fragment_index'] == 0
|
|
|
|
|
|
|
|
|
|
|
|
dest_stream, tmpfilename = sanitize_open(tmpfilename, open_mode)
|
|
|
|
dest_stream, tmpfilename = self.sanitize_open(tmpfilename, open_mode)
|
|
|
|
|
|
|
|
|
|
|
|
ctx.update({
|
|
|
|
ctx.update({
|
|
|
|
'dl': dl,
|
|
|
|
'dl': dl,
|
|
|
|