changed the way stuff is downloaded

This commit is contained in:
Hellow2
2023-03-30 16:50:27 +02:00
parent f8b3e57ade
commit 5067b84f48
5 changed files with 51 additions and 22 deletions

View File

@@ -17,7 +17,7 @@ from ..objects import (
Collection,
Label
)
from ..tagging import write_metadata
from ..tagging import write_metadata_to_target
LOGGER = logging.getLogger("this shouldn't be used")
@@ -330,11 +330,16 @@ class Page:
if len(sources) == 0:
return
cls._download_song_to_targets(source=sources[0], target_list=song.target_collection.shallow_list)
temp_target = cls._download_song_to_targets(source=sources[0], target_list=song.target_collection.shallow_list)
cls._post_process_targets(song, temp_target)
@classmethod
def _post_process_targets(cls, song: Song):
write_metadata(song)
def _post_process_targets(cls, song: Song, temp_target: Target):
write_metadata_to_target(song.metadata, temp_target)
target: Target
for target in song.target_collection:
temp_target.copy_content(target)
@classmethod
@@ -358,6 +363,5 @@ class Page:
return None
@classmethod
def _download_song_to_targets(cls, source: Source, target_list: List[Target]):
for target in target_list:
print(f"downloading {source} to {target}")
def _download_song_to_targets(cls, source: Source) -> Target:
return Target()

View File

@@ -6,9 +6,12 @@ import pycountry
from urllib.parse import urlparse
from enum import Enum
from dataclasses import dataclass
from pathlib import Path
import random
from ..utils.shared import (
ENCYCLOPAEDIA_METALLUM_LOGGER as LOGGER
ENCYCLOPAEDIA_METALLUM_LOGGER as LOGGER,
TEMP_FOLDER
)
from .abstract import Page
@@ -894,8 +897,21 @@ class Musify(Page):
return None
@classmethod
def _download_song_to_targets(cls, source: Source, target_list: List[Target]):
def _download_song_to_targets(cls, source: Source) -> Path:
"""
https://musify.club/track/im-in-a-coffin-life-never-was-waste-of-skin-16360302
https://musify.club/track/dl/16360302/im-in-a-coffin-life-never-was-waste-of-skin.mp3
"""
pass
url: MusifyUrl = cls.parse_url(source.url)
if url.source_type != MusifyTypes.SONG:
return
target: Target = Target(
path=TEMP_FOLDER,
file=str(random.randint(0, 999999))
)
endpoint = f"https://musify.club/track/dl/{url.musify_id}/{url.name_without_id}.mp3"
print(endpoint)
return target