🛠️ Fixed segment order after download.
This commit is contained in:
@@ -164,6 +164,8 @@ class Download:
|
|||||||
# mark the whole thing as corrupt.
|
# mark the whole thing as corrupt.
|
||||||
result_segments = False
|
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.
|
# TODO: Implement error handling on corrupt segments (also in the following method.
|
||||||
reult_merge: bool = self._segments_merge(path_file, dl_segment_results)
|
reult_merge: bool = self._segments_merge(path_file, dl_segment_results)
|
||||||
tmp_path_file_decrypted: pathlib.Path = pathlib.Path("")
|
tmp_path_file_decrypted: pathlib.Path = pathlib.Path("")
|
||||||
@@ -205,6 +207,8 @@ class Download:
|
|||||||
) -> DownloadSegmentResult:
|
) -> DownloadSegmentResult:
|
||||||
result: bool = False
|
result: bool = False
|
||||||
path_segment: pathlib.Path = path_base / url_to_filename(url)
|
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:
|
try:
|
||||||
# Create the request object with stream=True, so the content won't be loaded into memory at once.
|
# 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:
|
if not progress_to_stdout:
|
||||||
self.progress_gui.item.emit(self.progress.tasks[p_task].percentage)
|
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(
|
def item(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ class DownloadSegmentResult:
|
|||||||
result: bool
|
result: bool
|
||||||
url: str
|
url: str
|
||||||
path_segment: pathlib.Path
|
path_segment: pathlib.Path
|
||||||
|
id_segment: int
|
||||||
|
|||||||
Reference in New Issue
Block a user