aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/music')
-rw-r--r--cogs/music/play_commands.py24
1 files changed, 8 insertions, 16 deletions
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
10from os import PathLike 10from os import PathLike
11from typing import Awaitable, Callable, List, Tuple 11from typing import Awaitable, Callable, List, Tuple
12import re 12import re
13import requests
13from yt_dlp import YoutubeDL 14from yt_dlp import YoutubeDL
14 15
15import discord 16import discord
@@ -228,8 +229,6 @@ class PlayCommands(commands.Cog):
228 229
229 async def _upload_to_copyparty_async(self, file_path: str) -> None: 230 async def _upload_to_copyparty_async(self, file_path: str) -> None:
230 """Upload file to copyparty asynchronously (fire and forget).""" 231 """Upload file to copyparty asynchronously (fire and forget)."""
231 import aiohttp
232
233 try: 232 try:
234 logger.info(f"Starting async upload: {file_path}") 233 logger.info(f"Starting async upload: {file_path}")
235 baseurl = get_uploadurl() 234 baseurl = get_uploadurl()
@@ -243,25 +242,18 @@ class PlayCommands(commands.Cog):
243 with open(file_path, "rb") as f: 242 with open(file_path, "rb") as f:
244 content = f.read() 243 content = f.read()
245 244
246 files = aiohttp.FormData() 245 files = {"f": (os.path.basename(file_path), content, "application/octet-stream")}
247 files.add_field(
248 "f",
249 content,
250 filename=os.path.basename(file_path),
251 content_type="application/octet-stream",
252 )
253 headers = {"Cookie": f"cppwd={password}"} 246 headers = {"Cookie": f"cppwd={password}"}
254 params = {"j": "1", "ck": "b2"} 247 params = {"j": "1", "ck": "b2"}
255 248
256 logger.info(f"Posting to {baseurl}") 249 logger.info(f"Posting to {baseurl}")
257 async with aiohttp.ClientSession() as session: 250 response = requests.post(baseurl, files=files, headers=headers, params=params)
258 async with session.post(baseurl, data=files, headers=headers, params=params) as response: 251 text = response.text
259 text = await response.text() 252 logger.info(f"Upload response: {response.status_code} - {text[:200] if text else 'empty'}")
260 logger.info(f"Upload response: {response.status} - {text[:200] if text else 'empty'}")
261 253
262 if response.status in [200, 201]: 254 if response.status_code in [200, 201]:
263 result = await response.json() 255 result = response.json()
264 logger.info(f"Uploaded to copyparty: {result.get('fileurl')}") 256 logger.info(f"Uploaded to copyparty: {result.get('fileurl')}")
265 except Exception as e: 257 except Exception as e:
266 logger.error(f"Async upload failed: {e}", exc_info=True) 258 logger.error(f"Async upload failed: {e}", exc_info=True)
267 259