start laying out downloads
This commit is contained in:
@@ -148,3 +148,7 @@ class Collection:
|
||||
returns a shallow copy of the data list
|
||||
"""
|
||||
return self._data.copy()
|
||||
|
||||
@property
|
||||
def empty(self) -> bool:
|
||||
return len(self._data) == 0
|
||||
|
@@ -25,16 +25,18 @@ class Target(DatabaseObject):
|
||||
self,
|
||||
file: str = None,
|
||||
path: str = None,
|
||||
_id: str = None,
|
||||
dynamic: bool = False,
|
||||
relative_to_music_dir: bool = False
|
||||
) -> None:
|
||||
super().__init__(_id=_id, dynamic=dynamic)
|
||||
super().__init__(dynamic=dynamic)
|
||||
self._file: Path = Path(file)
|
||||
self._path: Path = Path(path) if relative_to_music_dir else Path(path)
|
||||
self._path: Path = Path(shared.MUSIC_DIR, path) if relative_to_music_dir else Path(path)
|
||||
|
||||
self.is_relative_to_music_dir: bool = relative_to_music_dir
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return str(self.file_path)
|
||||
|
||||
@property
|
||||
def file_path(self) -> Path:
|
||||
return Path(self._path, self._file)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from typing import Optional, Union, Type, Dict
|
||||
from typing import Optional, Union, Type, Dict, List
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
import logging
|
||||
@@ -274,6 +274,18 @@ class Page:
|
||||
cls._clean_collection(song.feature_artist_collection, collections)
|
||||
cls._clean_collection(song.main_artist_collection, collections)
|
||||
|
||||
@classmethod
|
||||
def download_song(cls, song: Song):
|
||||
if song.target_collection.empty:
|
||||
return
|
||||
|
||||
sources = song.source_collection.get_sources_from_page(cls.SOURCE_TYPE)
|
||||
if len(sources) == 0:
|
||||
return
|
||||
|
||||
cls._download_song_to_targets(source=sources[0], target_list=song.target_collection.shallow_list)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _fetch_song_from_source(cls, source: Source, stop_at_level: int = 1) -> Song:
|
||||
return Song()
|
||||
@@ -293,3 +305,8 @@ class Page:
|
||||
@classmethod
|
||||
def _get_type_of_url(cls, url: str) -> Optional[Union[Type[Song], Type[Album], Type[Artist], Type[Label]]]:
|
||||
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}")
|
||||
|
Reference in New Issue
Block a user