feat(echo): implement album download functionality

Add support for downloading albums in the echo command, including artwork and all tracks. The implementation fetches album details, downloads artwork, and processes each song in the album, cleaning up temporary files after sending.
This commit is contained in:
2025-06-07 12:25:22 -07:00
parent d447e7c71e
commit d57590617d

26
main.py
View File

@ -62,7 +62,31 @@ async def echo(_, message: filters.Message):
os.remove(artwork_file) os.remove(artwork_file)
elif content_type =='albums': elif content_type =='albums':
await message.reply("downloading from albums does not support yet") album = songbox.music.get_album(content_id)
artwork_file = f"{album['name']}_artwork.jpg"
await download_file(album['artwork_url'], artwork_file)
await message.reply_photo(
photo=artwork_file,
caption=(
f"**Album:** {album['name']} ({album['released_date']})\n"
f"**Artist:** {album['artist_name']}\n"
f"**Tracks:** {len(album['songs'])}\n"
f"**Share:** https://on.lavafoshi.mv/albums/{album['id']}"
)
)
for song in album['songs']:
audio_file = songbox.music.download_song(song['url_original'])
await message.reply_audio(
audio=audio_file,
performer=song['artist_name'],
title=song['name'],
thumb=artwork_file,
)
if os.path.exists(audio_file):
os.remove(audio_file)
if os.path.exists(artwork_file):
os.remove(artwork_file)
elif content_type =='artists': elif content_type =='artists':
await message.reply("downloading from artists does not support yet") await message.reply("downloading from artists does not support yet")
new_token = songbox.auth.refresh_token() new_token = songbox.auth.refresh_token()