implemented the ability to simply run the programm from terminal typing 'music-kraken' when installing with pip

This commit is contained in:
Lars Noack 2022-11-15 13:04:44 +01:00
parent a2c0610444
commit ea45d2f62e
13 changed files with 166 additions and 124 deletions

View File

@ -1,3 +1,15 @@
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
echo "building............"
python3 -m pip install --upgrade build
python3 -m build
echo "uploading............"
python3 -m pip install --upgrade twine
# twine upload dist/music_kraken*
twine upload --repository testpypi dist/music_kraken*
exit
echo "pushing............" echo "pushing............"
git add . git add .
git commit -am "new build and upload" git commit -am "new build and upload"
@ -8,13 +20,3 @@ mkdir -p dist/build_files
mkdir -p dist/compiled mkdir -p dist/compiled
pyinstaller --onefile src/music_kraken_cli.py --specpath dist/build_files --workpath dist/build_files --distpath dist/compiled pyinstaller --onefile src/music_kraken_cli.py --specpath dist/build_files --workpath dist/build_files --distpath dist/compiled
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
echo "building............"
python3 -m pip install --upgrade build
python3 -m build
echo "uploading............"
python3 -m pip install --upgrade twine
twine upload dist/music_kraken*
# twine upload --repository testpypi dist/*

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "music_kraken" name = "music_kraken"
version = "0.0.8" version = "1.0.0"
authors = [ authors = [
{ name="Hellow2", email="Hellow2@outlook.de" }, { name="Hellow2", email="Hellow2@outlook.de" },
] ]

View File

@ -1,4 +1,11 @@
from distutils.core import setup try:
from setuptools import setup, Command, find_packages
setuptools_available = True
except ImportError:
from distutils.core import setup, Command, find_packages
setuptools_available = False
# packages=['music_kraken'],
setup( setup(
name='music-kraken', name='music-kraken',
@ -8,7 +15,17 @@ setup(
author='Hellow2', author='Hellow2',
author_email='Hellow2@outlook.de', author_email='Hellow2@outlook.de',
url='https://github.com/HeIIow2/music-downloader', url='https://github.com/HeIIow2/music-downloader',
packages=['music_kraken'], packages=find_packages(where="src"),
package_dir={'': 'src'}, package_dir={'': 'src'},
install_requires=["requests~=2.28.1", "mutagen~=1.46.0", "musicbrainzngs~=0.7.1", "jellyfish~=0.9.0", "pydub~=0.25.1", "youtube_dl", "beautifulsoup4~=4.11.1", "pycountry~=22.3.5"] install_requires=[
"requests~=2.28.1",
"mutagen~=1.46.0",
"musicbrainzngs~=0.7.1",
"jellyfish~=0.9.0",
"pydub~=0.25.1",
"youtube_dl",
"beautifulsoup4~=4.11.1",
"pycountry~=22.3.5"
],
entry_points={'console_scripts': ['music-kraken = music_kraken:cli']}
) )

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: music-kraken Name: music-kraken
Version: 0.0.8 Version: 0.0.13
Summary: An extensive music downloader crawling the internet. It gets its metadata from a couple metadata provider, and it scrapes the audiofiles. Summary: An extensive music downloader crawling the internet. It gets its metadata from a couple metadata provider, and it scrapes the audiofiles.
Home-page: https://github.com/HeIIow2/music-downloader Home-page: https://github.com/HeIIow2/music-downloader
Author: Hellow2 Author: Hellow2

View File

@ -10,5 +10,25 @@ src/music_kraken/url_to_path.py
src/music_kraken.egg-info/PKG-INFO src/music_kraken.egg-info/PKG-INFO
src/music_kraken.egg-info/SOURCES.txt src/music_kraken.egg-info/SOURCES.txt
src/music_kraken.egg-info/dependency_links.txt src/music_kraken.egg-info/dependency_links.txt
src/music_kraken.egg-info/entry_points.txt
src/music_kraken.egg-info/requires.txt src/music_kraken.egg-info/requires.txt
src/music_kraken.egg-info/top_level.txt src/music_kraken.egg-info/top_level.txt
src/music_kraken/audio/__init__.py
src/music_kraken/audio/song.py
src/music_kraken/lyrics/__init__.py
src/music_kraken/lyrics/genius.py
src/music_kraken/lyrics/lyrics.py
src/music_kraken/metadata/__init__.py
src/music_kraken/metadata/database.py
src/music_kraken/metadata/download.py
src/music_kraken/metadata/object_handeling.py
src/music_kraken/metadata/search.py
src/music_kraken/scraping/__init__.py
src/music_kraken/scraping/file_system.py
src/music_kraken/scraping/musify.py
src/music_kraken/scraping/phonetic_compares.py
src/music_kraken/scraping/youtube_music.py
src/music_kraken/utils/__init__.py
src/music_kraken/utils/object_handeling.py
src/music_kraken/utils/phonetic_compares.py
src/music_kraken/utils/shared.py

View File

@ -0,0 +1,2 @@
[console_scripts]
music-kraken = music_kraken:cli

View File

@ -0,0 +1,106 @@
from .utils.shared import *
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.lyrics import fetch_lyrics
import logging
import os
# configure logger default
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.FileHandler(os.path.join(temp_dir, LOG_FILE)),
logging.StreamHandler()
]
)
def get_existing_genre():
valid_directories = []
for elem in os.listdir(MUSIC_DIR):
if elem not in NOT_A_GENRE:
valid_directories.append(elem)
return valid_directories
def search_for_metadata():
search = s.Search()
while True:
input_ = input(
"q to quit, .. for previous options, int for this element, str to search for query, ok to download\n")
input_.strip()
if input_.lower() == "ok":
break
if input_.lower() == "q":
break
if input_.lower() == "..":
print()
print(search.get_previous_options())
continue
if input_.isdigit():
print()
print(search.choose(int(input_)))
continue
print()
print(search.search_from_query(input_))
print(search.current_option)
return search.current_option
def get_genre():
existing_genres = get_existing_genre()
print("printing available genres:")
for i, genre_option in enumerate(existing_genres):
print(f"{i}: {genre_option}")
genre = input("Input the ID for an existing genre or text for a new one: ")
if genre.isdigit():
genre_id = int(genre)
if genre_id >= len(existing_genres):
logging.warning("An invalid genre id has been given")
return get_genre()
return existing_genres[genre_id]
return genre
def cli(start_at: int = 0, only_lyrics: bool = False):
if start_at <= 2 and not only_lyrics:
genre = get_genre()
logging.info(f"{genre} has been set as genre.")
if start_at <= 0:
search = search_for_metadata()
# search = metadata.search.Option("release", "f8d4b24d-2c46-4e9c-8078-0c0f337c84dd", "Beautyfall")
logging.info("Starting Downloading of metadata")
metadata_downloader = MetadataDownloader()
metadata_downloader.download({'type': search.type, 'id': search.id})
if start_at <= 1 and not only_lyrics:
logging.info("creating Paths")
url_to_path.UrlPath(genre=genre)
if start_at <= 2 and not only_lyrics:
logging.info("Fetching Download Links")
download_links.Download()
if start_at <= 3 and not only_lyrics:
logging.info("starting to download the mp3's")
download.Download()
if start_at <= 4:
logging.info("starting to fetch the lyrics")
fetch_lyrics()

View File

@ -1,110 +1,5 @@
from .utils.shared import * import music_kraken
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.lyrics import fetch_lyrics
import logging
import os
# configure logger default
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.FileHandler(os.path.join(temp_dir, LOG_FILE)),
logging.StreamHandler()
]
)
def get_existing_genre():
valid_directories = []
for elem in os.listdir(MUSIC_DIR):
if elem not in NOT_A_GENRE:
valid_directories.append(elem)
return valid_directories
def search_for_metadata():
search = s.Search()
while True:
input_ = input(
"q to quit, .. for previous options, int for this element, str to search for query, ok to download\n")
input_.strip()
if input_.lower() == "ok":
break
if input_.lower() == "q":
break
if input_.lower() == "..":
print()
print(search.get_previous_options())
continue
if input_.isdigit():
print()
print(search.choose(int(input_)))
continue
print()
print(search.search_from_query(input_))
print(search.current_option)
return search.current_option
def get_genre():
existing_genres = get_existing_genre()
print("printing available genres:")
for i, genre_option in enumerate(existing_genres):
print(f"{i}: {genre_option}")
genre = input("Input the ID for an existing genre or text for a new one: ")
if genre.isdigit():
genre_id = int(genre)
if genre_id >= len(existing_genres):
logging.warning("An invalid genre id has been given")
return get_genre()
return existing_genres[genre_id]
return genre
def cli(start_at: int = 0, only_lyrics: bool = False):
if start_at <= 2 and not only_lyrics:
genre = get_genre()
logging.info(f"{genre} has been set as genre.")
if start_at <= 0:
search = search_for_metadata()
# search = metadata.search.Option("release", "f8d4b24d-2c46-4e9c-8078-0c0f337c84dd", "Beautyfall")
logging.info("Starting Downloading of metadata")
metadata_downloader = MetadataDownloader()
metadata_downloader.download({'type': search.type, 'id': search.id})
if start_at <= 1 and not only_lyrics:
logging.info("creating Paths")
url_to_path.UrlPath(genre=genre)
if start_at <= 2 and not only_lyrics:
logging.info("Fetching Download Links")
download_links.Download()
if start_at <= 3 and not only_lyrics:
logging.info("starting to download the mp3's")
download.Download()
if start_at <= 4:
logging.info("starting to fetch the lyrics")
fetch_lyrics()
if __name__ == "__main__": if __name__ == "__main__":
cli(start_at=0, only_lyrics=False) music_kraken.cli(start_at=0, only_lyrics=False)

View File

@ -1,4 +1,4 @@
from music_kraken.__main__ import cli from music_kraken import cli
if __name__ == "__main__": if __name__ == "__main__":
cli() cli()