diff --git a/build b/build new file mode 100755 index 0000000..73c817a --- /dev/null +++ b/build @@ -0,0 +1,48 @@ +#!/bin/bash + +test=false +version_bump="minor" + +while getopts ":b:t" opt; do + case ${opt} in + b ) + version_bump=$OPTARG + ;; + t ) + test=true + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit 1 + ;; + : ) + echo "Invalid option: $OPTARG requires an argument" 1>&2 + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +# install dev dependencies +echo "installing dev dependencies..." +sudo python3 -m pip install -r requirements-dev.txt + +hatch version ${version_bump} +git add "music_kraken/__init__.py" +git commit -m "bump: ${version_bump}" + +# build the wheels +python3 -m build + +# install the newest version +python3 -m pip install . + +if [ "$test" = true ]; +then + echo "just a test" + twine upload --repository testpypi dist/music_kraken* + python3 -m pip install -i https://test.pypi.org/simple/ music-kraken -U + exit +fi + +twine upload dist/music_kraken* diff --git a/build.sh b/build.sh deleted file mode 100755 index 506457e..0000000 --- a/build.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -test=true - -rm /tmp/music-downloader/*.db -rm /tmp/music-downloader/*.sql - -version=$(cut -d@ -f1 version) -echo version: $version - -git add . -git commit -am "ready for build $version" -git push - -sudo python3 -m pip install -U twine wheel setuptools - -python3 setup.py sdist bdist_wheel -sudo python3 -m pip uninstall music-kraken -y - -python3 -m pip install dist/music-kraken-$version.tar.gz --user -music-kraken - -if [ "$test" = true ]; -then - echo "just a test" - twine upload --repository testpypi dist/music_kraken* - python3 -m pip install -i https://test.pypi.org/simple/ music-kraken -U - exit -fi - -twine upload dist/music_kraken* - -echo "compiling............" -mkdir -p dist/build_files -mkdir -p dist/compiled - -pyinstaller --onefile src/music_kraken_cli.py --specpath dist/build_files --workpath dist/build_files --distpath dist/compiled -exit - -# https://packaging.python.org/en/latest/tutorials/packaging-projects/ -#echo "building............" -#echo "python3 -m pip install --upgrade build" -# python3 -m pip install --upgrade pip -# python3 -m pip install --upgrade build -#echo "python3 -m build" -# python3 -m build -# python3 setup.py sdist bdist_wheel -# python3 setup.py install --user - -# echo "python3 -m pip install dist/music_kraken-1.2.2-py3-none-any.whl --user --force-reinstall" -# python3 -m pip install dist/music_kraken-1.2.2.tar.gz --user --force-reinstall - -# music-kraken - -# open /home/lars/.local/lib/python3.10/site-packages/music_kraken -# echo "uploading............" -#python3 -m pip install --upgrade twine -#twine upload dist/music_kraken* - -# twine upload --repository testpypi dist/music_kraken* -exit - -echo "pushing............" -git add . -git commit -am "new build and upload" -git push - -echo "compiling............" -mkdir -p dist/build_files -mkdir -p dist/compiled - -pyinstaller --onefile src/music_kraken_cli.py --specpath dist/build_files --workpath dist/build_files --distpath dist/compiled diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..7ce1d72 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +build +twine +hatch diff --git a/version b/version deleted file mode 100644 index 23aa839..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -1.2.2 diff --git a/website/assets/logo_cropped.jpg b/website/assets/logo_cropped.jpg deleted file mode 100644 index a4f0a94..0000000 Binary files a/website/assets/logo_cropped.jpg and /dev/null differ diff --git a/website/index.html b/website/index.html deleted file mode 100644 index eac1a40..0000000 --- a/website/index.html +++ /dev/null @@ -1,373 +0,0 @@ - - - -
- --# Install it with -pip install music-kraken - -# and simply run it like this: -music-kraken -- -
- Genre: First, the cli asks you to input a genre you want to download to. The options it gives you (if it gives you any) are all the folders you have in the music directory. You can also just input a new one. -
-- What to download: After that it prompts you for a search. Here are a couple examples how you can search: -
- --> #a <any artist> -searches for the artist <any artist> - -> #a <any artist> #r <any releas> -searches for the release <album> <any release> by the artist <any artist> - -> #r <any release> Me #t <any track> -searches for the track <any track> from the release <any relaese> -- -
- After searching with this syntax, it prompts you with multiple results. You can either choose one of those by inputing its id `int`, or you can search for a new query. -
-- After you chose either an artist, a release group, a release, or a track by its id, download it by inputting the string `ok`. My downloader will download it automatically for you. -
--from music_kraken import cli - -cli() -- -## Search for Metadata - -The whole program takes the data it processes further from the cache, a sqlite database. -So before you can do anything, you will need to fill it with the songs you want to download (*or create song objects manually, but more on that later*). - -For now the base of everything is [musicbrainz][mb], so you need to get the musicbrainz `id` and `type`. The `id` corresponds to either - - an artist - - a release group - - a release - - a recording/track). - -To get this info, you first have to initialize a search object (`music_kraken.MetadataSearch`). - -
-search_object = music_kraken.MetadataSearch() -- -Then you need an initial "text search" to get some options you can choose from. For -this you can either specify artists releases and whatever directly with one of the following functions: - -
-# you can directly specify artist, release group, release or recording/track -multiple_options = search_object.search_from_text(artist=input("input the name of the artist: ")) -# you can specify a query see the simple integrated cli on how to use the query -multiple_options = search_object.search_from_query(query=input("input the query: ")) -- -Both methods return an instance of `MultipleOptions`, which can be directly converted to a string. - -
-print(multiple_options) -- -After the first "*text search*" you can either again search the same way as before, -or you can further explore one of the options from the previous search. -To explore and select one options from `MultipleOptions`, simply call `MetadataSearch.choose(self, index: int)`. -The index represents the number in the previously returned instance of MultipleOptions. -The selected Option will be selected and can be downloaded in the next step. - -*Thus, this has to be done **after either search_from_text or search_from_query*** - -
-# choosing the best matching band -multiple_options = search_object.choose(0) -# choosing the first ever release group of this band -multiple_options = search_object.choose(1) -# printing out the current options -print(multiple_options) -- -This process can be repeated indefinitely (until you run out of memory). -A search history is kept in the Search instance. You could go back to -the previous search (without any loading time) like this: - -
-multiple_options = search_object.get_previous_options() -- -## Downloading Metadata / Filling up the Cache - -You can download following metadata: - - an artist (the whole discography) - - a release group - - a release - - a track/recording - -If you got an instance of `MetadataSearch`, like I elaborated [previously](#search-for-metadata), downloading every piece of metadata from the currently selected Option is really quite easy. - -
-from music_kraken import fetch_metadata_from_search - -# this is it :) -music_kraken.fetch_metadata_from_search(search_object) -- -If you already know what you want to download you can skip the search instance and simply do the following. - -
-from music_kraken import fetch_metadata - -# might change and break after I add multiple metadata sources which I will - -fetch_metadata(id_=musicbrainz_id, type=metadata_type) -- -The option type is a string (*I'm sorry for not making it an enum I know its a bad pratice*), which can -have following values: - - 'artist' - - 'release_group' - - 'release' - - 'recording' - -**PAY ATTENTION TO TYPOS, IT'S CASE SENSITIVE** - -The musicbrainz id is just the id of the object from musicbrainz. - -After following those steps, it might take a couple seconds/minutes to execute, but then the Cache will be filled. - - -## Cache / Temporary Database - -All the data, the functions that download stuff use, can be gotten from the temporary database / cache. -The cache can be simply used like this: - -
-music_kraken.cache -- -When fetching any song data from the cache, you will get it as Song -object (music_kraken.Song). There are multiple methods -to get different sets of Songs. The names explain the methods pretty -well: - -
-from music_kraken import cache - -# gets a single track specified by the id -cache.get_track_metadata(id: str) - -# gets a list of tracks. -cache.get_tracks_to_download() -cache.get_tracks_without_src() -cache.get_tracks_without_isrc() -cache.get_tracks_without_filepath() -- -The id always is a musicbrainz id and distinct for every track. - -## Setting the Target - -By default the music downloader doesn't know where to save the music file, if downloaded. To set those variables (the directory to save the file in and the filepath), it is enough to run one single command: - -
-from music_kraken import set_target - -# adds file path, file directory and the genre to the database -set_target(genre="some test genre") -- -The concept of genres is too loose, to definitely say, this band exclusively plays this genre, or this song is this genre. This doesn't work manually, this will never work automatically. Thus, I've decided to just use the genre as category, to sort the artists and songs by. Most Music players support that. - -As a result of this decision you will have to pass the genre in this function. - -## Get Audio - -This is most likely the most useful and unique feature of this Project. If the cache is filled, you can get audio sources for the songs you only have the metadata, and download them. This works for most songs. I'd guess for about 97% (?) - -First of you will need a List of song objects `music_kraken.Song`. As [mentioned above](#cache--temporary-database), you could get a list like that from the cache. - -
-# Here is an Example -from music_kraken import ( - cache, - fetch_sources, - fetch_audios -) - -# scanning pages, searching for a download and storing results -fetch_sources(cache.get_tracks_without_src()) - -# downloading all previously fetched sources to previously defined targets -fetch_audios(cache.get_tracks_to_download()) - -- -*Note:* -To download audio two cases have to be met: - 1. [The target](#setting-the-target) has to be set beforehand - 2. The sources have to be fetched beforehand - ---- -
-[ - { - "id":"Lorna Shore", - "label":"Lorna Shore", - "value":"Lorna Shore", - "category":"Исполнители", - "image":"https://39s.musify.club/img/68/9561484/25159224.jpg", - "url":"/artist/lorna-shore-59611" - }, - {"id":"Immortal","label":"Lorna Shore - Immortal (2020)","value":"Immortal","category":"Релизы","image":"https://39s-a.musify.club/img/70/20335517/52174338.jpg","url":"/release/lorna-shore-immortal-2020-1241300"}, - {"id":"Immortal","label":"Lorna Shore - Immortal","value":"Immortal","category":"Треки","image":"","url":"/track/lorna-shore-immortal-12475071"} -] -- -This is a shortened example for the response the api gives. The results are very Limited, but it is also very efficient to parse. The steps I take are: - -- call the api with the query being the track name -- parse the json response to an object -- look at how different the title and artist are on every element from the category `Треки`, translated roughly to track or release. -- If they match get the download links and cache them. - -## Youtube - -Herte the **isrc** plays a huge role. You probably know it, when you search on youtube for a song, and the music videos has a long intro or the first result is a live version. I don't want those in my music collection, only if the tracks are like this in the official release. Well how can you get around that? - -Turns out if you search for the **isrc** on youtube the results contain the music, like it is on the official release and some japanese meme videos. The tracks I wan't just have the title of the released track, so one can just compare those two. - -For searching, as well as for downloading I use the programm `youtube-dl`, which also has a programming interface for python. - -There are two bottlenecks with this approach though: -1. `youtube-dl` is just slow. Actually it has to be, to not get blocked by youtube. -2. Ofthen musicbrainz just doesn't give the isrc for some songs. -
-# Install it with -pip install music-kraken - -# and simply run it like this: -music-kraken -- -
- Genre: First, the cli asks you to input a genre you want to download to. The options it gives you (if it gives you any) are all the folders you have in the music directory. You can also just input a new one. -
-- What to download: After that it prompts you for a search. Here are a couple examples how you can search: -
- --> #a <any artist> -searches for the artist <any artist> - -> #a <any artist> #r <any releas> -searches for the release <album> <any release> by the artist <any artist> - -> #r <any release> Me #t <any track> -searches for the track <any track> from the release <any relaese> -- -
- After searching with this syntax, it prompts you with multiple results. You can either choose one of those by inputing its id `int`, or you can search for a new query. -
-- After you chose either an artist, a release group, a release, or a track by its id, download it by inputting the string `ok`. My downloader will download it automatically for you. -
\ No newline at end of file