From f955ccdbe604eda9b66d38754bbda2b250ea12ac Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Mon, 14 Nov 2022 12:32:31 +0100 Subject: [PATCH] refactored imports --- src/__init__.py | 1 - src/__main__.py | 20 ++++++++++---------- src/download.py | 4 ++-- src/download_links.py | 4 ++-- src/lyrics/genius.py | 6 +++--- src/lyrics_.py | 8 ++++---- src/metadata/download.py | 4 ++-- src/metadata/search.py | 4 ++-- src/scraping/file_system.py | 4 ++-- src/scraping/musify.py | 4 ++-- src/scraping/youtube_music.py | 2 +- src/url_to_path.py | 2 +- src/utils/shared.py | 2 +- 13 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index ea52717..e69de29 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +0,0 @@ -__name__ = "music downloader" diff --git a/src/__main__.py b/src/__main__.py index 66fceca..7215c4e 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,14 +1,14 @@ -from utils.shared import * +from .utils.shared import * -from metadata.download import MetadataDownloader -import metadata.download -import metadata.search -import download_links -import url_to_path -import download +from .metadata.download import MetadataDownloader +from .metadata import download +from .metadata import search as s +from . import download_links +from . import url_to_path +from . import download # NEEDS REFACTORING -from lyrics_ import fetch_lyrics +from .lyrics_ import fetch_lyrics import logging import os @@ -34,7 +34,7 @@ def get_existing_genre(): def search_for_metadata(): - search = metadata.search.Search() + search = s.Search() while True: input_ = input( @@ -107,4 +107,4 @@ def cli(start_at: int = 0, only_lyrics: bool = False): if __name__ == "__main__": - cli(start_at=3, only_lyrics=False) + cli(start_at=0, only_lyrics=False) diff --git a/src/download.py b/src/download.py index f112100..b569961 100644 --- a/src/download.py +++ b/src/download.py @@ -4,8 +4,8 @@ import os.path from mutagen.easyid3 import EasyID3 from pydub import AudioSegment -from src.utils.shared import * -from src.scraping import musify, youtube_music +from .utils.shared import * +from .scraping import musify, youtube_music """ https://en.wikipedia.org/wiki/ID3 diff --git a/src/download_links.py b/src/download_links.py index 8fe7e24..be9286e 100644 --- a/src/download_links.py +++ b/src/download_links.py @@ -1,7 +1,7 @@ import requests -from src.utils.shared import * -from src.scraping import musify, youtube_music, file_system +from .utils.shared import * +from .scraping import musify, youtube_music, file_system logger = URL_DOWNLOAD_LOGGER diff --git a/src/lyrics/genius.py b/src/lyrics/genius.py index e4d7a5f..6a4040e 100644 --- a/src/lyrics/genius.py +++ b/src/lyrics/genius.py @@ -3,9 +3,9 @@ from typing import List from bs4 import BeautifulSoup import pycountry -from src.utils.shared import * -from src.utils import phonetic_compares -from src.utils.object_handeling import get_elem_from_obj +from ..utils.shared import * +from ..utils import phonetic_compares +from ..utils.object_handeling import get_elem_from_obj # search doesn't support isrc # https://genius.com/api/search/multi?q=I Prevail - Breaking Down diff --git a/src/lyrics_.py b/src/lyrics_.py index 89df530..c2a49bf 100644 --- a/src/lyrics_.py +++ b/src/lyrics_.py @@ -1,10 +1,10 @@ from mutagen.id3 import ID3, USLT -from metadata import database as db +from .metadata import database as db -from src.utils.shared import * +from .utils.shared import * -from lyrics import genius -from src.utils.shared import * +from .lyrics import genius +from .utils.shared import * """ This whole Part is bodgy as hell and I need to rewrite this little file urgently. genius.py is really clean though :3 diff --git a/src/metadata/download.py b/src/metadata/download.py index 4918cfc..acb61f5 100644 --- a/src/metadata/download.py +++ b/src/metadata/download.py @@ -1,5 +1,5 @@ -from src.utils.shared import * -from src.utils.object_handeling import get_elem_from_obj, parse_music_brainz_date +from ..utils.shared import * +from ..utils.object_handeling import get_elem_from_obj, parse_music_brainz_date from typing import List import musicbrainzngs diff --git a/src/metadata/search.py b/src/metadata/search.py index 5ce22d3..7931ce0 100644 --- a/src/metadata/search.py +++ b/src/metadata/search.py @@ -1,8 +1,8 @@ from typing import List import musicbrainzngs -from src.utils.shared import * -from src.utils.object_handeling import get_elem_from_obj, parse_music_brainz_date +from ..utils.shared import * +from ..utils.object_handeling import get_elem_from_obj, parse_music_brainz_date logger = SEARCH_LOGGER diff --git a/src/scraping/file_system.py b/src/scraping/file_system.py index 4c12b21..72e919f 100644 --- a/src/scraping/file_system.py +++ b/src/scraping/file_system.py @@ -1,7 +1,7 @@ import os -from src.utils.shared import * -from src.utils import phonetic_compares +from ..utils.shared import * +from ..utils import phonetic_compares def is_valid(a1, a2, t1, t2) -> bool: diff --git a/src/scraping/musify.py b/src/scraping/musify.py index b101c73..a0dba25 100644 --- a/src/scraping/musify.py +++ b/src/scraping/musify.py @@ -4,8 +4,8 @@ import time import requests import bs4 -from src.utils.shared import * -from src.utils import phonetic_compares +from ..utils.shared import * +from ..utils import phonetic_compares TRIES = 5 TIMEOUT = 10 diff --git a/src/scraping/youtube_music.py b/src/scraping/youtube_music.py index f95930a..d97430a 100644 --- a/src/scraping/youtube_music.py +++ b/src/scraping/youtube_music.py @@ -4,7 +4,7 @@ import youtube_dl import logging import time -from src.utils import phonetic_compares +from ..utils import phonetic_compares YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'} YOUTUBE_URL_KEY = 'webpage_url' diff --git a/src/url_to_path.py b/src/url_to_path.py index 3886527..09f8aea 100644 --- a/src/url_to_path.py +++ b/src/url_to_path.py @@ -1,7 +1,7 @@ import os.path import logging -from src.utils.shared import * +from .utils.shared import * logger = PATH_LOGGER diff --git a/src/utils/shared.py b/src/utils/shared.py index e0b9905..a69a969 100644 --- a/src/utils/shared.py +++ b/src/utils/shared.py @@ -3,7 +3,7 @@ import logging import tempfile import os -from src.metadata.database import Database +from ..metadata.database import Database TEMP_FOLDER = "music-downloader" LOG_FILE = "download_logs.log"