fix: downloads

This commit is contained in:
Hazel 2024-01-15 11:40:48 +01:00
parent 99690068db
commit 1a3f164827
6 changed files with 32 additions and 33 deletions

View File

@ -1,3 +1,4 @@
from pathlib import Path
from typing import List, Tuple from typing import List, Tuple
from tqdm import tqdm from tqdm import tqdm
from ffmpeg_progress_yield import FfmpegProgress 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) bitrate_b = int(bitrate_kb / 1024)
output_target = Target( output_target = Target(
path=target._path, file_path=Path(str(target.file_path) + "." + audio_format)
file=str(target._file) + "." + audio_format
) )
# get the select thingie # get the select thingie

View File

@ -229,6 +229,7 @@ class Collection(Generic[T]):
if existing_object is None: if existing_object is None:
# append # append
# print("appending", existing_object, __object)
append_to._data.append(__object) append_to._data.append(__object)
else: else:
# merge # merge

View File

@ -68,7 +68,7 @@ class Song(Base):
} }
def __init__(self, title: str = None, unified_title: str = None, isrc: str = None, length: int = None, 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, target_list: List[Target] = None, lyrics_list: List[Lyrics] = None,
main_artist_list: List[Artist] = None, feature_artist_list: List[Artist] = None, main_artist_list: List[Artist] = None, feature_artist_list: List[Artist] = None,
album_list: List[Album] = None, **kwargs) -> 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, def __init__(self, title: str = None, unified_title: str = None, album_status: AlbumStatus = None,
album_type: AlbumType = None, language: Language = None, date: ID3Timestamp = None, album_type: AlbumType = None, language: Language = None, date: ID3Timestamp = None,
barcode: str = None, albumsort: int = None, notes: FormattedText = 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: label_list: List[Label] = None, **kwargs) -> None:
super().__init__(title=title, unified_title=unified_title, album_status=album_status, album_type=album_type, 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, language=language, date=date, barcode=barcode, albumsort=albumsort, notes=notes,
@ -410,7 +410,7 @@ class Artist(Base):
# This is automatically generated # This is automatically generated
def __init__(self, name: str = None, unified_name: str = None, country: Country = None, 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, 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, contact_list: List[Contact] = None, feature_song_list: List[Song] = None,
main_album_list: List[Album] = None, label_list: List[Label] = None, **kwargs) -> 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, 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: 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, 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, contact_list=contact_list, album_list=album_list, current_artist_list=current_artist_list,

View File

@ -64,7 +64,7 @@ class Target(OuterProxy):
return self.file_path.stat().st_size return self.file_path.stat().st_size
def create_path(self): 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): def copy_content(self, copy_to: Target):
if not self.exists: if not self.exists:

View File

@ -24,6 +24,7 @@ from ..connection import Connection
from ..utils.support_classes.download_result import DownloadResult from ..utils.support_classes.download_result import DownloadResult
from ..utils.config import main_settings, logging_settings from ..utils.config import main_settings, logging_settings
from ..utils.shared import DEBUG from ..utils.shared import DEBUG
if DEBUG: if DEBUG:
from ..utils.debug_utils import dump_to_file from ..utils.debug_utils import dump_to_file
@ -38,7 +39,6 @@ def _get_host(source: Source) -> str:
return urlunparse((parsed.scheme, parsed.netloc, "", "", "", "")) return urlunparse((parsed.scheme, parsed.netloc, "", "", "", ""))
class BandcampTypes(Enum): class BandcampTypes(Enum):
ARTIST = "b" ARTIST = "b"
ALBUM = "a" ALBUM = "a"
@ -161,7 +161,6 @@ class Bandcamp(Page):
def song_search(self, song: Song) -> List[Song]: def song_search(self, song: Song) -> List[Song]:
return self.general_search(song.title, filter_string="t") return self.general_search(song.title, filter_string="t")
def fetch_label(self, source: Source, stop_at_level: int = 1) -> Label: def fetch_label(self, source: Source, stop_at_level: int = 1) -> Label:
return Label() return Label()
@ -219,7 +218,6 @@ class Bandcamp(Page):
return album_list return album_list
def fetch_artist(self, source: Source, stop_at_level: int = 1) -> Artist: def fetch_artist(self, source: Source, stop_at_level: int = 1) -> Artist:
artist = Artist() artist = Artist()
@ -310,7 +308,6 @@ class Bandcamp(Page):
return [] return []
def fetch_song(self, source: Source, stop_at_level: int = 1) -> Song: def fetch_song(self, source: Source, stop_at_level: int = 1) -> Song:
r = self.connection.get(source.url) r = self.connection.get(source.url)
if r is None: if r is None:
@ -340,7 +337,7 @@ class Bandcamp(Page):
song = Song( song = Song(
title=data["name"].strip(), 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( album_list=[Album(
title=album_data["name"].strip(), title=album_data["name"].strip(),
date=ID3Timestamp.strptime(data["datePublished"], "%d %b %Y %H:%M:%S %Z"), 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: def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult:
if source.audio_url is None: if source.audio_url is None:
print(source)
return DownloadResult(error_message="Couldn't find download link.") return DownloadResult(error_message="Couldn't find download link.")
return self.connection.stream_into(url=source.audio_url, target=target, description=desc) return self.connection.stream_into(url=source.audio_url, target=target, description=desc)

View File

@ -628,7 +628,7 @@ class Musify(Page):
source_list.append(Source( source_list.append(Source(
self.SOURCE_TYPE, self.SOURCE_TYPE,
url=current_url, url=current_url,
adio_url=self.HOST + download_href audio_url=self.HOST + download_href
)) ))
return Song( return Song(