summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/gui.py
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2025-09-07 18:27:30 +0200
committerRobert Honz <exislow+github@gmail.com>2025-09-07 18:27:30 +0200
commit541527be322a73e4ecdef215e04dc0a040250063 (patch)
tree9faec435eb0db7a8ae018ca886050c485eab3ed7 /tidal_dl_ng/gui.py
parent47b1f2a6692d0981afa9e1d9708e71e7f41b37cc (diff)
downloadtidal-dl-ng-541527be322a73e4ecdef215e04dc0a040250063.tar.gz
feat(tidal): ✨ add url_ending_clean function and refactor URL handling. Fixes #523
* Introduced `url_ending_clean` to sanitize URLs by removing trailing "/u" or "?u". * Updated `_process_url` and GUI search logic to utilize cleaned URLs for better validation and processing.
Diffstat (limited to 'tidal_dl_ng/gui.py')
-rw-r--r--tidal_dl_ng/gui.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py
index 6263c76..20742a2 100644
--- a/tidal_dl_ng/gui.py
+++ b/tidal_dl_ng/gui.py
@@ -77,6 +77,7 @@ from tidal_dl_ng.helper.tidal import (
name_builder_title,
quality_audio_highest,
search_results_all,
+ url_ending_clean,
user_media_lists,
)
@@ -743,12 +744,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
Returns:
list[ResultItem]: The search results.
"""
- query = query.strip()
+ query_clean: str = 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)
- item_id = get_tidal_media_id(query)
+ if "http" in query_clean:
+ query_clean: str = url_ending_clean(query_clean)
+ media_type = get_tidal_media_type(query_clean)
+ item_id = get_tidal_media_id(query_clean)
try:
media = instantiate_media(self.tidal.session, media_type, item_id)
@@ -760,7 +762,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
result_search = {"direct": [media]}
else:
result_search: dict[str, list[SearchTypes]] = search_results_all(
- session=self.tidal.session, needle=query, types_media=types_media
+ session=self.tidal.session, needle=query_clean, types_media=types_media
)
result: list[ResultItem] = []