pre-migration commit
This commit is contained in:
+41
-8
@@ -3,11 +3,37 @@ from __future__ import annotations
|
||||
from typing import Any, Dict, List, Optional, Set
|
||||
|
||||
from .base import API, ApiError
|
||||
from SYS.logger import debug
|
||||
from SYS.logger import debug, debug_panel
|
||||
|
||||
DEFAULT_BASE_URL = "https://tidal-api.binimum.org"
|
||||
|
||||
|
||||
def _debug_payload_summary(title: str, payload: Any) -> None:
|
||||
try:
|
||||
keys = list(payload.keys()) if isinstance(payload, dict) else []
|
||||
except Exception:
|
||||
keys = []
|
||||
|
||||
preview = ", ".join(str(key) for key in keys[:8]) if keys else "<none>"
|
||||
if keys and len(keys) > 8:
|
||||
preview = f"{preview}, ..."
|
||||
|
||||
try:
|
||||
payload_size = len(str(payload))
|
||||
except Exception:
|
||||
payload_size = "<unknown>"
|
||||
|
||||
debug_panel(
|
||||
title,
|
||||
[
|
||||
("type", type(payload).__name__),
|
||||
("keys", preview),
|
||||
("size", payload_size),
|
||||
],
|
||||
border_style="cyan",
|
||||
)
|
||||
|
||||
|
||||
def stringify(value: Any) -> str:
|
||||
"""Helper to ensure we have a stripped string or empty."""
|
||||
return str(value or "").strip()
|
||||
@@ -242,14 +268,14 @@ class Tidal(API):
|
||||
|
||||
# 1. Fetch info (metadata) - fetch raw to ensure all fields are available for merging
|
||||
info_resp = self._get_json("info/", params={"id": track_int})
|
||||
debug(f"[API.Tidal] info_resp (len={len(str(info_resp))}): {info_resp}")
|
||||
_debug_payload_summary("API.Tidal info", info_resp)
|
||||
info_data = info_resp.get("data") if isinstance(info_resp, dict) else info_resp
|
||||
if not isinstance(info_data, dict) or "id" not in info_data:
|
||||
info_data = info_resp if isinstance(info_resp, dict) and "id" in info_resp else {}
|
||||
|
||||
# 2. Fetch track (manifest/bit depth)
|
||||
track_resp = self.track(track_id)
|
||||
debug(f"[API.Tidal] track_resp (len={len(str(track_resp))}): {track_resp}")
|
||||
_debug_payload_summary("API.Tidal track", track_resp)
|
||||
# Note: track() method in this class currently returns raw JSON, so we handle it similarly.
|
||||
track_data = track_resp.get("data") if isinstance(track_resp, dict) else track_resp
|
||||
if not isinstance(track_data, dict):
|
||||
@@ -259,7 +285,7 @@ class Tidal(API):
|
||||
lyrics_data = {}
|
||||
try:
|
||||
lyr_resp = self.lyrics(track_id)
|
||||
debug(f"[API.Tidal] lyrics_resp (len={len(str(lyr_resp))}): {lyr_resp}")
|
||||
_debug_payload_summary("API.Tidal lyrics", lyr_resp)
|
||||
lyrics_data = lyr_resp.get("lyrics") or lyr_resp if isinstance(lyr_resp, dict) else {}
|
||||
except Exception:
|
||||
pass
|
||||
@@ -271,11 +297,8 @@ class Tidal(API):
|
||||
if isinstance(track_data, dict):
|
||||
merged_md.update(track_data)
|
||||
|
||||
debug(f"[API.Tidal] merged_md keys: {list(merged_md.keys())}")
|
||||
|
||||
# Derived tags and normalized/parsed info
|
||||
tags = build_track_tags(merged_md)
|
||||
debug(f"[API.Tidal] generated tags: {tags}")
|
||||
parsed_info = parse_track_item(merged_md)
|
||||
|
||||
# Structure for return
|
||||
@@ -285,7 +308,17 @@ class Tidal(API):
|
||||
"tags": list(tags),
|
||||
"lyrics": lyrics_data,
|
||||
}
|
||||
debug(f"[API.Tidal] returning full_track_metadata keys: {list(res.keys())}")
|
||||
debug_panel(
|
||||
"API.Tidal full track metadata",
|
||||
[
|
||||
("track_id", track_int),
|
||||
("metadata_keys", len(merged_md)),
|
||||
("tags", len(tags)),
|
||||
("has_lyrics", bool(lyrics_data)),
|
||||
("result_keys", ", ".join(res.keys())),
|
||||
],
|
||||
border_style="cyan",
|
||||
)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
"(rapidgator\\.net/file/[0-9]{7,8})"
|
||||
],
|
||||
"regexp": "((rapidgator\\.net|rg\\.to|rapidgator\\.asia)/file/([0-9a-zA-Z]{32}))|((rapidgator\\.net/file/[0-9]{7,8}))",
|
||||
"status": false
|
||||
"status": true
|
||||
},
|
||||
"turbobit": {
|
||||
"name": "turbobit",
|
||||
@@ -463,7 +463,7 @@
|
||||
"isra\\.cloud/\\?op=report_file&id=([0-9a-zA-Z]{12})"
|
||||
],
|
||||
"regexp": "((isra\\.cloud/[0-9a-zA-Z]{12}))|(isra\\.cloud/\\?op=report_file&id=([0-9a-zA-Z]{12}))",
|
||||
"status": false,
|
||||
"status": true,
|
||||
"hardRedirect": [
|
||||
"isra\\.cloud/([0-9a-zA-Z]{12})"
|
||||
]
|
||||
@@ -494,7 +494,7 @@
|
||||
"mediafire\\.com/(\\?|download/|file/|download\\.php\\?)([0-9a-z]{15})"
|
||||
],
|
||||
"regexp": "mediafire\\.com/(\\?|download/|file/|download\\.php\\?)([0-9a-z]{15})",
|
||||
"status": true
|
||||
"status": false
|
||||
},
|
||||
"mixdrop": {
|
||||
"name": "mixdrop",
|
||||
|
||||
Reference in New Issue
Block a user