diff --git a/development/actual_donwload.py b/development/actual_donwload.py index 748bf1b..a8eb732 100644 --- a/development/actual_donwload.py +++ b/development/actual_donwload.py @@ -6,8 +6,8 @@ logging.getLogger().setLevel(logging.DEBUG) if __name__ == "__main__": commands = [ - "s: #a Psychonaut 4", - "d: 0", + "s: #a Crystal F", + "d: 20", ] diff --git a/music_kraken/audio/metadata.py b/music_kraken/audio/metadata.py index dbcd36a..d3f450e 100644 --- a/music_kraken/audio/metadata.py +++ b/music_kraken/audio/metadata.py @@ -112,8 +112,6 @@ def write_metadata_to_target(metadata: Metadata, target: Target, song: Song): USLT(encoding=3, lang=u'eng', desc=u'desc', text=uslt_val) ) - mutagen_file = mutagen.File(target.file_path) - id3_object.add_metadata(metadata) id3_object.save() diff --git a/music_kraken/objects/target.py b/music_kraken/objects/target.py index 2ba1cfe..2491a5a 100644 --- a/music_kraken/objects/target.py +++ b/music_kraken/objects/target.py @@ -1,7 +1,7 @@ from __future__ import annotations from pathlib import Path -from typing import List, Tuple, TextIO, Union +from typing import List, Tuple, TextIO, Union, Optional import logging import random import requests @@ -31,7 +31,10 @@ class Target(OuterProxy): } @classmethod - def temp(cls, name: str = str(random.randint(0, HIGHEST_ID))) -> P: + def temp(cls, name: str = str(random.randint(0, HIGHEST_ID)), file_extension: Optional[str] = None) -> P: + if file_extension is not None: + name = f"{name}.{file_extension}" + return cls(main_settings["temp_directory"] / name) # This is automatically generated diff --git a/music_kraken/pages/abstract.py b/music_kraken/pages/abstract.py index 8d6dba9..4d123a9 100644 --- a/music_kraken/pages/abstract.py +++ b/music_kraken/pages/abstract.py @@ -381,7 +381,7 @@ class Page: song.target_collection.append(new_target) r = DownloadResult(1) - temp_target: Target = Target.temp() + temp_target: Target = Target.temp(file_extension=main_settings["audio_format"]) found_on_disc = False target: Target diff --git a/music_kraken/pages/youtube_music/super_youtube.py b/music_kraken/pages/youtube_music/super_youtube.py index 420c46d..3ba1cee 100644 --- a/music_kraken/pages/youtube_music/super_youtube.py +++ b/music_kraken/pages/youtube_music/super_youtube.py @@ -145,6 +145,8 @@ class SuperYouTube(Page): _sponsorblock_connection: Connection = Connection() self.sponsorblock = python_sponsorblock.SponsorBlock(silent=True, session=_sponsorblock_connection.session) + super().__init__(*args, **kwargs) + def get_source_type(self, source: Source) -> Optional[Type[DatabaseObject]]: _url_type = { YouTubeUrlType.CHANNEL: Artist, diff --git a/music_kraken/pages/youtube_music/youtube_music.py b/music_kraken/pages/youtube_music/youtube_music.py index bbb8d22..eff7376 100644 --- a/music_kraken/pages/youtube_music/youtube_music.py +++ b/music_kraken/pages/youtube_music/youtube_music.py @@ -193,8 +193,7 @@ class YoutubeMusic(SuperYouTube): self.start_millis = get_current_millis() - if self.credentials.api_key == "" or DEBUG_YOUTUBE_INITIALIZING: - self._fetch_from_main_page() + self._fetch_from_main_page() SuperYouTube.__init__(self, *args, **kwargs) @@ -215,6 +214,8 @@ class YoutubeMusic(SuperYouTube): self.download_values_by_url: dict = {} self.not_download: Dict[str, DownloadError] = {} + super().__init__(*args, **kwargs) + def _fetch_from_main_page(self): """ ===API=KEY=== @@ -736,7 +737,7 @@ class YoutubeMusic(SuperYouTube): raw_headers=True, disable_cache=True, headers=media.get("headers", {}), - # chunk_size=media.get("chunk_size", main_settings["chunk_size"]), + chunk_size=main_settings["chunk_size"], method="GET", ) else: