mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2024-11-25 07:03:44 +03:00
bug fixes
This commit is contained in:
parent
64f28fc1c8
commit
d49be5c42e
|
@ -122,12 +122,15 @@ def load_track(
|
||||||
album=album,
|
album=album,
|
||||||
):
|
):
|
||||||
return sng.first()
|
return sng.first()
|
||||||
|
try:
|
||||||
if not path.endswith(".mp3"):
|
if not path.endswith(".mp3"):
|
||||||
mp3_path = path.replace(path.split(".")[-1], "mp3")
|
mp3_path = path.replace(path.split(".")[-1], "mp3")
|
||||||
AudioSegment.from_file(path).export(mp3_path)
|
AudioSegment.from_file(path).export(mp3_path)
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
path = mp3_path
|
path = mp3_path
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return Song.objects.none()
|
||||||
|
|
||||||
tag = MP3(path, ID3=ID3)
|
tag = MP3(path, ID3=ID3)
|
||||||
|
|
||||||
|
|
|
@ -95,18 +95,16 @@ def load_url(link: str, user_id: int):
|
||||||
)
|
)
|
||||||
elif "/album/" in link:
|
elif "/album/" in link:
|
||||||
album = client.albums_with_tracks(obj_id)
|
album = client.albums_with_tracks(obj_id)
|
||||||
tracks = []
|
|
||||||
for volume in album.volumes:
|
for volume in album.volumes:
|
||||||
for track in volume:
|
for track in volume:
|
||||||
tracks.append(track)
|
|
||||||
|
|
||||||
for track in tracks:
|
|
||||||
tasks.load_ym_file_meta.apply_async(
|
tasks.load_ym_file_meta.apply_async(
|
||||||
kwargs={"track": track.track.id, "user_id": user_id}
|
kwargs={"track": track.id, "user_id": user_id}
|
||||||
)
|
)
|
||||||
elif "/artist/" in link:
|
elif "/artist/" in link:
|
||||||
artist = client.artists(obj_id)[0]
|
artist = client.artists(obj_id)[0]
|
||||||
for track in artist.popular_tracks:
|
albums = artist.get_albums(page_size=100)
|
||||||
|
for album in albums:
|
||||||
|
for track in album.fetch_tracks():
|
||||||
tasks.load_ym_file_meta.apply_async(
|
tasks.load_ym_file_meta.apply_async(
|
||||||
kwargs={"track": track.id, "user_id": user_id}
|
kwargs={"track": track.id, "user_id": user_id}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user