refactored some more

This commit is contained in:
Lars Noack 2022-11-24 14:56:51 +01:00
parent 0d7fd4496c
commit 068918feda
2 changed files with 11 additions and 10 deletions

View File

@ -200,12 +200,12 @@ By default the music downloader doesn't know where to save the music file, if do
```python
# adds file path, file directory and the genre to the database
mk.target.set_target.UrlPath(genre="some test genre")
music_kraken.set_target(genre="some test genre")
```
The concept of genres is too loose, to definitly say, this band exclusively plays this genre, or this song is this genre. This doesn't work manually, this will never work automatically. Thus I've decided to just use the genre as category, to sort the artists and songs by. Most Music players support that.
As a result of this decision you will have to pass the genre in this function (*actually its a class but it doesn't make any difference*).
As a result of this decision you will have to pass the genre in this function.
### Get Audio
@ -231,7 +231,7 @@ fetch_audios(cache.get_tracks_to_download())
*Note:*
To download audio two cases have to be met:
1. The target has to be set beforehand
1. [The target](#setting-the-target) has to be set beforehand
2. The sources have to be fetched beforehand
---

View File

@ -5,7 +5,8 @@ import os
from . import (
database,
audio_source
audio_source,
target
)
from .utils.shared import (
@ -16,11 +17,7 @@ from .metadata import (
metadata_search,
metadata_fetch
)
from .target import set_target
from .audio_source import (
fetch_source,
fetch_audio
)
from .lyrics import lyrics
logging.getLogger("musicbrainzngs").setLevel(logging.WARNING)
@ -31,6 +28,9 @@ Song = database.song.Song
cache = database.cache
def set_targets(genre: str):
target.set_target.UrlPath(genre=genre)
def fetch_sources(songs: List[Song], skip_existing_files: bool = True):
audio_source.fetch_sources(songs=songs, skip_existing_files=skip_existing_files)
@ -38,6 +38,7 @@ def fetch_audios(songs: List[Song], override_existing: bool = False):
audio_source.fetch_audios(songs=songs, override_existing=override_existing)
def get_existing_genre():
valid_directories = []
for elem in os.listdir(MUSIC_DIR):
@ -138,7 +139,7 @@ def cli(start_at: int = 0, only_lyrics: bool = False):
if start_at <= 1 and not only_lyrics:
logging.info("creating Paths")
set_target.UrlPath(genre=genre)
set_targets(genre=genre)
if start_at <= 2 and not only_lyrics:
logging.info("Fetching Download Links")