Fix search and add JS runtime.
This commit is contained in:
@@ -436,11 +436,15 @@ async def process_radio_track(video_link, video_id, title):
|
||||
|
||||
dl_cmd = [
|
||||
"yt-dlp",
|
||||
"--cache-dir", "/usr/src/app/.cache",
|
||||
"--cache-dir",
|
||||
"/usr/src/app/.cache",
|
||||
"--extract-audio",
|
||||
"--embed-metadata",
|
||||
"--embed-thumbnail",
|
||||
"--convert-thumbnails", "jpg",
|
||||
"--convert-thumbnails",
|
||||
"jpg",
|
||||
"--js-runtimes",
|
||||
"quickjs",
|
||||
"--output",
|
||||
f"{base_filepath}.%(ext)s",
|
||||
video_link,
|
||||
@@ -508,19 +512,20 @@ async def process_radio_track(video_link, video_id, title):
|
||||
stderr=asyncio.subprocess.DEVNULL,
|
||||
)
|
||||
search_out, _ = await search_proc.communicate()
|
||||
|
||||
search_data = json.loads(search_out.decode())
|
||||
if (
|
||||
isinstance(search_data, dict)
|
||||
and "rows" in search_data
|
||||
and len(search_data["rows"]) > 0
|
||||
):
|
||||
unique_id = unique_id or search_data["rows"][0].get("unique_id")
|
||||
azura_path = azura_path or search_data["rows"][0].get("path")
|
||||
elif isinstance(search_data, list) and len(search_data) > 0:
|
||||
unique_id = unique_id or search_data[0].get("unique_id")
|
||||
azura_path = azura_path or search_data[0].get("path")
|
||||
|
||||
# Normalize the data list whether it's wrapped in "rows" or is a raw array
|
||||
file_list = (
|
||||
search_data.get("rows", [])
|
||||
if isinstance(search_data, dict)
|
||||
else (search_data if isinstance(search_data, list) else [])
|
||||
)
|
||||
for item in file_list:
|
||||
item_path = item.get("path", "")
|
||||
# Match the specific filename we just uploaded
|
||||
if item_path == filename or item_path.endswith(f"/{filename}"):
|
||||
unique_id = unique_id or item.get("unique_id")
|
||||
azura_path = azura_path or item.get("path")
|
||||
break
|
||||
except json.JSONDecodeError:
|
||||
print(f"❌ Failed to parse AzuraCast upload response")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user