summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-11-14 15:10:14 +0100
committerRobert Honz <exislow+github@gmail.com>2024-11-14 15:10:14 +0100
commita9ff6dc558637452e635f5ba44f5842715b41b2d (patch)
treeed1d0f9ed06e3d183ca4b2ad144f28499cd7001b
parent8cb907f908170cf0e46f757c1bd35150e056e36d (diff)
downloadtidal-dl-ng-a9ff6dc558637452e635f5ba44f5842715b41b2d.tar.gz
🛠️ Fixed segment id calculation for BTS tracks. Fixes #232
Fixed GUI crash on trailing / leading spaces in search terms.
-rw-r--r--tidal_dl_ng/download.py6
-rw-r--r--tidal_dl_ng/gui.py2
2 files changed, 6 insertions, 2 deletions
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index 46c0beb..11ee8da 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -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
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py
index 7aa2150..d85c8a0 100644
--- a/tidal_dl_ng/gui.py
+++ b/tidal_dl_ng/gui.py
@@ -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)