refactored module names and imports
This commit is contained in:
parent
65bb48c3cf
commit
e9056771ff
2
notes.md
2
notes.md
@ -29,7 +29,7 @@
|
||||
- metadata
|
||||
- search
|
||||
- fetch
|
||||
- something with target
|
||||
- target
|
||||
- audio_source
|
||||
- fetch_source
|
||||
- fetch_audio
|
||||
|
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
@ -1,11 +1,10 @@
|
||||
from .utils.shared import *
|
||||
|
||||
from .metadata.download import MetadataDownloader
|
||||
from .metadata import download
|
||||
from .metadata.fetch import MetadataDownloader
|
||||
from .metadata import fetch
|
||||
from .metadata import search as s
|
||||
from . import download_links
|
||||
from . import url_to_path
|
||||
from . import download_
|
||||
from .audio_source import fetch_source, fetch_audio
|
||||
from .target import set_target
|
||||
|
||||
# NEEDS REFACTORING
|
||||
from .lyrics.lyrics import fetch_lyrics
|
||||
@ -91,15 +90,15 @@ def cli(start_at: int = 0, only_lyrics: bool = False):
|
||||
|
||||
if start_at <= 1 and not only_lyrics:
|
||||
logging.info("creating Paths")
|
||||
url_to_path.UrlPath(genre=genre)
|
||||
set_target.UrlPath(genre=genre)
|
||||
|
||||
if start_at <= 2 and not only_lyrics:
|
||||
logging.info("Fetching Download Links")
|
||||
download_links.Download()
|
||||
fetch_source.Download()
|
||||
|
||||
if start_at <= 3 and not only_lyrics:
|
||||
logging.info("starting to download the mp3's")
|
||||
download_.Download()
|
||||
fetch_audio.Download()
|
||||
|
||||
if start_at <= 4:
|
||||
logging.info("starting to fetch the lyrics")
|
||||
|
0
src/music_kraken/audio_source/__init__.py
Normal file
0
src/music_kraken/audio_source/__init__.py
Normal file
@ -4,8 +4,14 @@ import os.path
|
||||
from mutagen.easyid3 import EasyID3
|
||||
from pydub import AudioSegment
|
||||
|
||||
from .utils.shared import *
|
||||
from .scraping import musify, youtube_music
|
||||
from ..utils.shared import *
|
||||
from .sources import (
|
||||
youtube,
|
||||
musify,
|
||||
local_files
|
||||
)
|
||||
|
||||
logger = DOWNLOAD_LOGGER
|
||||
|
||||
"""
|
||||
https://en.wikipedia.org/wiki/ID3
|
||||
@ -17,8 +23,6 @@ print("\n".join(EasyID3.valid_keys.keys()))
|
||||
print(EasyID3.valid_keys.keys())
|
||||
"""
|
||||
|
||||
logger = DOWNLOAD_LOGGER
|
||||
|
||||
|
||||
class Download:
|
||||
def __init__(self):
|
||||
@ -36,7 +40,7 @@ class Download:
|
||||
if src == 'musify':
|
||||
download_success = musify.download(row)
|
||||
elif src == 'youtube':
|
||||
download_success = youtube_music.download(row)
|
||||
download_success = youtube.download(row)
|
||||
|
||||
if download_success == -1:
|
||||
logger.warning(f"couldn't download {row['url']} from {row['src']}")
|
@ -1,7 +1,9 @@
|
||||
import requests
|
||||
|
||||
from .utils.shared import *
|
||||
from .scraping import musify, youtube_music, file_system
|
||||
from ..utils.shared import *
|
||||
from .sources import (
|
||||
youtube,
|
||||
musify,
|
||||
local_files
|
||||
)
|
||||
|
||||
logger = URL_DOWNLOAD_LOGGER
|
||||
|
||||
@ -28,7 +30,7 @@ class Download:
|
||||
"""
|
||||
|
||||
# check YouTube
|
||||
youtube_url = youtube_music.get_youtube_url(row)
|
||||
youtube_url = youtube.get_youtube_url(row)
|
||||
if youtube_url is not None:
|
||||
self.add_url(youtube_url, 'youtube', id_)
|
||||
continue
|
||||
@ -47,7 +49,8 @@ class Download:
|
||||
|
||||
logger.warning(f"Didn't find any sources for {row['title']}")
|
||||
|
||||
def add_url(self, url: str, src: str, id_: str):
|
||||
@staticmethod
|
||||
def add_url(url: str, src: str, id_: str):
|
||||
database.set_download_data(id_, url, src)
|
||||
|
||||
|
0
src/music_kraken/audio_source/sources/__init__.py
Normal file
0
src/music_kraken/audio_source/sources/__init__.py
Normal file
@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from ..utils.shared import *
|
||||
from ..utils import phonetic_compares
|
||||
from ...utils.shared import *
|
||||
from ...utils import phonetic_compares
|
||||
|
||||
|
||||
def is_valid(a1, a2, t1, t2) -> bool:
|
@ -4,8 +4,8 @@ import time
|
||||
import requests
|
||||
import bs4
|
||||
|
||||
from ..utils.shared import *
|
||||
from ..utils import phonetic_compares
|
||||
from ...utils.shared import *
|
||||
from ...utils import phonetic_compares
|
||||
|
||||
TRIES = 5
|
||||
TIMEOUT = 10
|
@ -4,7 +4,7 @@ import youtube_dl
|
||||
import logging
|
||||
import time
|
||||
|
||||
from ..utils import phonetic_compares
|
||||
from ...utils import phonetic_compares
|
||||
|
||||
YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'}
|
||||
YOUTUBE_URL_KEY = 'webpage_url'
|
@ -1,8 +1,6 @@
|
||||
import mutagen
|
||||
from mutagen.id3 import ID3, USLT
|
||||
|
||||
|
||||
from ..metadata import database as db
|
||||
from ..utils.shared import *
|
||||
from . import genius
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
from datetime import date
|
||||
|
||||
|
||||
def get_elem_from_obj(current_object, keys: list, after_process=lambda x: x, return_if_none=None):
|
||||
current_object = current_object
|
||||
for key in keys:
|
||||
if key in current_object or (type(key) == int and key < len(current_object)):
|
||||
current_object = current_object[key]
|
||||
else:
|
||||
return return_if_none
|
||||
return after_process(current_object)
|
||||
|
||||
|
||||
def parse_music_brainz_date(mb_date: str) -> date:
|
||||
year = 1
|
||||
month = 1
|
||||
day = 1
|
||||
|
||||
first_release_date = mb_date
|
||||
if first_release_date.count("-") == 2:
|
||||
year, month, day = [int(i) for i in first_release_date.split("-")]
|
||||
elif first_release_date.count("-") == 0 and first_release_date.isdigit():
|
||||
year = int(first_release_date)
|
||||
return date(year, month, day)
|
0
src/music_kraken/target/__init__.py
Normal file
0
src/music_kraken/target/__init__.py
Normal file
@ -1,7 +1,7 @@
|
||||
import os.path
|
||||
import logging
|
||||
|
||||
from .utils.shared import *
|
||||
from ..utils.shared import *
|
||||
|
||||
logger = PATH_LOGGER
|
||||
|
@ -3,7 +3,7 @@ import logging
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from ..metadata.database import Database
|
||||
from .database import Database
|
||||
|
||||
TEMP_FOLDER = "music-downloader"
|
||||
LOG_FILE = "download_logs.log"
|
||||
|
Loading…
Reference in New Issue
Block a user