mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2024-11-22 12:06:33 +03:00
fixed music handling
This commit is contained in:
parent
0a49519a4e
commit
017efcb1cc
|
@ -101,6 +101,7 @@ def download_from_youtube_link(link: str, user_id: int) -> Song:
|
||||||
chapter_path = path.split(".")[0] + chapters[i][2] + ".mp3"
|
chapter_path = path.split(".")[0] + chapters[i][2] + ".mp3"
|
||||||
info = search_all_platforms(chapters[i][2])
|
info = search_all_platforms(chapters[i][2])
|
||||||
audio.export(chapter_path, format="mp3")
|
audio.export(chapter_path, format="mp3")
|
||||||
|
if not info["album_image"].startswith("/"):
|
||||||
r = requests.get(info["album_image"])
|
r = requests.get(info["album_image"])
|
||||||
img_pth = str(
|
img_pth = str(
|
||||||
settings.MEDIA_ROOT
|
settings.MEDIA_ROOT
|
||||||
|
@ -111,12 +112,14 @@ def download_from_youtube_link(link: str, user_id: int) -> Song:
|
||||||
|
|
||||||
im = Image.open(img_pth)
|
im = Image.open(img_pth)
|
||||||
im.save(str(f"{img_pth}.png"))
|
im.save(str(f"{img_pth}.png"))
|
||||||
|
img_pth = f"{img_pth}.png"
|
||||||
|
else:
|
||||||
|
img_pth = info["album_image"]
|
||||||
|
|
||||||
os.remove(img_pth)
|
|
||||||
if "genre" in info:
|
if "genre" in info:
|
||||||
song = load_track(
|
song = load_track(
|
||||||
chapter_path,
|
chapter_path,
|
||||||
f"{img_pth}.png",
|
img_pth,
|
||||||
user_id,
|
user_id,
|
||||||
info["artists"],
|
info["artists"],
|
||||||
info["album_name"],
|
info["album_name"],
|
||||||
|
@ -126,7 +129,7 @@ def download_from_youtube_link(link: str, user_id: int) -> Song:
|
||||||
else:
|
else:
|
||||||
song = load_track(
|
song = load_track(
|
||||||
chapter_path,
|
chapter_path,
|
||||||
f"{img_pth}.png",
|
img_pth,
|
||||||
user_id,
|
user_id,
|
||||||
info["artists"],
|
info["artists"],
|
||||||
info["album_name"],
|
info["album_name"],
|
||||||
|
@ -137,6 +140,7 @@ def download_from_youtube_link(link: str, user_id: int) -> Song:
|
||||||
print(f"[processing] loading {title}")
|
print(f"[processing] loading {title}")
|
||||||
|
|
||||||
info = search_all_platforms(title)
|
info = search_all_platforms(title)
|
||||||
|
if not info["album_image"].startswith("/"):
|
||||||
r = requests.get(info["album_image"])
|
r = requests.get(info["album_image"])
|
||||||
img_pth = str(
|
img_pth = str(
|
||||||
settings.MEDIA_ROOT
|
settings.MEDIA_ROOT
|
||||||
|
@ -149,10 +153,13 @@ def download_from_youtube_link(link: str, user_id: int) -> Song:
|
||||||
im.save(str(f"{img_pth}.png"))
|
im.save(str(f"{img_pth}.png"))
|
||||||
|
|
||||||
os.remove(img_pth)
|
os.remove(img_pth)
|
||||||
|
img_pth = f"{img_pth}.png"
|
||||||
|
else:
|
||||||
|
img_pth = info["album_image"]
|
||||||
if "genre" in info:
|
if "genre" in info:
|
||||||
song = load_track(
|
song = load_track(
|
||||||
path,
|
path,
|
||||||
f"{img_pth}.png",
|
img_pth,
|
||||||
user_id,
|
user_id,
|
||||||
info["artists"],
|
info["artists"],
|
||||||
info["album_name"],
|
info["album_name"],
|
||||||
|
@ -162,7 +169,7 @@ def download_from_youtube_link(link: str, user_id: int) -> Song:
|
||||||
else:
|
else:
|
||||||
song = load_track(
|
song = load_track(
|
||||||
path,
|
path,
|
||||||
f"{img_pth}.png",
|
img_pth,
|
||||||
user_id,
|
user_id,
|
||||||
info["artists"],
|
info["artists"],
|
||||||
info["album_name"],
|
info["album_name"],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user