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.
This commit is contained in:
@@ -41,6 +41,7 @@ def name_builder_item(media: Track | Video) -> str:
|
||||
|
||||
|
||||
def get_tidal_media_id(url_or_id_media: str) -> str:
|
||||
|
||||
id_dirty = url_or_id_media.rsplit("/", 1)[-1]
|
||||
id_media = id_dirty.rsplit("?", 1)[0]
|
||||
|
||||
@@ -70,6 +71,18 @@ def get_tidal_media_type(url_media: str) -> MediaType | bool:
|
||||
return result
|
||||
|
||||
|
||||
def url_ending_clean(url: str) -> str:
|
||||
"""Checks if a link ends with "/u" or "?u" and removes that part.
|
||||
|
||||
Args:
|
||||
url (str): The URL to clean.
|
||||
|
||||
Returns:
|
||||
str: The cleaned URL.
|
||||
"""
|
||||
return url[:-2] if url.endswith("/u") or url.endswith("?u") else url
|
||||
|
||||
|
||||
def search_results_all(session: Session, needle: str, types_media: SearchTypes = None) -> dict[str, [SearchTypes]]:
|
||||
limit: int = 300
|
||||
offset: int = 0
|
||||
|
||||
Reference in New Issue
Block a user