mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-23 17:35:07 +00:00
Compare commits
2
Commits
39f5bc2a9e
...
03bcfc0c45
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03bcfc0c45 | ||
|
|
efb560f887 |
@@ -740,11 +740,19 @@ class HLS:
|
||||
delete: Delete the file once it's been merged.
|
||||
include_map_data: Whether to include the init map data.
|
||||
"""
|
||||
prepend = include_map_data and map_data and map_data[1]
|
||||
if len(via) == 1 and not prepend and delete:
|
||||
try:
|
||||
os.replace(via[0], to)
|
||||
return
|
||||
except OSError:
|
||||
pass
|
||||
with open(to, "wb") as x:
|
||||
if include_map_data and map_data and map_data[1]:
|
||||
if prepend:
|
||||
x.write(map_data[1])
|
||||
for file in via:
|
||||
x.write(file.read_bytes())
|
||||
with open(file, "rb") as segment:
|
||||
shutil.copyfileobj(segment, x, 1024 * 1024)
|
||||
x.flush()
|
||||
if delete:
|
||||
file.unlink()
|
||||
@@ -1005,8 +1013,8 @@ class HLS:
|
||||
else:
|
||||
with open(save_path, "wb") as f:
|
||||
for discontinuity_file in segments_to_merge:
|
||||
discontinuity_data = discontinuity_file.read_bytes()
|
||||
f.write(discontinuity_data)
|
||||
with open(discontinuity_file, "rb") as src:
|
||||
shutil.copyfileobj(src, f, 1024 * 1024)
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
discontinuity_file.unlink()
|
||||
|
||||
Reference in New Issue
Block a user