-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from cooperhammond/crystal-port
Crystal port
- Loading branch information
Showing
41 changed files
with
1,769 additions
and
1,631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*.cr] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,14 @@ | ||
# General stuff to ignore. | ||
*.pyc | ||
/dist/ | ||
/*.egg-info/ | ||
/build/ | ||
__pycache__/ | ||
.eggs | ||
/docs/ | ||
/lib/ | ||
/bin/ | ||
/logs/ | ||
/.shards/ | ||
/Music/ | ||
*.dwarf | ||
|
||
# For easy updating of stuff. | ||
update_pypi_and_github.py | ||
|
||
# Currently in progress | ||
/flexx-app/ | ||
/.idea/ | ||
*test.py | ||
|
||
# Temporarily downloaded files | ||
*.mp3 | ||
*.zip | ||
*.part | ||
*.webm | ||
|
||
# Coverage files | ||
.coverage | ||
|
||
# Temporarily built binaries | ||
ffmpeg binaries/ | ||
|
||
# vscode work space | ||
.vscode/ | ||
*.webm* | ||
.ripper.log | ||
ffmpeg | ||
ffprobe | ||
youtube-dl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: crystal | ||
|
||
# Uncomment the following if you'd like Travis to run specs and check code formatting | ||
# script: | ||
# - crystal spec | ||
# - crystal tool format --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,177 @@ | ||
# Ironic Redistribution System | ||
# irs: The Ironic Repositioning System | ||
|
||
[](http://www.gnu.org/licenses/gpl.html) | ||
[](https://github.com/kepoorhampond/irs/stargazers) | ||
[](https://saythanks.io/to/kepoorhampond) | ||
[](https://pypi.python.org/pypi/irs) | ||
[](https://crystal-lang.org/) | ||
[](https://github.com/cooperhammond/irs/blob/master/LICENSE) | ||
[](https://saythanks.io/to/kepoorh%40gmail.com) | ||
|
||
> A music downloader that understands your metadata needs. | ||
> A music scraper that understands your metadata needs. | ||
A tool to download your music with metadata. It uses [Spotify](https://www.spotify.com/) for finding metadata and [Youtube](https://www.youtube.com/) for the actual audio source. You will need to have some Spotify tokens, the instructions to set them up are [here](https://github.com/kepoorhampond/irs#spotify-tokens). | ||
`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. | ||
|
||
Works with Python 2 and 3. | ||
<p align="center"> | ||
<img src="https://i.imgur.com/7QTM6rD.png" height="400" title="#1F816D" /> | ||
</p> | ||
<p align="center" | ||
|
||
## Install and Setup | ||
``` | ||
$ sudo pip install irs | ||
$ irs --setup | ||
``` | ||
[](https://forthebadge.com) | ||
[](https://forthebadge.com) | ||
[](https://forthebadge.com) | ||
</p> | ||
|
||
**You will need to have some Spotify tokens, the instructions to set them up are [here](https://github.com/kepoorhampond/irs#spotify-tokens).** | ||
--- | ||
|
||
## Table of Contents | ||
|
||
## Demo and Usages | ||
- [Usage](#usage) | ||
- [Demo](#demo) | ||
- [Installation](#installation) | ||
- [Pre-built](#pre-built) | ||
- [From source](#from-source) | ||
- [Set up](#setup) | ||
- [Config](#config) | ||
- [How it works](#how-it-works) | ||
- [Contributing](#contributing) | ||
|
||
The usages can be found with the `-h` or `--help` flag: | ||
``` | ||
usage: irs [-h] [-S] [-a ARTIST] [-s SONG] [-A ALBUM] [-p PLAYLIST] | ||
[-u USERNAME] [-o ORGANIZATION] | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
-S, --setup Run this by itself to setup config files and folder | ||
for irs and download the ffmpeg binaries | ||
-a ARTIST, --artist ARTIST | ||
Specify artist name. Must be used with -s/--song or | ||
-A/--album | ||
-s SONG, --song SONG Specify song name. Must be used with -a/--artist | ||
-A ALBUM, --album ALBUM | ||
Specify album name. Can be used by itself. | ||
-p PLAYLIST, --playlist PLAYLIST | ||
Specify playlist name. Must be used with -A/--album | ||
-u USERNAME, --username USERNAME | ||
Specify user name for playlist. Must be used with | ||
-A/--album | ||
-o ORGANIZATION, --organization ORGANIZATION | ||
Specify type of organization for list. Used when | ||
downloading spotify playlist/album | ||
``` | ||
|
||
So all of these are valid commands: | ||
``` | ||
$ irs -a "Brandon Flowers" -s "Lonely Town" | ||
$ irs -u "spotify" -p "Brain Food" | ||
$ irs -A "Suicide Squad: The Album" | ||
``` | ||
But these are not: | ||
## Usage | ||
|
||
``` | ||
$ irs -s "Bohemian Rhapsody" | ||
$ irs -p "Best Nirvana" | ||
~ $ 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 | ||
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 | ||
``` | ||
|
||
## Spotify Tokens | ||
|
||
To download metadata through spotify, you'll want to head to their Dev Apps page, [here](https://developer.spotify.com/my-applications/). After doing that you'll want to create a new app. Name it whatever you want and then once you've done that, find the `Client ID` and `Client Secret` keys. You'll want to take those keys and paste them into your system's environment variables as `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`, correspondingly. Voilà! You can now download metadata with IRS! | ||
|
||
## Metadata | ||
|
||
Currently, the program attaches the following metadata to the downloaded files: | ||
- Title | ||
- Artist | ||
- Album | ||
- Album Art | ||
- Genre | ||
- Track Number | ||
- Disc Number | ||
|
||
## Wishlist | ||
|
||
- [x] Full album downloading | ||
- [x] Album art metadata correctly displayed | ||
- [x] Spotify playlist downloading | ||
- [ ] Comment metadata | ||
- [ ] Compilation metadata | ||
- [ ] GUI/Console interactive version - *in progress* | ||
- [ ] Lyric metadata | ||
### Demo | ||
|
||
[](https://asciinema.org/a/332793) | ||
|
||
## Installation | ||
|
||
### Pre-built | ||
|
||
Just download the latest release for your platform | ||
[here](https://github.com/cooperhammond/irs/releases). | ||
|
||
### From Source | ||
|
||
If you're one of those cool people who compiles from source | ||
|
||
1. Install crystal-lang | ||
([`https://crystal-lang.org/install/`](https://crystal-lang.org/install/)) | ||
1. Clone it (`git clone https://github.com/cooperhammond/irs`) | ||
1. CD it (`cd irs`) | ||
1. Build it (`shards build`) | ||
|
||
### Setup | ||
|
||
1. Create a `.yaml` config file somewhere on your system (usually `~/.irs/`) | ||
1. Copy the following into it | ||
```yaml | ||
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 | ||
``` | ||
1. Set the environment variable `IRS_CONFIG_LOCATION` pointing to that file | ||
1. Go to [`https://developer.spotify.com/dashboard/`](https://developer.spotify.com/dashboard/) | ||
1. Log in or create an account | ||
1. Click `CREATE A CLIENT ID` | ||
1. Enter all necessary info, true or false, continue | ||
1. Find your client key and client secret | ||
1. Copy each respectively into the X's in your config file | ||
1. 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: | ||
```yaml | ||
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`](https://github.com/ytdl-org/youtube-dl), extract the audio using | ||
[`ffmpeg`](https://ffmpeg.org/), 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 | ||
1. It was a charlie foxtrot of code that I made when I was little and I wanted | ||
to refine it | ||
1. `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](mailto:[email protected]). 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 |
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.