mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 20:45:11 +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.
|
delete: Delete the file once it's been merged.
|
||||||
include_map_data: Whether to include the init map data.
|
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:
|
with open(to, "wb") as x:
|
||||||
if include_map_data and map_data and map_data[1]:
|
if prepend:
|
||||||
x.write(map_data[1])
|
x.write(map_data[1])
|
||||||
for file in via:
|
for file in via:
|
||||||
x.write(file.read_bytes())
|
with open(file, "rb") as segment:
|
||||||
|
shutil.copyfileobj(segment, x, 1024 * 1024)
|
||||||
x.flush()
|
x.flush()
|
||||||
if delete:
|
if delete:
|
||||||
file.unlink()
|
file.unlink()
|
||||||
@@ -1005,8 +1013,8 @@ class HLS:
|
|||||||
else:
|
else:
|
||||||
with open(save_path, "wb") as f:
|
with open(save_path, "wb") as f:
|
||||||
for discontinuity_file in segments_to_merge:
|
for discontinuity_file in segments_to_merge:
|
||||||
discontinuity_data = discontinuity_file.read_bytes()
|
with open(discontinuity_file, "rb") as src:
|
||||||
f.write(discontinuity_data)
|
shutil.copyfileobj(src, f, 1024 * 1024)
|
||||||
f.flush()
|
f.flush()
|
||||||
os.fsync(f.fileno())
|
os.fsync(f.fileno())
|
||||||
discontinuity_file.unlink()
|
discontinuity_file.unlink()
|
||||||
|
|||||||
Reference in New Issue
Block a user