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 a90f901..c6a55b0 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
@@ -229,8 +230,6 @@ class PlayCommands(commands.Cog):
229 230
230 async def _upload_to_copyparty_async(self, file_path: str) -> None: 231 async def _upload_to_copyparty_async(self, file_path: str) -> None:
231 """Upload file to copyparty asynchronously (fire and forget).""" 232 """Upload file to copyparty asynchronously (fire and forget)."""
232 import aiohttp
233
234 try: 233 try:
235 logger.info(f"Starting async upload: {file_path}") 234 logger.info(f"Starting async upload: {file_path}")
236 baseurl = get_uploadurl() 235 baseurl = get_uploadurl()
@@ -244,25 +243,18 @@ class PlayCommands(commands.Cog):
244 with open(file_path, "rb") as f: 243 with open(file_path, "rb") as f:
245 content = f.read() 244 content = f.read()
246 245
247 files = aiohttp.FormData() 246 files = {"f": (os.path.basename(file_path), content, "application/octet-stream")}
248 files.add_field(
249 "f",
250 content,
251 filename=os.path.basename(file_path),
252 content_type="application/octet-stream",
253 )
254 headers = {"Cookie": f"cppwd={password}"} 247 headers = {"Cookie": f"cppwd={password}"}
255 params = {"j": "1", "ck": "b2"} 248 params = {"j": "1", "ck": "b2"}
256 249
257 logger.info(f"Posting to {baseurl}") 250 logger.info(f"Posting to {baseurl}")
258 async with aiohttp.ClientSession() as session: 251 response = requests.post(baseurl, files=files, headers=headers, params=params)
259 async with session.post(baseurl, data=files, headers=headers, params=params) as response: 252 text = response.text
260 text = await response.text() 253 logger.info(f"Upload response: {response.status_code} - {text[:200] if text else 'empty'}")
261 logger.info(f"Upload response: {response.status} - {text[:200] if text else 'empty'}")
262 254
263 if response.status in [200, 201]: 255 if response.status_code in [200, 201]:
264 result = await response.json() 256 result = response.json()
265 logger.info(f"Uploaded to copyparty: {result.get('fileurl')}") 257 logger.info(f"Uploaded to copyparty: {result.get('fileurl')}")
266 except Exception as e: 258 except Exception as e:
267 logger.error(f"Async upload failed: {e}", exc_info=True) 259 logger.error(f"Async upload failed: {e}", exc_info=True)
268 260