Chunked decryption, resume & selection fixes

Implement chunked decryption of .m4s segments (avoid loading entire stream into memory) by changing decrypt() to accept a segment directory, process ~1GB chunks with mp4ff-decrypt, and concatenate results. Add resume support in segment downloader by skipping already downloaded .m4s files and initializing successful counter accordingly. Improve manifest handling: gracefully handle missing AVC/HEVC tracks, bruteforce ticks conditionally, and mark representations for removal when no valid tick is found. Add fallback unfiltered selection in select_track when filtered lookup yields no candidates. Replace naive UTC offset logic with explicit Europe/Paris timezone utilities and adjust related time conversion signatures. Bump project version to 1.0.
This commit is contained in:
√(noham)²
2026-06-17 16:49:49 +02:00
parent 4b524b2ead
commit e51a108d28
7 changed files with 189 additions and 84 deletions

View File

@@ -456,8 +456,19 @@ async def save_segments(
# Build list of all segments to download
segments_to_download = [(start_tick + i * duration, i) for i in range(rep_nb)]
# In case of resuming, check which segments are already downloaded
already_downloaded = [
int(f.split(".")[0])
for f in os.listdir(f"{output_folder}/segments_{track_id}")
if f.endswith(".m4s") and f.split(".")[0].isdigit()
]
segments_to_download = [
(tick, rep) for tick, rep in segments_to_download if tick not in already_downloaded
]
retry_list = []
successful = 0
successful = len(already_downloaded)
async with aiohttp.ClientSession() as session:
# Process segments in batches