summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tidal_dl_ng/download.py6
-rw-r--r--tidal_dl_ng/model/downloader.py1
2 files changed, 6 insertions, 1 deletions
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index 7876368..b1ff2c6 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -164,6 +164,8 @@ class Download:
# mark the whole thing as corrupt.
result_segments = False
+ # Bring list into right order, so segments can be easily merged.
+ dl_segment_results.sort(key=lambda x: x.id_segment)
# TODO: Implement error handling on corrupt segments (also in the following method.
reult_merge: bool = self._segments_merge(path_file, dl_segment_results)
tmp_path_file_decrypted: pathlib.Path = pathlib.Path("")
@@ -205,6 +207,8 @@ class Download:
) -> DownloadSegmentResult:
result: bool = False
path_segment: pathlib.Path = path_base / url_to_filename(url)
+ # Calculate the segment ID based on the file name within the URL.
+ id_segment: int = int(path_segment.stem)
try:
# Create the request object with stream=True, so the content won't be loaded into memory at once.
@@ -228,7 +232,7 @@ class Download:
if not progress_to_stdout:
self.progress_gui.item.emit(self.progress.tasks[p_task].percentage)
- return DownloadSegmentResult(result, url, path_segment)
+ return DownloadSegmentResult(result=result, url=url, path_segment=path_segment, id_segment=id_segment)
def item(
self,
diff --git a/tidal_dl_ng/model/downloader.py b/tidal_dl_ng/model/downloader.py
index b8c5348..52c8e30 100644
--- a/tidal_dl_ng/model/downloader.py
+++ b/tidal_dl_ng/model/downloader.py
@@ -7,3 +7,4 @@ class DownloadSegmentResult:
result: bool
url: str
path_segment: pathlib.Path
+ id_segment: int