🛠️ Fixed segment id calculation for BTS tracks. Fixes #232

Fixed GUI crash on trailing / leading spaces in search terms.
This commit is contained in:
Robert Honz
2024-11-14 15:10:14 +01:00
parent 8cb907f908
commit a9ff6dc558
2 changed files with 6 additions and 2 deletions
+4 -2
View File
@@ -218,7 +218,9 @@ class Download:
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(str(path_segment.stem).split("_")[-1])
filename_stem: str = str(path_segment.stem).split("_")[-1]
# CAUTION: This is a workaround, so BTS (LOW quality) track will work. They usually have only ONE link.
id_segment: int = int(filename_stem) if filename_stem.isdecimal() else 0
error: HTTPError | None = None
# Retry download on failed segments, with an exponential delay between retries
@@ -342,7 +344,7 @@ class Download:
stream_manifest: StreamManifest = media_stream.get_stream_manifest()
if stream_manifest.file_extension is VideoExtensions.TS:
file_extension = stream_manifest.file_extension
elif AudioExtensions.FLAC in stream_manifest.dash_info.first_url:
elif stream_manifest.dash_info and AudioExtensions.FLAC in stream_manifest.dash_info.first_url:
file_extension = AudioExtensions.FLAC
else:
file_extension = AudioExtensions.M4A
+2
View File
@@ -511,6 +511,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self._init_dl()
def search(self, query: str, types_media: SearchTypes) -> [ResultItem]:
query = query.strip()
# If a direct link was searched for, skip search and create the object from the link directly.
if "http" in query:
media_type = get_tidal_media_type(query)