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