From a769cf0ac5c20a2f4b4cb72bab3ed438480d9a98 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 16 May 2026 18:07:07 +0200 Subject: fix naming not resolving things like %20 Signed-off-by: salmonik --- cogs/music/play_commands.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'cogs/music') diff --git a/cogs/music/play_commands.py b/cogs/music/play_commands.py index bdb021d..80a30ef 100644 --- a/cogs/music/play_commands.py +++ b/cogs/music/play_commands.py @@ -10,6 +10,7 @@ import asyncio from os import PathLike from typing import Awaitable, Callable, List, Tuple import re +import requests from yt_dlp import YoutubeDL import discord @@ -228,8 +229,6 @@ class PlayCommands(commands.Cog): async def _upload_to_copyparty_async(self, file_path: str) -> None: """Upload file to copyparty asynchronously (fire and forget).""" - import aiohttp - try: logger.info(f"Starting async upload: {file_path}") baseurl = get_uploadurl() @@ -243,25 +242,18 @@ class PlayCommands(commands.Cog): with open(file_path, "rb") as f: content = f.read() - files = aiohttp.FormData() - files.add_field( - "f", - content, - filename=os.path.basename(file_path), - content_type="application/octet-stream", - ) + files = {"f": (os.path.basename(file_path), content, "application/octet-stream")} headers = {"Cookie": f"cppwd={password}"} params = {"j": "1", "ck": "b2"} logger.info(f"Posting to {baseurl}") - async with aiohttp.ClientSession() as session: - async with session.post(baseurl, data=files, headers=headers, params=params) as response: - text = await response.text() - logger.info(f"Upload response: {response.status} - {text[:200] if text else 'empty'}") + response = requests.post(baseurl, files=files, headers=headers, params=params) + text = response.text + logger.info(f"Upload response: {response.status_code} - {text[:200] if text else 'empty'}") - if response.status in [200, 201]: - result = await response.json() - logger.info(f"Uploaded to copyparty: {result.get('fileurl')}") + if response.status_code in [200, 201]: + result = response.json() + logger.info(f"Uploaded to copyparty: {result.get('fileurl')}") except Exception as e: logger.error(f"Async upload failed: {e}", exc_info=True) -- cgit v1.2.3