Merge pull request #3 from GabrieleAncillai/development

edited readme + cli improvements
This commit is contained in:
Hellow 2022-11-22 11:06:18 +01:00 committed by GitHub
commit b93d6d2282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 69 additions and 33 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@ __pycache__/
/build/*
!/build/build.sh
# Virtual Environment
venv

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (music-downloader)" project-jdk-type="Python SDK" />
</project>

View File

@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.10 (music-downloader)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="rythmbox-id3-lyrics-support" />
</component>

View File

@ -1,3 +1,4 @@
from .utils.functions import *
from .utils.shared import *
from .metadata import (
@ -37,24 +38,42 @@ def get_existing_genre():
def search_for_metadata():
clear_console()
search = metadata_search.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":
"""
- - - Type the command you want to execute - - -
.. - Previous Options
(query_string) - Search for songs, albums, bands...
(int) - Select an item from the search results
d - Start the download
h - Help
q - Quit / Exit
command: """
)
match (input_.strip().lower()):
case "d" | "ok" | "dl" | "download":
break
if input_.lower() == "q":
break
if input_.lower() == "..":
case "q" | "quit" | "exit":
clear_console()
exit()
case "h" | "help":
print()
print(search.get_previous_options())
continue
if input_.isdigit():
# TODO: Help text (mainly explaining query strings and alternative command functionalities)
print("Insert here help text....")
case inp if inp.isdigit():
print()
print(search.choose(int(input_)))
continue
case ".." :
print()
print(search.get_previous_options())
print()
print(search.search_from_query(input_))
@ -81,6 +100,8 @@ def get_genre():
def cli(start_at: int = 0, only_lyrics: bool = False):
clear_console()
if start_at <= 2 and not only_lyrics:
genre = get_genre()
logging.info(f"{genre} has been set as genre.")
@ -107,3 +128,7 @@ def cli(start_at: int = 0, only_lyrics: bool = False):
if start_at <= 4:
logging.info("starting to fetch the lyrics")
lyrics.fetch_lyrics()
def gtk_gui():
pass

View File

@ -14,7 +14,7 @@ class Option:
def __init__(self, type_: str, id_: str, name: str, additional_info: str = "") -> None:
# print(type_, id_, name)
if type_ not in OPTION_TYPES:
raise ValueError(f"type: {type_} doesn't exist. Leagal Values: {OPTION_TYPES}")
raise ValueError(f"type: {type_} doesn't exist. Legal Values: {OPTION_TYPES}")
self.type = type_
self.name = name
self.id = id_

View File

@ -16,7 +16,7 @@ License-File: LICENSE
RUN WITH: `python3 -m src` from the project Directory
This programm will first get the metadata of various songs from metadata provider like musicbrainz, and then search for download links on pages like bandcamp. Then it will download the song and edit the metadata according.
This program will first get the metadata of various songs from metadata provider like musicbrainz, and then search for download links on pages like bandcamp. Then it will download the song and edit the metadata according.
## Metadata
@ -26,9 +26,9 @@ First the metadata has to be downloaded. The best api to do so is undeniably [Mu
![Musicbrainz Data Scheme](https://wiki.musicbrainz.org/-/images/9/9e/pymb3-model-core.png)
To fetch from [Musicbrainz](musicbrainz.org/) we first have to know what to fetch. A good start is to get an input querry, which can be just put into the MB-Api. It then returns a list of possible artists, releases and recordings.
To fetch from [Musicbrainz](musicbrainz.org/) we first have to know what to fetch. A good start is to get an input query, which can be just put into the MB-Api. It then returns a list of possible artists, releases and recordings.
Then we can output them in the Terminal and ask for further input. Following can be inputed afterwards:
Then we can output them in the Terminal and ask for further input. Following can be inputted afterwards:
- `q` to quit
- `ok` to download
@ -36,18 +36,18 @@ Then we can output them in the Terminal and ask for further input. Following can
- `.` for current options
- `an integer` for this element
If the following chosen element is an artist, its discography + a couple tracks are outputed, if a release is chosen, the artists + tracklist + release is outputted, If a track is chosen its artists and releases are shown.
If the following chosen element is an artist, its discography + a couple tracks are outputted, if a release is chosen, the artists + tracklist + release is outputted, If a track is chosen its artists and releases are shown.
**TO DO**
- Schow always the whole tracklist of an release if it is chosen
- Show always the whole tracklist of an release if it is chosen
- Show always the whole discography of an artist if it is chosen
Up to now it doesn't if the discography or tracklist is chosen.
### Metadata to fetch
I orient on which metadata to download on the keys in `mutagen.EasyID3` . Following I fatch and thus tag the MP3 with:
I orient on which metadata to download on the keys in `mutagen.EasyID3` . Following I fetch and thus tag the MP3 with:
- title
- artist
- albumartist
@ -70,7 +70,7 @@ Those Tags are for the musicplayer to not sort for Example the albums of a band
#### isrc
This is the **international standart release code**. With this a track can be identified 100% percicely all of the time, if it is known and the website has a search api for that. Obviously this will get important later.
This is the **international standard release code**. With this a track can be identified 100% precisely all of the time, if it is known and the website has a search api for that. Obviously this will get important later.
---
@ -80,7 +80,7 @@ Now that the metadata is downloaded and cached, download sources need to be soun
### Musify
The quickest source to get download links from is to my knowledge [musify](https://musify.club/). Its a russian music downloading page, where many many songs are available to stream and to download. Due to me not wanting to stress the server to much, I abuse a handy feature nearly every page where you can search suff has. The autocomplete api for the search input. Those always are quite limited in the number of results it returns, but it is optimized to be quick. Thus with the http header `Connection` set to `keep-alive` the bottelneck defently is not at the speed of those requests.
The quickest source to get download links from is to my knowledge [musify](https://musify.club/). Its a russian music downloading page, where many many songs are available to stream and to download. Due to me not wanting to stress the server to much, I abuse a handy feature nearly every page where you can search stuff has. The autocomplete api for the search input. Those always are quite limited in the number of results it returns, but it is optimized to be quick. Thus with the http header `Connection` set to `keep-alive` the bottleneck definitely is not at the speed of those requests.
For musify the endpoint is following: [https://musify.club/search/suggestions?term={title}](https://musify.club/search/suggestions?term=LornaShore) If the http headers are set correctly, then searching for example for "Lorna Shore" yields following result:
@ -101,29 +101,29 @@ For musify the endpoint is following: [https://musify.club/search/suggestions?te
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 querry being the track name
- 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 probaply 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?
Here 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.
For searching, as well as for downloading I use the program `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.
2. Often musicbrainz just doesn't give the isrc for some songs.
**TODO**
- look at how the isrc id derived an try to generate it for the tracks without directly getting it from mb.
**Progress**
- There is a great site whith a huge isrc database [https://isrc.soundexchange.com/](https://isrc.soundexchange.com/).
- There is a great site with a huge isrc database [https://isrc.soundexchange.com/](https://isrc.soundexchange.com/).
## Lyrics
@ -158,7 +158,7 @@ music-downloader
├── metadata
│   ├── database.py
│   ├── download.py
│   ├── object_handeling.py
│   ├── object_handling.py
│   └── search.py
├── scraping
│   ├── file_system.py
@ -167,7 +167,7 @@ music-downloader
│   └── youtube_music.py
├── url_to_path.py
└── utils
├── object_handeling.py
├── object_handling.py
├── phonetic_compares.py
└── shared.py

View File

@ -1,2 +1,2 @@
# tells what exists
__all__ = ["shared", "object_handeling", "phonetic_compares"]
__all__ = ["shared", "object_handeling", "phonetic_compares", "functions"]

View File

@ -0,0 +1,4 @@
import os
def clear_console():
os.system('cls' if os.name in ('nt', 'dos') else 'clear')

4
src/music_kraken_gtk.py Normal file
View File

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