diff --git a/slavart.py b/slavart.py deleted file mode 100644 index 614239d..0000000 --- a/slavart.py +++ /dev/null @@ -1,12 +0,0 @@ -import requests - -API_ENDPOINT = "https://slavart.gamesdrive.net/api/search?q=Tekkno" -DOWNLOAD_ENDPOINT = "https://slavart-api.gamesdrive.net/api/download/track?id=153182274" - - -if __name__ == "__main__": - r = requests.get(DOWNLOAD_ENDPOINT, headers={ - "Access-Control-Allow-Origin": "https://slavart.gamesdrive.net/" - }) - print(r.status_code) - print(r.text) diff --git a/src/download.py b/src/download.py index fcc7e7d..72ee974 100644 --- a/src/download.py +++ b/src/download.py @@ -5,8 +5,7 @@ from mutagen.easyid3 import EasyID3 from pydub import AudioSegment import logging -import musify -import youtube_music +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 b3e1e80..04eadde 100644 --- a/src/download_links.py +++ b/src/download_links.py @@ -1,8 +1,8 @@ import requests +import os import logging -import musify -import youtube_music +from scraping import musify, youtube_music class Download: @@ -18,6 +18,9 @@ class Download: row['artists'] = [artist['name'] for artist in row['artists']] id_ = row['id'] + if os.path.exists(os.path.join(os.path.expanduser('~/Music'), row['file'])): + self.logger.info(f"skipping the fetching of the download links, cuz {row['file']} already exists.") + continue # check YouTube youtube_url = youtube_music.get_youtube_url(row) diff --git a/src/main.py b/src/main.py index 759299d..3d2f378 100644 --- a/src/main.py +++ b/src/main.py @@ -111,13 +111,13 @@ def cli(start_at: int = 0): metadata_downloader.download(search) if start_at <= 1: - logging.info("Fetching Download Links") - download_links.Download(database, METADATA_DOWNLOAD_LOGGER, proxies=proxies) - - if start_at <= 2: logging.info("creating Paths") url_to_path.UrlPath(database, PATH_LOGGER, genre=genre) + if start_at <= 2: + logging.info("Fetching Download Links") + download_links.Download(database, METADATA_DOWNLOAD_LOGGER, proxies=proxies) + if start_at <= 3: logging.info("starting to download the mp3's") download.Download(database, DOWNLOAD_LOGGER, proxies=proxies, base_path=MUSIC_DIR) diff --git a/src/musify.py b/src/scraping/musify.py similarity index 97% rename from src/musify.py rename to src/scraping/musify.py index 7a0e23b..59771e7 100644 --- a/src/musify.py +++ b/src/scraping/musify.py @@ -4,7 +4,10 @@ import time import requests import bs4 -import phonetic_compares +try: + import phonetic_compares +except ModuleNotFoundError: + from scraping import phonetic_compares TRIES = 5 TIMEOUT = 10 diff --git a/src/phonetic_compares.py b/src/scraping/phonetic_compares.py similarity index 100% rename from src/phonetic_compares.py rename to src/scraping/phonetic_compares.py diff --git a/src/youtube_music.py b/src/scraping/youtube_music.py similarity index 95% rename from src/youtube_music.py rename to src/scraping/youtube_music.py index a138e2a..940f6be 100644 --- a/src/youtube_music.py +++ b/src/scraping/youtube_music.py @@ -3,7 +3,10 @@ import pandas as pd import logging import time -import phonetic_compares +try: + import phonetic_compares +except ModuleNotFoundError: + from scraping import phonetic_compares YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'} YOUTUBE_URL_KEY = 'webpage_url'