gotta fix fucking imports
This commit is contained in:
parent
ef362dd2a4
commit
f45afcb2ce
@ -14,11 +14,18 @@ from .audio_source import (
|
||||
)
|
||||
|
||||
from .lyrics import lyrics
|
||||
from .database.database import Database
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
||||
database = Database(os.path.join(temp_dir, DATABASE_FILE),
|
||||
os.path.join(temp_dir, DATABASE_STRUCTURE_FILE),
|
||||
DATABASE_STRUCTURE_FALLBACK,
|
||||
DATABASE_LOGGER,
|
||||
reset_anyways=False)
|
||||
|
||||
def get_existing_genre():
|
||||
valid_directories = []
|
||||
for elem in os.listdir(MUSIC_DIR):
|
||||
|
@ -10,6 +10,7 @@ from .sources import (
|
||||
musify,
|
||||
local_files
|
||||
)
|
||||
from ..database import song as song_objects
|
||||
|
||||
logger = DOWNLOAD_LOGGER
|
||||
|
||||
@ -33,11 +34,8 @@ print(EasyID3.valid_keys.keys())
|
||||
class Download:
|
||||
def __init__(self):
|
||||
for song in database.get_tracks_to_download():
|
||||
song['artist'] = [i['name'] for i in song['artists']]
|
||||
song['file'] = os.path.join(MUSIC_DIR, song['file'])
|
||||
song['path'] = os.path.join(MUSIC_DIR, song['path'])
|
||||
|
||||
if self.path_stuff(song['path'], song['file']):
|
||||
if self.path_stuff(song.target):
|
||||
self.write_metadata(song, song['file'])
|
||||
continue
|
||||
|
||||
@ -93,12 +91,12 @@ class Download:
|
||||
audiofile.save(file_path, v1=2)
|
||||
|
||||
@staticmethod
|
||||
def path_stuff(path: str, file_: str):
|
||||
def path_stuff(target: song_objects.Target):
|
||||
# returns true if it shouldn't be downloaded
|
||||
if os.path.exists(file_):
|
||||
logger.info(f"'{file_}' does already exist, thus not downloading.")
|
||||
if os.path.exists(target.file):
|
||||
logger.info(f"'{target.file}' does already exist, thus not downloading.")
|
||||
return True
|
||||
os.makedirs(path, exist_ok=True)
|
||||
os.makedirs(target.path, exist_ok=True)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -6,6 +6,8 @@ from .sources import (
|
||||
local_files
|
||||
)
|
||||
|
||||
from .. import database
|
||||
|
||||
logger = URL_DOWNLOAD_LOGGER
|
||||
|
||||
# maps the classes to get data from to the source name
|
||||
|
@ -26,11 +26,11 @@ session.proxies = proxies
|
||||
|
||||
class Musify(AudioSource):
|
||||
@classmethod
|
||||
def fetch_source(cls, row: dict) -> str | None:
|
||||
super().fetch_source(row)
|
||||
def fetch_source(cls, song: dict) -> str | None:
|
||||
super().fetch_source(song)
|
||||
|
||||
title = row.title
|
||||
artists = row.get_artist_names()
|
||||
title = song.title
|
||||
artists = song.get_artist_names()
|
||||
|
||||
# trying to get a download link via the autocomplete api
|
||||
for artist in artists:
|
||||
@ -73,9 +73,9 @@ class Musify(AudioSource):
|
||||
return None
|
||||
if r.status_code == 200:
|
||||
autocomplete = r.json()
|
||||
for row in autocomplete:
|
||||
if artist in row['label'] and "/track" in row['url']:
|
||||
return cls.get_download_link(row['url'])
|
||||
for song in autocomplete:
|
||||
if artist in song['label'] and "/track" in song['url']:
|
||||
return cls.get_download_link(song['url'])
|
||||
|
||||
return None
|
||||
|
||||
|
@ -19,5 +19,5 @@ class AudioSource:
|
||||
logger.info(f"try getting source {row['title']} from {cls.__name__}")
|
||||
|
||||
@classmethod
|
||||
def fetch_audio(cls, song: song_objects.Song, src: song_objects.Sourcet):
|
||||
def fetch_audio(cls, song: song_objects.Song, src: song_objects.Source):
|
||||
logger.info(f"downloading {song}: {cls.__name__} {src.url} -> {song.target.file}")
|
||||
|
@ -1,5 +1,7 @@
|
||||
from typing import List
|
||||
from ..utils.shared import *
|
||||
from ..utils.shared import (
|
||||
MUSIC_DIR
|
||||
)
|
||||
|
||||
import os
|
||||
|
||||
@ -29,7 +31,7 @@ class Target:
|
||||
|
||||
class Artist:
|
||||
def __init__(self, artist_data) -> None:
|
||||
self.artist_data
|
||||
self.artist_data = artist_data
|
||||
|
||||
self.id = self.artist_data['id']
|
||||
self.name = self.artist_data['name']
|
||||
@ -73,7 +75,7 @@ class Song:
|
||||
return self.isrc is not None
|
||||
|
||||
def get_artist_names(self) -> List[str]:
|
||||
return [a.name for a in self.aritsts]
|
||||
return [a.name for a in self.artists]
|
||||
|
||||
def __getitem__(self, item):
|
||||
if item not in self.json_data:
|
||||
|
@ -1,6 +1,8 @@
|
||||
from ..utils.shared import *
|
||||
from ..utils.object_handeling import get_elem_from_obj, parse_music_brainz_date
|
||||
|
||||
from .. import database
|
||||
|
||||
from typing import List
|
||||
import musicbrainzngs
|
||||
import logging
|
||||
|
@ -3,7 +3,6 @@ import logging
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from ..database.database import Database
|
||||
|
||||
TEMP_FOLDER = "music-downloader"
|
||||
LOG_FILE = "download_logs.log"
|
||||
@ -42,13 +41,6 @@ NOT_A_GENRE = ".", "..", "misc_scripts", "Music", "script", ".git", ".idea"
|
||||
MUSIC_DIR = os.path.expanduser('~/Music')
|
||||
|
||||
|
||||
database = Database(os.path.join(temp_dir, DATABASE_FILE),
|
||||
os.path.join(temp_dir, DATABASE_STRUCTURE_FILE),
|
||||
DATABASE_STRUCTURE_FALLBACK,
|
||||
DATABASE_LOGGER,
|
||||
reset_anyways=False)
|
||||
|
||||
|
||||
TOR = False
|
||||
proxies = {
|
||||
'http': 'socks5h://127.0.0.1:9150',
|
||||
|
@ -1,10 +1,14 @@
|
||||
import music_kraken as mk
|
||||
print(mk.__path__)
|
||||
|
||||
# mk.fetch_source.Download()
|
||||
db = mk.utils.shared.database
|
||||
if len(db.get_custom_track([])) == 0:
|
||||
mk.cli()
|
||||
# mk.cli()
|
||||
|
||||
mk.fetch_source.Download()
|
||||
# db = mk.utils.shared.database
|
||||
# if len(db.get_custom_track([])) == 0:
|
||||
|
||||
|
||||
mk.target.set_target.UrlPath(genre="test")
|
||||
|
||||
mk.fetch_audio.Download()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user