e
Go to file
Cooper Hammond 58895e2e87
Merge pull request #66 from Who23/youtube-sources
Add ability to specifiy youtube URLs manually

Looks like wonderful stuff, I appreciate the contribution and time investment to my small homebrew project, I hope you've been getting good stuff out of it.
2020-09-08 13:54:58 -06:00
spec Updated to v1.0.0 2020-02-21 12:00:27 -07:00
src URL source for albums/playlists & Youtube module improvements 2020-09-07 18:16:31 -04:00
.editorconfig Updated to v1.0.0 2020-02-21 12:00:27 -07:00
.gitignore README updata, it's pretty AND useful now 2020-05-21 19:27:39 -07:00
.travis.yml Updated to v1.0.0 2020-02-21 12:00:27 -07:00
LICENSE nothing affecting functionality, all meta changes 2020-05-15 09:16:50 -07:00
README.md URL source for albums/playlists & Youtube module improvements 2020-09-07 18:16:31 -04:00
shard.lock up to date with .35 specs and standards 2020-08-31 14:35:22 -06:00
shard.yml up to date with .35 specs and standards 2020-08-31 14:35:22 -06:00

irs: The Ironic Repositioning System

made-with-crystal License: MIT Say Thanks

A music scraper that understands your metadata needs.

irs is a command-line application that downloads audio and metadata in order to package an mp3 with both. Extensible, the user can download individual songs, entire albums, or playlists from Spotify.

forthebadge forthebadge forthebadge


Table of Contents

Usage

~ $ irs -h

Usage: irs [--help] [--version] [--install]
           [-s <song> -a <artist>]
           [-A <album> -a <artist>]
           [-p <playlist> -a <username>]

Arguments:
    -h, --help                  Show this help message and exit
    -v, --version               Show the program version and exit
    -i, --install               Download binaries to config location
    -c, --config                Show config file location
    -a, --artist <artist>       Specify artist name for downloading
    -s, --song <song>           Specify song name to download
    -A, --album <album>         Specify the album name to download
    -p, --playlist <playlist>   Specify the playlist name to download
    -u, --url <url>             Specify the youtube url to download from (for single songs only)
    -g, --give-url              Specify the youtube url sources while downloading (for albums or playlists only only)

Examples:
    $ irs --song "Bohemian Rhapsody" --artist "Queen"
    # => downloads the song "Bohemian Rhapsody" by "Queen"
    $ irs --album "Demon Days" --artist "Gorillaz"
    # => downloads the album "Demon Days" by "Gorillaz"
    $ irs --playlist "a different drummer" --artist "prakkillian"
    # => downloads the playlist "a different drummer" by the user prakkillian

Demo

asciicast

Installation

Pre-built

Just download the latest release for your platform here.

Note that the binaries right now have only been tested on WSL. They should run on most linux distros, and OS X, but if they don't please make an issue above.

From Source

If you're one of those cool people who compiles from source

  1. Install crystal-lang (https://crystal-lang.org/install/)
  2. Clone it (git clone https://github.com/cooperhammond/irs)
  3. CD it (cd irs)
  4. Build it (shards build)

Setup

  1. Create a .yaml config file somewhere on your system (usually ~/.irs/)
  2. Copy the following into it
    binary_directory: ~/.irs/bin
    music_directory: ~/Music
    client_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    client_secret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    single_folder_playlist:
        enabled: true
        retain_playlist_order: true
        unify_into_album: false
    
  3. Set the environment variable IRS_CONFIG_LOCATION pointing to that file
  4. Go to https://developer.spotify.com/dashboard/
  5. Log in or create an account
  6. Click CREATE A CLIENT ID
  7. Enter all necessary info, true or false, continue
  8. Find your client key and client secret
  9. Copy each respectively into the X's in your config file
  10. Run irs --install and answer the prompts!

You should be good to go! Run the file from your command line to get more help on usage or keep reading!

Config

You may have noticed that there's a config file with more than a few options. Here's what they do:

binary_directory: ~/.irs/bin
music_directory: ~/Music
client_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
client_secret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
single_folder_playlist:
    enabled: true
    retain_playlist_order: true
    unify_into_album: false
  • binary_directory: a path specifying where the downloaded binaries should be placed
  • music_directory: a path specifying where downloaded mp3s should be placed. Note that there will be more structure created inside that folder, usually in the format of music-dir>artist-name>album-name>track
  • client_key: a client key from your spotify API application
  • client_secret: a client secret key from your spotify API application
  • single_folder_playlist/enabled: if set to true, all mp3s from a downloaded playlist will be placed in the same folder.
  • single_folder_playlist/retain_playlist_order: if set to true, the track numbers of the mp3s of the playlist will be overwritten to correspond to their place in the playlist
  • single_folder_playlist/unify_into_album: if set to true, will overwrite the album name and album image of the mp3 with the title of your playlist and the image for your playlist respectively

How it works

At it's core irs downloads individual songs. It does this by interfacing with the Spotify API, grabbing metadata, and then searching Youtube for a video containing the song's audio. It will download the video using youtube-dl, extract the audio using ffmpeg, and then pack the audio and metadata together into an MP3.

From the core, it has been extended to download the index of albums and playlists through the spotify API, and then iteratively use the method above for downloading each song.

It used to be in python, but

  1. I wasn't a fan of python's limited ability to distribute standalone binaries
  2. It was a charlie foxtrot of code that I made when I was little and I wanted to refine it
  3. crystal-lang made some promises and I was interested in seeing how well it did (verdict: if you're building high-level tools you want to run quickly and distribute, it's perfect)

Contributing

Any and all contributions are welcome. If you think of a cool feature, send a PR or shoot me an email. If you think something could be implemented better, please shoot me an email. If you like what I'm doing here, pretty please shoot me an email.

  1. Fork it (https://github.com/your-github-user/irs/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request