music-kraken-core/README.md

691 lines
23 KiB
Markdown
Raw Normal View History

2023-02-22 17:56:28 +00:00
# Music Kraken
2023-02-23 11:17:41 +00:00
<img align="right" src="assets/logo.svg" width=300>
2022-11-24 15:03:53 +00:00
1. [Installlation](#installation)
2. [Command Line Usage](#quick-guide)
2023-02-22 17:56:28 +00:00
3. [Contribute](#contribute)
4. [Matrix Space](#matrix-space), if you don't wanna read: **[Invite](https://matrix.to/#/#music-kraken:matrix.org)**
2022-11-24 15:03:53 +00:00
2023-02-22 17:56:28 +00:00
5. [Library Usage / Python Interface](#programming-interface--use-as-library)
6. [About Metadata](#metadata)
7. [About the Audio](#download)
8. [About the Lyrics](#lyrics)
2023-02-06 08:44:11 +00:00
2023-02-22 17:56:28 +00:00
---
2022-11-15 16:01:17 +00:00
2022-11-15 09:52:54 +00:00
## Installation
You can find and get this project from either [PyPI](https://pypi.org/project/music-kraken/) as a Python-Package,
or simply the source code from [GitHub](https://github.com/HeIIow2/music-downloader). Note that even though
everything **SHOULD** work cross-platform, I have only tested it on Ubuntu.
If you enjoy this project, feel free to give it a star on GitHub.
2022-11-15 09:52:54 +00:00
```sh
# Install it with
2022-11-15 09:52:54 +00:00
pip install music-kraken
2022-11-15 12:36:45 +00:00
# and simply run it like this:
music-kraken
2022-11-15 09:52:54 +00:00
```
## Dependencies
- ffmpeg
- pandoc
2023-01-13 13:37:15 +00:00
### Notes for Python 3.9
Unfortunately I use features that newly git introduced in [Python 3.10](https://docs.python.org/3/library/types.html#types.UnionType).
So unfortunately you **CAN'T** run this programm with python 3.9. [#10][i10]
2022-11-23 19:07:31 +00:00
### Notes for WSL
2022-11-23 19:12:38 +00:00
If you choose to run it in WSL, make sure ` ~/.local/bin` is added to your `$PATH` [#2][i2]
2022-11-23 19:07:31 +00:00
2022-11-15 09:52:54 +00:00
## Quick-Guide
**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.
2022-11-15 09:52:54 +00:00
**What to download:** After that it prompts you for a search. Here are a couple examples how you can search:
```
2022-11-23 07:37:56 +00:00
> #a <any artist>
searches for the artist <any artist>
2022-11-15 09:52:54 +00:00
2022-11-23 07:37:56 +00:00
> #a <any artist> #r <any releas>
searches for the release (album) <any release> by the artist <any artist>
2022-11-15 09:52:54 +00:00
2022-11-23 07:37:56 +00:00
> #r <any release> Me #t <any track>
searches for the track <any track> from the release <any relaese>
2022-11-15 09:52:54 +00:00
```
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.
2022-11-15 09:52:54 +00:00
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.
2022-10-14 13:23:47 +00:00
---
2023-02-22 17:56:28 +00:00
## CONTRIBUTE
I am happy about every pull request. To contribute look [here](contribute.md).
## Matrix Space
<img align="right" src="assets/element_logo.png" width=100>
I decided against creating a discord server, due to piracy communities get often banned from discord. A good and free Alternative are Matrix Spaces. I reccomend the use of the Client [Element](https://element.io/download). It is completely open source.
**Click [this link](https://matrix.to/#/#music-kraken:matrix.org) _([https://matrix.to/#/#music-kraken:matrix.org](https://matrix.to/#/#music-kraken:matrix.org))_ to join.**
---
2023-02-07 11:00:54 +00:00
# Programming Interface / Use as Library
2023-01-23 15:57:00 +00:00
This application is $100\%$ centered around Data. Thus the most important thing for working with musik kraken is, to understand how I structured the data.
2023-02-27 13:29:09 +00:00
2023-02-27 13:29:27 +00:00
## quick Overview
2023-02-27 13:29:09 +00:00
- explanation of the [Data Model](#data-model)
- how to use the [Data Objects](#data-objects)
2023-01-23 15:57:00 +00:00
2023-02-07 11:00:54 +00:00
```mermaid
2023-02-27 13:29:09 +00:00
---
title: Quick Overview
---
2023-02-07 11:00:54 +00:00
sequenceDiagram
participant pg as Page (eg. YouTube, MB, Musify, ...)
participant obj as DataObjects (eg. Song, Artist, ...)
participant db as DataBase
obj ->> db: write
db ->> obj: read
pg -> obj: find a source for any page, for object.
obj -> pg: add more detailed data from according page.
obj -> pg: if available download audio to target.
```
2023-02-27 13:29:09 +00:00
## Data Model
2023-02-27 13:21:19 +00:00
The Data Structure, that the whole programm is built on looks as follows:
```mermaid
---
title: Music Data
---
erDiagram
2023-02-27 13:23:56 +00:00
Target {
}
Lyrics {
}
2023-02-27 13:21:19 +00:00
Song {
}
Album {
}
Artist {
}
Label {
}
Source {
}
Source }o--|| Song : from
Source }o--|| Lyrics : from
Source }o--|| Album : from
Source }o--|| Artist : from
Source }o--|| Label : from
2023-02-27 13:49:12 +00:00
Song }o--o{ Album : AlbumSong
Album }o--o{ Artist : ArtistAlbum
Song }o--o{ Artist : features
Label }o--o{ Album : LabelAlbum
Label }o--o{ Artist : LabelSong
Song ||--o{ Lyrics : contains
Song ||--o{ Target : points
2023-02-27 13:21:19 +00:00
```
Ok now this **WILL** look intimidating, thus I break it down quickly.
*That is also the reason I didn't add all Attributes here.*
The most important Entities are:
- Song
- Album
- Artist
- Label
All of them *(and Lyrics)* can have multiple Sources, and every Source can only Point to one of those Element.
The `Target` Entity represents the location on the hard drive a Song has. One Song can have multiple download Locations.
The `Lyrics` Entity simply represents the Lyrics of each Song. One Song can have multiple Lyrics, e.g. Translations.
Here is the simplified Diagramm without only the main Entities.
```mermaid
---
title: simplified Music Data
---
erDiagram
Song {
}
Album {
}
Artist {
}
Label {
}
2023-02-27 13:49:12 +00:00
Song }o--o{ Album : AlbumSong
Album }o--o{ Artist : ArtistAlbum
Song }o--o{ Artist : features
2023-02-27 13:21:19 +00:00
2023-02-27 13:49:12 +00:00
Label }o--o{ Album : LabelAlbum
Label }o--o{ Artist : LabelSong
2023-02-27 13:21:19 +00:00
```
2023-03-10 09:54:15 +00:00
Looks way more manageable, doesn't it?
2023-02-27 13:21:19 +00:00
The reason every relation here is a `n:m` *(many to many)* relation is not, that it makes sense in the aspekt of modeling reality, but to be able to put data from many Sources in the same Data Model.
2023-03-10 09:54:15 +00:00
Every Service models Data a bit different, and projecting a one-to-many relationship to a many to many relationship without data loss is easy. The other way around it is basically impossible
2023-02-27 13:21:19 +00:00
2023-02-27 13:29:09 +00:00
## Data Objects
> Not 100% accurate yet and *might* change slightly
2023-01-23 15:57:00 +00:00
2023-03-09 15:14:38 +00:00
### Creation
2023-01-23 15:57:00 +00:00
```python
# importing the libraries I build on
2023-03-10 09:54:15 +00:00
from music_kraken import objects
2023-01-23 15:57:00 +00:00
2023-03-10 09:54:15 +00:00
import pycountry
2023-01-23 15:57:00 +00:00
2023-03-10 09:54:15 +00:00
song = objects.Song(
2023-01-23 15:57:00 +00:00
genre="HS Core",
title="Vein Deep in the Solution",
length=666,
isrc="US-S1Z-99-00001",
tracksort=2,
2023-03-10 09:54:15 +00:00
target=[
objects.Target(file="song.mp3", path="example")
],
lyrics_list=[
objects.Lyrics(text="these are some depressive lyrics", language="en"),
objects.Lyrics(text="Dies sind depressive Lyrics", language="de")
2023-01-23 15:57:00 +00:00
],
2023-03-10 09:54:15 +00:00
source_list=[
objects.Source(objects.SourcePages.YOUTUBE, "https://youtu.be/dfnsdajlhkjhsd"),
objects.Source(objects.SourcePages.MUSIFY, "https://ln.topdf.de/Music-Kraken/")
],
album_list=[
objects.Album(
title="One Final Action",
date=objects.ID3Timestamp(year=1986, month=3, day=1),
language=pycountry.languages.get(alpha_2="en"),
label_list=[
objects.Label(name="an album label")
],
source_list=[
objects.Source(objects.SourcePages.ENCYCLOPAEDIA_METALLUM, "https://www.metal-archives.com/albums/I%27m_in_a_Coffin/One_Final_Action/207614")
]
),
2023-01-23 15:57:00 +00:00
],
main_artist_list=[
2023-03-10 09:54:15 +00:00
objects.Artist(
2023-01-23 15:57:00 +00:00
name="I'm in a coffin",
2023-03-10 09:54:15 +00:00
source_list=[
objects.Source(
objects.SourcePages.ENCYCLOPAEDIA_METALLUM,
"https://www.metal-archives.com/bands/I%27m_in_a_Coffin/127727"
)
]
),
objects.Artist(name="some_split_artist")
],
feature_artist_list=[
objects.Artist(
name="Ruffiction",
label_list=[
objects.Label(name="Ruffiction Productions")
2023-01-23 15:57:00 +00:00
]
)
],
)
2023-03-10 09:54:15 +00:00
print(song.option_string)
for album in song.album_collection:
print(album.option_string)
for artist in song.main_artist_collection:
print(artist.option_string)
2023-01-23 15:57:00 +00:00
```
2023-03-09 15:14:38 +00:00
2023-03-09 21:14:39 +00:00
If you just want to start implementing, then just use the code example, I don't care.
For those who don't want any bugs and use it as intended *(which is recommended, cuz I am only one person so there are defs bugs)* continue reading.
2023-01-23 15:57:00 +00:00
2023-03-09 15:14:38 +00:00
## Appending and Merging data
If you want to append for example a Song to an Album, you obviously need to check beforehand if the Song already exists in the Album, and if so, you need to merge their data in one Song object, to not loose any Information.
Fortunately I implemented all of this functionality in [objects.Collection](#collection).append(music_object).
I made a flow chart showing how it works:
```mermaid
---
title: "Collection.append(music_object: MusicObject)"
---
flowchart TD
exist("""
<b>Check if music_object already exists.</b>
<hr>
2023-03-10 10:09:05 +00:00
Gets all indexing values with <code>music_object.indexing_values</code>.
If any returned value exists in <code>Collection._attribute_to_object_map</code>,
2023-03-09 15:14:38 +00:00
the music_object exists
""")
2023-03-10 10:09:05 +00:00
subgraph merge["Merging"]
_merge("""merges the passed in object in the already
existing whith <code>existing.merge(new)</code>""")
_map("""In case a new source or something simmilar
has been addet, it maps the existing object again.
""")
2023-03-10 11:36:28 +00:00
_merge --> _map
2023-03-10 10:09:05 +00:00
2023-03-09 15:14:38 +00:00
end
2023-03-10 10:09:05 +00:00
subgraph add["Adding"]
2023-03-10 11:36:28 +00:00
__map("""map the values from <code>music_object.indexing_values</code>
to <code>Collection._attribute_to_object_map</code> by writing
those values in the map as keys, and the class I wanna add as values.
""")
_add("""add the new music object to <code>_data</code>""")
__map --> _add
2023-03-09 15:14:38 +00:00
end
2023-03-10 11:36:28 +00:00
exist-->|"if it doesn't exist"|add --> return
exist-->|"if already exists"|merge --> return
2023-03-09 15:14:38 +00:00
```
2023-03-10 11:36:28 +00:00
This is Implemented in [music_kraken.objects.Collection.append()](src/music_kraken/objects/collection.py).
The <u>indexing values</u> are defined in the superclass [DatabaseObject](src/music_kraken/objects/parents.py) and get implemented for each Object seperately. I will just give as example its implementation for the `Song` class:
```python
@property
def indexing_values(self) -> List[Tuple[str, object]]:
return [
('id', self.id),
('title', self.unified_title),
('barcode', self.barcode),
*[('url', source.url) for source in self.source_collection]
]
```
2023-03-09 15:14:38 +00:00
## Classes and Objects
### music_kraken.objects
#### Collection
#### Song
2023-01-23 15:57:00 +00:00
2023-03-10 10:09:05 +00:00
So as you can see, the probably most important Class is the `music_kraken.Song` class. It is used to save the song in *(duh)*.
2023-01-23 15:57:00 +00:00
2023-03-10 10:09:05 +00:00
It has handful attributes, where half of em are self-explanatory, like `title` or `genre`. The ones like `isrc` are only relevant to you, if you know what it is, so I won't elaborate on it.
2023-01-23 15:57:00 +00:00
Interesting is the `date`. It uses a custom class. More on that [here](#music_krakenid3timestamp).
2023-03-09 15:14:38 +00:00
#### ID3Timestamp
2023-01-23 15:57:00 +00:00
For multiple Reasons I don't use the default `datetime.datetime` class.
The most important reason is, that you need to pass in at least year, month and day. For every other values there are default values, that are indistinguishable from values that are directly passed in. But I need optional values. The ID3 standart allows default values. Additionally `datetime.datetime` is immutable, thus I can't inherint all the methods. Sorry.
2023-03-10 10:09:05 +00:00
Anyway you can create those custom objects easily.
2023-01-23 15:57:00 +00:00
```python
from music_kraken import ID3Timestamp
# returns an instance of ID3Timestamp with the current time
ID3Timestamp.now()
# yea
ID3Timestamp(year=1986, month=3, day=1)
```
you can pass in the Arguments:
- year
- month
- day
- hour
- minute
- second
:)
2023-02-07 11:00:54 +00:00
# Old implementation
2023-01-23 15:57:00 +00:00
2023-03-10 11:36:28 +00:00
> IF U USE THIS NOW YOU ARE DUMB *no offense thoug*. IT ISN'T FINISHED AND THE STUFF YOU CODE NOW WILL BE BROKEN TOMORROW
2023-01-13 13:39:43 +00:00
> SOON YOU CAN THOUGH
2022-11-23 18:15:55 +00:00
If you want to use this project, or parts from it in your own projects from it,
make sure to be familiar with [Python Modules](https://docs.python.org/3/tutorial/modules.html).
Further and better documentation including code examples are yet to come, so here is the rough
module structure for now. (Should be up-to-date, but no guarantees)
2022-11-24 14:55:50 +00:00
If you simply want to run the builtin minimal cli just do this:
2022-11-23 18:15:55 +00:00
```python
2022-11-24 14:55:50 +00:00
from music_kraken import cli
2022-11-23 18:15:55 +00:00
2022-11-24 14:55:50 +00:00
cli()
2022-11-23 18:15:55 +00:00
```
### Search for Metadata
The whole program takes the data it processes further from the cache, a sqlite database.
2022-11-24 14:42:50 +00:00
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
2022-11-24 14:42:50 +00:00
- an artist
- a release group
- a release
- a recording/track).
2022-11-24 14:42:50 +00:00
To get this info, you first have to initialize a search object (`music_kraken.MetadataSearch`).
2022-11-23 18:15:55 +00:00
```python
2022-11-24 14:42:50 +00:00
search_object = music_kraken.MetadataSearch()
2022-11-23 18:15:55 +00:00
```
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:
```python
# 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.
2022-11-23 18:15:55 +00:00
```python
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.
2022-11-24 14:42:50 +00:00
To explore and select one options from `MultipleOptions`, simply call `MetadataSearch.choose(self, index: int)`.
2022-11-23 18:15:55 +00:00
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***
```python
# 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:
```python
2022-11-24 14:42:50 +00:00
multiple_options = search_object.get_previous_options()
2022-11-23 18:15:55 +00:00
```
### Downloading Metadata / Filling up the Cache
2022-11-24 14:42:50 +00:00
You can download following metadata:
2022-11-23 18:15:55 +00:00
- an artist (the whole discography)
- a release group
- a release
- a track/recording
2022-11-24 14:42:50 +00:00
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.
```python
2022-11-24 14:55:50 +00:00
from music_kraken import fetch_metadata_from_search
2022-11-24 14:42:50 +00:00
# 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.
2022-11-23 18:15:55 +00:00
```python
2022-11-24 14:55:50 +00:00
from music_kraken import fetch_metadata
2022-11-24 14:42:50 +00:00
# might change and break after I add multiple metadata sources which I will
fetch_metadata(id_=musicbrainz_id, type=metadata_type)
2022-11-23 18:15:55 +00:00
```
2022-11-24 14:42:50 +00:00
The option type is a string (*I'm sorry for not making it an enum I know its a bad pratice*), which can
2022-11-23 18:15:55 +00:00
have following values:
- 'artist'
- 'release_group'
- 'release'
- 'recording'
2022-11-24 14:55:50 +00:00
**PAY ATTENTION TO TYPOS, IT'S CASE SENSITIVE**
2022-11-23 18:15:55 +00:00
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:
2022-11-23 18:15:55 +00:00
```python
2023-01-30 22:54:21 +00:00
music_kraken.test_db
2022-11-23 18:15:55 +00:00
```
When fetching any song data from the cache, you will get it as Song
object (music_kraken.Song). There are multiple methods
2022-11-23 18:15:55 +00:00
to get different sets of Songs. The names explain the methods pretty
well:
```python
2022-11-24 14:55:50 +00:00
from music_kraken import cache
2022-11-23 18:15:55 +00:00
# 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.
2022-11-29 11:23:36 +00:00
2022-11-24 11:10:00 +00:00
### Setting the Target
2022-11-24 08:20:44 +00:00
2022-11-24 11:10:00 +00:00
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:
```python
2022-11-24 14:55:50 +00:00
from music_kraken import set_target
2022-11-24 11:10:00 +00:00
# adds file path, file directory and the genre to the database
2022-11-24 14:55:50 +00:00
set_target(genre="some test genre")
2022-11-24 11:10:00 +00:00
```
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.
2022-11-24 11:10:00 +00:00
2022-11-24 13:56:51 +00:00
As a result of this decision you will have to pass the genre in this function.
2022-11-24 11:10:00 +00:00
### Get Audio
2022-11-24 11:10:00 +00:00
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% (?)
2022-11-24 11:10:00 +00:00
2022-11-24 13:59:34 +00:00
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.
2022-11-24 11:10:00 +00:00
```python
# Here is an Example
from music_kraken import (
cache,
fetch_sources,
fetch_audios
)
2022-11-24 11:10:00 +00:00
# scanning pages, searching for a download and storing results
fetch_sources(cache.get_tracks_without_src())
2022-11-24 11:10:00 +00:00
# downloading all previously fetched sources to previously defined targets
fetch_audios(cache.get_tracks_to_download())
2022-11-24 11:10:00 +00:00
```
2022-11-24 11:10:00 +00:00
*Note:*
To download audio two cases have to be met:
2022-11-24 13:56:51 +00:00
1. [The target](#setting-the-target) has to be set beforehand
2. The sources have to be fetched beforehand
---
2022-10-14 13:23:47 +00:00
## Metadata
2022-11-24 14:42:50 +00:00
First the metadata has to be downloaded. The best api to do so is undeniably [Musicbrainz][mb]. This is a result of them being a website with a large Database spanning over all Genres.
### Musicbrainz
2022-10-14 13:23:47 +00:00
![Musicbrainz Data Scheme](https://wiki.musicbrainz.org/-/images/9/9e/pymb3-model-core.png)
To fetch from [Musicbrainz][mb] 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.
If the following chosen element is an artist, its discography + a couple tracks are printed, if a release is chosen, the artists + tracklist + release is outputted, If a track is chosen its artists and releases are shown.
For 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`. The following I fetch and tag the MP3 with:
- title
- artist
- albumartist
- tracknumber
- albumsort can sort albums cronological
- titlesort is just set to the tracknumber to sort by track order to sort correctly
- isrc
- musicbrainz_artistid
- musicbrainz_albumid
- musicbrainz_albumartistid
- musicbrainz_albumstatus
- language
- musicbrainz_albumtype
- releasecountry
- barcode
#### albumsort/titlesort
Those Tags are for the musicplayer to not sort for Example the albums of a band alphabetically, but in another way. I set it just to chronological order
#### isrc
This is the **international standart release code**. With this a track can be identified 99% of the time, if it is known and the website has a search api for that. Obviously this will get important later.
## Download
Now that the metadata is downloaded and cached, download sources need to be sound, because one can't listen to metadata. Granted it would be amazing if that would be possible.
### Musify
The quickest source to get download links from is to my knowledge [musify](https://musify.club/). It's 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 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:
```json
[
{
"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
2022-10-26 08:28:49 +00:00
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?
2022-10-26 08:28:49 +00:00
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.
2022-10-26 08:28:49 +00:00
2022-11-06 22:01:03 +00:00
## Lyrics
To get the Lyrics, I scrape them, and put those in the USLT ID3 Tags of for example mp3 files. Unfortunately some players, like the one I use, Rhythmbox don't support USLT Lyrics. So I created an Plugin for Rhythmbox. You can find it here: [https://github.com/HeIIow2/rythmbox-id3-lyrics-support](https://github.com/HeIIow2/rythmbox-id3-lyrics-support).
### Genius
For the lyrics source the page [https://genius.com/](https://genius.com/) is easily sufficient. It has most songs. Some songs are not present though, but that is fine, because the lyrics are optional anyways.
2022-11-23 19:12:38 +00:00
2023-01-13 13:37:15 +00:00
[i10]: https://github.com/HeIIow2/music-downloader/issues/10
2022-11-23 19:13:16 +00:00
[i2]: https://github.com/HeIIow2/music-downloader/issues/2
2022-11-27 09:14:55 +00:00
[mb]: https://musicbrainz.org/