Git Product home page Git Product logo

heiiow2 / music-downloader Goto Github PK

View Code? Open in Web Editor NEW
65.0 2.0 8.0 398.98 MB

This program will first get the metadata of various songs from metadata providers like musicbrainz, and then search for download links on pages like bandcamp. Then it will download the song and edit the metadata accordingly.

License: GNU Affero General Public License v3.0

Python 99.76% Shell 0.24%
cli command-line lyrics music python python310

music-downloader's Introduction

Music Kraken

music kraken logo


Installation

You can find and get this project from either PyPI as a Python-Package, or simply the source code from GitHub. 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.

THE PyPI PACKAGE IS OUTDATED

From source

if you use Debian or Ubuntu:

git clone https://github.com/HeIIow2/music-downloader
sudo apt install pandoc

cd music-downloader/
python3 -m pip install -r requirements.txt 

then you can add to ~/.bashrc

alias music-kraken='cd your/directory/music-downloader/src; python3 -m music_kraken'
alias 🥺='sudo'
source ~/.bashrc
music-kraken

Notes for WSL

If you choose to run it in WSL, make sure ~/.local/bin is added to your $PATH #2

Quick-Guide

The Genre you define at the start, is the folder my program will download the files into, as well as the value of the ID3 genre field.

When it drops you into the shell 2 main things are important:

  1. You search with s: <query/url>
  2. You choose an option with just the index number of the option
  3. You download with d: <options/url>, where the options are comma separated

Query

The syntax for the query is really simple.

> s: #a <any artist>
searches for the artist <any artist>

> s: #a <any artist> #r <any release>
searches for the release (album) <any release> by the artist <any artist>

> s: #r <any release> Me #t <any track>
searches for the track <any track> from the release <any relaese>

The escape character is as usual \.


CONTRIBUTE

I am happy about every pull request. To contribute look here.

Matrix Space

music-kraken logo

I decided against creating a discord server, due to various communities get often banned from discord. A good and free Alternative are Matrix Spaces. I recommend the use of the Client Element. It is completely open source.

Click this invitation (https://matrix.to/#/#music-kraken:matrix.org) to join.

TODO till the next release

These Points will most likely be in the changelogs.

  • Migrate away from pandoc, to a more lightweight alternative, that can be installed over PiPY.
  • Update the Documentation of the internal structure. (could be pushed back one release)

Programming Interface / Use as Library

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.

Quick Overview

---
title: Quick Overview (outdated)
---
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.

Data Model

The Data Structure, that the whole programm is built on looks as follows:

---
title: Music Data
---
erDiagram



Target {

}

Lyrics {

}

Song {

}

Album {

}

Artist {

}

Label {

}

Source {

}

Source }o--|| Song : ""
Source }o--|| Lyrics : ""
Source }o--|| Album : ""
Source }o--|| Artist : ""
Source }o--|| Label : ""

Song }o--o{ Album : AlbumSong
Album }o--o{ Artist : ArtistAlbum
Song }o--o{ Artist : "ArtistSong (features)"

Label }o--o{ Album : LabelAlbum
Label }o--o{ Artist : LabelSong

Song ||--o{ Lyrics : ""
Song ||--o{ Target : ""

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.

---
title: simplified Music Data
---
erDiagram

Song {

}

Album {

}

Artist {

}

Label {

}

Song }o--o{ Album : AlbumSong
Album }o--o{ Artist : ArtistAlbum
Song }o--o{ Artist : "ArtistSong (features)"

Label }o--o{ Album : LabelAlbum
Label }o--o{ Artist : LabelSong

Looks way more manageable, doesn't it?

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.
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

Data Objects

Not 100% accurate yet and might change slightly

Creation

# needs to be added

If you just want to start implementing, then just use the code example I provided, 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, and read the whole documentation, which may exist in the future xD

music-downloader's People

Contributors

ethansocal avatar feyokorenhof avatar gabrieleancillai avatar heiiow2 avatar jamesclarke7283 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

music-downloader's Issues

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Hello!
After installing the program using pip, I get the following error when running it.
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/bin/music-kraken", line 5, in <module> from music_kraken import cli File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/music_kraken/__init__.py", line 15, in <module> from .lyrics import lyrics File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/music_kraken/lyrics/lyrics.py", line 5, in <module> from . import genius File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/music_kraken/lyrics/genius.py", line 25, in <module> class Song: File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/music_kraken/lyrics/genius.py", line 66, in Song def fetch_lyrics(self) -> str | None: TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
I'm on MacOS Big Sur, Python 3.9.4
Would someone mind checking this out?

Error when downloading something from yt

q to quit, ok to download, .. for previous options, . for current options, int for this element: 13
artists: 1; releases 1; tracks 10
0) artist: 'Lorna Shore' from US, 'American deathcore band'

  1. release: 'Immortal'
  2. track: 'Darkest Spawn'
  3. track: 'Death Portrait'
  4. track: 'Hollow Sentence'
  5. track: 'Immortal'
  6. track: 'King Ov Deception'
  7. track: 'Misery System'
  8. track: 'Obsession'
  9. track: 'Relentless Torment'
  10. track: 'This Is Hell'
  11. track: 'Warpath of Disease'

q to quit, ok to download, .. for previous options, . for current options, int for this element: ok
INFO:root:Starting Downloading of metadata
INFO:root:Fetching Download Links
[download] Downloading playlist: GBDHC2012001
[youtube:search] query "GBDHC2012001": Downloading page 1
[youtube:search] query "GBDHC2012001": Downloading page 2
[youtube:search] playlist GBDHC2012001: Downloading 0 videos
[download] Finished downloading playlist: GBDHC2012001
Traceback (most recent call last):
File "/home/lars/Projekts/big projects/music-downloader/src/main.py", line 104, in
cli(start_at=0)
File "/home/lars/Projekts/big projects/music-downloader/src/main.py", line 92, in cli
download_links.Download(file=STEP_TWO_CACHE, metadata_csv=STEP_ONE_CACHE, temp=TEMP, session=session)
File "/media/lars/Volume/Projekts/big projects/music-downloader/src/download_links.py", line 29, in init
youtube_url = youtube_music.get_youtube_url(row)
File "/media/lars/Volume/Projekts/big projects/music-downloader/src/youtube_music.py", line 31, in get_youtube_url
result = get_youtube_from_isrc(row['isrc'])
File "/media/lars/Volume/Projekts/big projects/music-downloader/src/youtube_music.py", line 17, in get_youtube_from_isrc
video = ydl.extract_info(f"ytsearch:{isrc}", download=False)['entries'][0]
IndexError: list index out of range

Using track name as a secondary option

I think that the current approach of only using ISRC for YouTube searches is a bit problematic. While it's correct that YouTube finds it out quickly via ISRC, not all songs there have ISRCs (as YouTube cares less about music than, say, Spotify), and sometimes the music just appears on the top through a search of its name. I am also not sure about how music-kraken handles music in different languages - musicbrainz tends to list their transcription - and rather lists its original name as an alias
It would be nice if the scraper searches for the name if both ISRC and Musify fails.

use yt-dlp instead of youtube-dl

yt-dlp doesn't seem to have the same download speed restrictions that youtube-dl does.

It might even be a drop in replacement?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.