Dockerization + ai review recomendations.

This commit is contained in:
2025-10-29 14:57:43 +01:00
parent c4fa88e8ee
commit f9ad679833
18 changed files with 937 additions and 293 deletions
+20 -5
View File
@@ -17,11 +17,16 @@ from constants import (
SEND_MP3,
SPOTIFY_CTRL,
YOUTUBE_AUTH,
service_headers,
)
from spotify_dl import spotify
from spotify_dl import youtube as youtube_download
SERVICE_HEADERS = service_headers()
MUSIC_ROOT = Path(MUSIC_FOLDER)
class MusicFileList(object):
"""
@@ -43,11 +48,15 @@ class MusicFileList(object):
"""
try:
self.logger.info("Attempt to connect to file service")
response = requests.get(f"{FILE_SERVICE_ADDRESS}{GET_MP3}", timeout=360)
response = requests.get(
f"{FILE_SERVICE_ADDRESS}{GET_MP3}",
headers=SERVICE_HEADERS,
timeout=60,
)
self.music_file_list = response.json()["music_file_list"]
self.file_service_active = True
except requests.exceptions.RequestException as e:
for mp3_item in Path.glob(Path(MUSIC_FOLDER), "**/*.mp3"):
for mp3_item in MUSIC_ROOT.glob("**/*.mp3"):
temp_music_file = mp3_item.as_posix()
if platform == "win32":
temp_music_file = temp_music_file.replace("/", "\\")
@@ -98,7 +107,12 @@ class MusicFileList(object):
"""
self.music_file_list.append(item)
post_data = {"item": str(item)}
requests.post(f"{FILE_SERVICE_ADDRESS}{SEND_MP3}", json=post_data, timeout=360)
requests.post(
f"{FILE_SERVICE_ADDRESS}{SEND_MP3}",
json=post_data,
headers=SERVICE_HEADERS,
timeout=60,
)
MUSIC_FILE_LIST = MusicFileList("discord")
@@ -142,7 +156,7 @@ async def get_file(ctx, source, link):
url_data = {"urls": []}
url_dict = {}
url_dict["save_path"] = Path(
PurePath.joinpath(Path(MUSIC_FOLDER), Path(directory_name))
PurePath.joinpath(MUSIC_ROOT, Path(directory_name))
)
url_dict["save_path"].mkdir(parents=True, exist_ok=True)
url_dict["songs"] = file_list
@@ -152,7 +166,7 @@ async def get_file(ctx, source, link):
coro = asyncio.to_thread(
youtube_download.download_songs,
songs=url_data,
output_dir=MUSIC_FOLDER,
output_dir=str(MUSIC_ROOT),
format_str="bestaudio/best",
skip_mp3=False,
keep_playlist_order=False,
@@ -308,6 +322,7 @@ async def search_music(ctx, how_many=0, slowa_kluczowe=None):
requests.post,
f"{FILE_SERVICE_ADDRESS}{GET_PLAYLIST}",
json=jrequest,
headers=SERVICE_HEADERS,
timeout=360,
)
return_data = await coroutine