fix: downloads
This commit is contained in:
parent
99690068db
commit
1a3f164827
@ -1,3 +1,4 @@
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple
|
||||
from tqdm import tqdm
|
||||
from ffmpeg_progress_yield import FfmpegProgress
|
||||
@ -19,8 +20,7 @@ def correct_codec(target: Target, bitrate_kb: int = main_settings["bitrate"], au
|
||||
bitrate_b = int(bitrate_kb / 1024)
|
||||
|
||||
output_target = Target(
|
||||
path=target._path,
|
||||
file=str(target._file) + "." + audio_format
|
||||
file_path=Path(str(target.file_path) + "." + audio_format)
|
||||
)
|
||||
|
||||
# get the select thingie
|
||||
|
@ -229,6 +229,7 @@ class Collection(Generic[T]):
|
||||
|
||||
if existing_object is None:
|
||||
# append
|
||||
# print("appending", existing_object, __object)
|
||||
append_to._data.append(__object)
|
||||
else:
|
||||
# merge
|
||||
|
@ -68,7 +68,7 @@ class Song(Base):
|
||||
}
|
||||
|
||||
def __init__(self, title: str = None, unified_title: str = None, isrc: str = None, length: int = None,
|
||||
genre: str = None, note: FormattedText = None, source_list: SourceCollection = None,
|
||||
genre: str = None, note: FormattedText = None, source_list: List[Source] = None,
|
||||
target_list: List[Target] = None, lyrics_list: List[Lyrics] = None,
|
||||
main_artist_list: List[Artist] = None, feature_artist_list: List[Artist] = None,
|
||||
album_list: List[Album] = None, **kwargs) -> None:
|
||||
@ -214,7 +214,7 @@ class Album(Base):
|
||||
def __init__(self, title: str = None, unified_title: str = None, album_status: AlbumStatus = None,
|
||||
album_type: AlbumType = None, language: Language = None, date: ID3Timestamp = None,
|
||||
barcode: str = None, albumsort: int = None, notes: FormattedText = None,
|
||||
source_list: SourceCollection = None, artist_list: List[Artist] = None, song_list: List[Song] = None,
|
||||
source_list: List[Source] = None, artist_list: List[Artist] = None, song_list: List[Song] = None,
|
||||
label_list: List[Label] = None, **kwargs) -> None:
|
||||
super().__init__(title=title, unified_title=unified_title, album_status=album_status, album_type=album_type,
|
||||
language=language, date=date, barcode=barcode, albumsort=albumsort, notes=notes,
|
||||
@ -410,7 +410,7 @@ class Artist(Base):
|
||||
# This is automatically generated
|
||||
def __init__(self, name: str = None, unified_name: str = None, country: Country = None,
|
||||
formed_in: ID3Timestamp = None, notes: FormattedText = None, lyrical_themes: List[str] = None,
|
||||
general_genre: str = None, unformated_location: str = None, source_list: SourceCollection = None,
|
||||
general_genre: str = None, unformated_location: str = None, source_list: List[Source] = None,
|
||||
contact_list: List[Contact] = None, feature_song_list: List[Song] = None,
|
||||
main_album_list: List[Album] = None, label_list: List[Label] = None, **kwargs) -> None:
|
||||
|
||||
@ -604,7 +604,7 @@ class Label(Base):
|
||||
}
|
||||
|
||||
def __init__(self, name: str = None, unified_name: str = None, notes: FormattedText = None,
|
||||
source_list: SourceCollection = None, contact_list: List[Contact] = None,
|
||||
source_list: List[Source] = None, contact_list: List[Contact] = None,
|
||||
album_list: List[Album] = None, current_artist_list: List[Artist] = None, **kwargs) -> None:
|
||||
super().__init__(name=name, unified_name=unified_name, notes=notes, source_list=source_list,
|
||||
contact_list=contact_list, album_list=album_list, current_artist_list=current_artist_list,
|
||||
|
@ -64,7 +64,7 @@ class Target(OuterProxy):
|
||||
return self.file_path.stat().st_size
|
||||
|
||||
def create_path(self):
|
||||
self._path.mkdir(parents=True, exist_ok=True)
|
||||
self.file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def copy_content(self, copy_to: Target):
|
||||
if not self.exists:
|
||||
|
@ -24,6 +24,7 @@ from ..connection import Connection
|
||||
from ..utils.support_classes.download_result import DownloadResult
|
||||
from ..utils.config import main_settings, logging_settings
|
||||
from ..utils.shared import DEBUG
|
||||
|
||||
if DEBUG:
|
||||
from ..utils.debug_utils import dump_to_file
|
||||
|
||||
@ -38,7 +39,6 @@ def _get_host(source: Source) -> str:
|
||||
return urlunparse((parsed.scheme, parsed.netloc, "", "", "", ""))
|
||||
|
||||
|
||||
|
||||
class BandcampTypes(Enum):
|
||||
ARTIST = "b"
|
||||
ALBUM = "a"
|
||||
@ -161,7 +161,6 @@ class Bandcamp(Page):
|
||||
def song_search(self, song: Song) -> List[Song]:
|
||||
return self.general_search(song.title, filter_string="t")
|
||||
|
||||
|
||||
def fetch_label(self, source: Source, stop_at_level: int = 1) -> Label:
|
||||
return Label()
|
||||
|
||||
@ -219,7 +218,6 @@ class Bandcamp(Page):
|
||||
|
||||
return album_list
|
||||
|
||||
|
||||
def fetch_artist(self, source: Source, stop_at_level: int = 1) -> Artist:
|
||||
artist = Artist()
|
||||
|
||||
@ -279,7 +277,7 @@ class Bandcamp(Page):
|
||||
|
||||
artist_source_list = []
|
||||
if "@id" in artist_data:
|
||||
artist_source_list=[Source(self.SOURCE_TYPE, _parse_artist_url(artist_data["@id"]))]
|
||||
artist_source_list = [Source(self.SOURCE_TYPE, _parse_artist_url(artist_data["@id"]))]
|
||||
album = Album(
|
||||
title=data["name"].strip(),
|
||||
source_list=[Source(self.SOURCE_TYPE, data.get("mainEntityOfPage", data["@id"]))],
|
||||
@ -310,7 +308,6 @@ class Bandcamp(Page):
|
||||
|
||||
return []
|
||||
|
||||
|
||||
def fetch_song(self, source: Source, stop_at_level: int = 1) -> Song:
|
||||
r = self.connection.get(source.url)
|
||||
if r is None:
|
||||
@ -340,7 +337,7 @@ class Bandcamp(Page):
|
||||
|
||||
song = Song(
|
||||
title=data["name"].strip(),
|
||||
source_list=[Source(self.SOURCE_TYPE, data.get("mainEntityOfPage", data["@id"]), adio_url=mp3_url)],
|
||||
source_list=[Source(self.SOURCE_TYPE, data.get("mainEntityOfPage", data["@id"]), audio_url=mp3_url)],
|
||||
album_list=[Album(
|
||||
title=album_data["name"].strip(),
|
||||
date=ID3Timestamp.strptime(data["datePublished"], "%d %b %Y %H:%M:%S %Z"),
|
||||
@ -359,5 +356,6 @@ class Bandcamp(Page):
|
||||
|
||||
def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult:
|
||||
if source.audio_url is None:
|
||||
print(source)
|
||||
return DownloadResult(error_message="Couldn't find download link.")
|
||||
return self.connection.stream_into(url=source.audio_url, target=target, description=desc)
|
||||
|
@ -628,7 +628,7 @@ class Musify(Page):
|
||||
source_list.append(Source(
|
||||
self.SOURCE_TYPE,
|
||||
url=current_url,
|
||||
adio_url=self.HOST + download_href
|
||||
audio_url=self.HOST + download_href
|
||||
))
|
||||
|
||||
return Song(
|
||||
|
Loading…
Reference in New Issue
Block a user