Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Silas Rosenkranz committed Mar 7, 2019
0 parents commit a025451
Show file tree
Hide file tree
Showing 138 changed files with 17,911 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_PATH=/path/to/spotify-ripper-web/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM node:10.15.1-alpine AS base


######
# spotify-ripper-docker
######

FROM base AS srd

WORKDIR /spotify-ripper-docker
COPY ./spotify-ripper-docker ./


######
# spotify-ripper-web-frontend
######

FROM base AS srwf

WORKDIR /spotify-ripper-web-frontend

COPY ./spotify-ripper-web-frontend/package.json ./
COPY ./spotify-ripper-web-frontend/yarn.lock ./
RUN yarn install

COPY ./spotify-ripper-web-frontend .
RUN yarn run build


######
# spotify-ripper-web-backend
######

FROM base AS srwb

WORKDIR /spotify-ripper-web-backend

COPY ./spotify-ripper-web-backend/package*.json ./
RUN npm install

COPY ./spotify-ripper-web-backend ./


######
# composed
######

FROM base AS release

COPY --from=srd /spotify-ripper-docker /spotify-ripper-docker
COPY --from=srwf /spotify-ripper-web-frontend /spotify-ripper-web-frontend
COPY --from=srwb /spotify-ripper-web-backend /spotify-ripper-web-backend

EXPOSE 3000

COPY ./entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "sh", "entrypoint.sh" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 hedwiggggg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# spotify-ripper-web
## Introduction

This repository aimed to create an easy-to-use web interface for the spotify-ripper. Archiving this goal I had the following point in the back of my head:

- Parallel downloads of multiple users

So I decided on the following project structure:

spotify-ripper-docker:
- This is just a dockerized version of the spotify-ripper, including some adjustments to better handle the standard data streams and bring them to the web interface.

spotify-ripper-web-backend:
- This is a node.js application which communicates with the frontend via websockets.
- It creates and starts new containers and forwards the standard data streams to the UI via Websocket.

spotify-ripper-web-frontend:
- This is a vue.js spa, communicating with the node.js backend; Here you can also finally download the music.

## Things that aren't so beautiful:

- The project actually consists of three projects, which would probably have been much more intelligent to separate.
- No TDD; not even the vue.js project
- Implemented the spotify-ripper as a zip file; this would also be a separate project...
- Not as much use of environment vars as I should have; there are some things hardcoded, like the websocket port
- Not the worst and ugliest code; but alsonot the cleanest one..

## Installation

The installation should be quite simple by dockerization.

### Prequesites

1. Installing docker and docker-compose
2. rename `.env.example` to `.env` and change the path according tr environment.
3. add your `spotify_appkey.key` to the `spotify-ripper-docker` folder
4. (adjust `docker-compose.yml` to mount your docker.sock)

### Run the application

To do this you can simply run `docker-compose up --build` (Depending on how you configured Docker, sudo may be required)

FYI: This whole repo is optimized and tested on Ubuntu 18.04.

If all went well, it should look something like this: (remember that port 3000 is in the container and mapped outside by your adjustments in the `docker-compose.yml`)

![Console](/screenshots/screenshot_1.png "Console")

Then you should be able to access it by `http://localhost:<your_port>/web/`

## Screenshots

![spotify-ripper web-ui](/screenshots/screenshot_2.png "spotify-ripper web-ui")
![spotify-ripper web-ui](/screenshots/screenshot_3.png "spotify-ripper web-ui")
![spotify-ripper web-ui](/screenshots/screenshot_4.png "spotify-ripper web-ui")
![spotify-ripper web-ui](/screenshots/screenshot_5.png "spotify-ripper web-ui")
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.7"

services:
spotify-ripper-web:
build: ./

restart: unless-stopped

ports:
- "80:3000"
- "81:3300"

volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./ripped_music:/ripped_music

environment:
APP_PATH: ${APP_PATH}
23 changes: 23 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

pid_node=0

term_handler() {
if [ $pid_node -ne 0 ]; then
kill -SIGTERM "$pid_node"
wait "$pid_node"
fi

exit 130;
}

trap term_handler INT TERM

node ./spotify-ripper-web-backend/app.js &
pid_node="$!"

while true
do
sleep 1

done
2 changes: 2 additions & 0 deletions ripped_music/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Binary file added screenshots/screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions spotify-ripper-docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
1 change: 1 addition & 0 deletions spotify-ripper-docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spotify_appkey.key
43 changes: 43 additions & 0 deletions spotify-ripper-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM debian:stretch-slim

ENV LANG C.UTF-8

ARG DEBIAN_FRONTEND=noninteractive

# Install packages
RUN apt-get update -qy && apt-get upgrade -qy
RUN apt-get install nano wget lame build-essential libffi-dev python-pip python-dev python3-dev python3-pip libffi-dev -y

WORKDIR /dependencies

# Download libspotify & compile it
COPY ./dependencies/libspotify-12.1.51-Linux-x86_64-release.tar.gz ./libspotify-12.1.51-Linux-x86_64-release.tar.gz
RUN tar xvf libspotify-12.1.51-Linux-x86_64-release.tar.gz && \
rm -f libspotify-12.1.51-Linux-x86_64-release.tar.gz && \
cd libspotify-12.1.51-Linux-x86_64-release && \
make install prefix=/usr/local

# Install required tools for support for AAC (M4A container)
COPY ./dependencies/libfdk-aac-dev_0.1.4-2+b1_amd64.deb ./libfdk-aac-dev_0.1.4-2+b1_amd64.deb
COPY ./dependencies/libfdk-aac1_0.1.4-2+b1_amd64.deb ./libfdk-aac1_0.1.4-2+b1_amd64.deb
RUN apt-get install pkg-config automake autoconf -y && \
dpkg -i libfdk-aac1_0.1.4-2+b1_amd64.deb && dpkg -i libfdk-aac-dev_0.1.4-2+b1_amd64.deb

# Compile libfdk-aac encoder
COPY ./dependencies/v0.6.2.tar.gz ./v0.6.2.tar.gz
RUN tar xvf v0.6.2.tar.gz && \
rm -f v0.6.2.tar.gz && cd fdkaac-0.6.2 && \
autoreconf -i && ./configure && make install

# Install a fork of spotify-ripper
COPY ./dependencies/spotify-ripper-morgaroth-2.9.6.tar.gz ./spotify-ripper-morgaroth-2.9.6.tar.gz
RUN pip3 install spotify-ripper-morgaroth-2.9.6.tar.gz

WORKDIR /

# Link our download location to /data in the container
VOLUME ["/ripped_music"]

# Copy needed files for spotify-ripper
COPY ./spotify_appkey.key /root/.spotify-ripper/spotify_appkey.key
COPY ./config.ini /root/.spotify-ripper/config.ini
30 changes: 30 additions & 0 deletions spotify-ripper-docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
> A Debian Stretch (slim) image with python, pip, libspotify and spotify-ripper
## Prereqs
1. Install Docker and make sure the Docker daemon is running.
2. Place your libspotify appkey in the directory you're going to build from
3. Modify the config if needed

## Installation
1. `git clone https://github.com/thibmaek/spotify-ripper-docker`
2. Add username & password in the `config.ini` file in this repo
3. `docker build -t spotify-ripper .`
4. `docker run -itd -v /home/user/download:/data --name spotify-ripper spotify-ripper`

## Ripping
Default config will use the liblamemp3 encoder to rip to a MP3 container at 320kbps.
You can also rip to M4A (AAC) using the libfdk-aac encoder which is compiled into this image.
The spotify-ripper-morgaroth pip package embedded in this image will however 'monkey-patch' an M4A bug which makes it really incompatible with iTunes and causes iTunes to hang or crash when adding new files to the library. Use with caution!

Once the container is running, use docker exec to start ripping:

```bash
# You can add --remove-offline-cache to remove the libspotify offline cache and save disk space
# and avoid Docker storage conflicts.

# Running this will run the output in the current terminal window
docker exec spotify-ripper spotify-ripper spotify:album:… --remove-offline-cache

# Running this will run it detached in the background so you don't need to keep a terminal open
docker exec -d spotify-ripper spotify-ripper spotify:album:…
```
10 changes: 10 additions & 0 deletions spotify-ripper-docker/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[main]
bitrate = 320
cbr = True
cover_file_and_embed = album_cover.jpg
directory = /ripped_music
format = {album}/{disc_num}{track_num:2} - {artist} - {track_name}.{ext}
grouping = {label}
normalize = True
quality = 320
partial_check = strict
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added spotify-ripper-docker/dependencies/v0.6.2.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions spotify-ripper-web-backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions spotify-ripper-web-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Loading

0 comments on commit a025451

Please sign in to comment.