Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryck committed Jun 12, 2024
2 parents 46148dd + 5d03a78 commit 139f5c7
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 25 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM node:alpine as base

# File Author / Maintainer
LABEL authors="Ricardo Gonzalez <[email protected]>"
FROM node:lts-alpine as base

LABEL org.opencontainers.image.title "Scrobblex"
LABEL org.opencontainers.image.description "Self-hosted app that enables Plex scrobbling integration with Trakt via webhooks"
LABEL org.opencontainers.image.url="https://github.com/ryck/scrobblex"
LABEL org.opencontainers.image.source='https://github.com/ryck/scrobblex'
LABEL org.opencontainers.image.licenses='MIT'

ENV NODE_ENV=production
ENV NODE_ENV $NODE_ENV
Expand All @@ -12,16 +14,14 @@ ENV PORT $PORT

HEALTHCHECK CMD curl --fail http://localhost:${PORT}/healthcheck || exit 1

WORKDIR /usr/src/app
WORKDIR /app

COPY package*.json ./

RUN npm ci

COPY . .

VOLUME /usr/src/app/data

EXPOSE 3090
EXPOSE ${PORT}

CMD ["node", "src/index.js"]
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) 2024 Ricardo Gonzalez

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.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,69 @@
# Scrobblex

[![Docker](https://github.com/ryck/scrobblex/actions/workflows/docker-publish.yml/badge.svg?branch=main)](https://github.com/ryck/scrobblex/actions/workflows/docker-publish.yml)
[![latest version](https://img.shields.io/github/tag/ryck/scrobblex.svg)](https://github.com/ryck/scrobblex/releases)
[![MIT License](https://img.shields.io/github/license/ryck/scrobblex.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Pulls from DockerHub](https://img.shields.io/docker/pulls/rickgc/scrobblex.svg)](https://hub.docker.com/r/rickgc/scrobblex)

## Description

Self-hosted app that enables Plex scrobbling integration with Trakt via webhooks.

Plex provides webhook integration for all Plex Pass subscribers, and users of their servers. A webhook is a request that the Plex application sends to third party services when a user takes an action, such as watching a movie or episode.

You can ask Plex to send these webhooks to this tool, which will then log those plays in your Trakt account.

## Installation

Scrobblex is designed to be run in Docker. You can host it right on your Plex server!

To run it yourself, first create an API application through Trakt [here](https://trakt.tv/oauth/applications). Set the Allowed Hostnames to be the URI you will hit to access Scrobblex, plus /authorize. So if you're exposing your server at http://10.20.30.40:3090, you'll set it to http://10.20.30.40:3090/authorize. Bare IP addresses and ports are totally fine, but keep in mind your Scrobblex instance _must_ be accessible to _all_ the Plex servers you intend to play media from.

Once Scrobblex is running, just go to http://$YOUR_IP:$PORT/ (ie: http://10.20.30.40:3090/) and a web page will guide you to get your token.

### docker run

```bash
docker run \
--name=scrobbler \
--restart always \
-v <path to configs>:/app/data \
-e TRAKT_ID=<trakt_id> \
-e TRAKT_SECRET=<trakt_secret> \
-p 3090:3090 \
ryck/scrobblex:latest
```

### docker-compose.yml

```yaml
services:
scrobbled:
image: ghcr.io/ryck/scrobblex:latest
container_name: scrobblex
restart: always
ports:
- 3090:3090
environment:
- TRAKT_ID=YOUR_TRAKT_ID
- TRAKT_SECRET=YOUR_TRAKT_SECRET
- LOG_LEVEL=info
volumes:
- ./scrobblex:/app/data
```
### compile from source
```bash
git clone https://github.com/ryck/scrobblex.git && cd scrobblex
npm install
npm run start
```

## Environment Variables

| Variable | Default | Description |
| ------------ | --------- | ---------------------------------- |
| TRAKT_ID | undefined | Trakt application ID |
| TRAKT_SECRET | undefined | trakt application secret |
| LOG_LEVEL | info | winston log level: ie: info, debug |
12 changes: 3 additions & 9 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
version: '3.9'

services:
scrobblex:
image: ghcr.io/ryck/scrobblex:latest
container_name: scrobblex
image: rickgc/scrobblex
restart: always
build:
context: .
dockerfile: Dockerfile
target: base
ports:
- 3091:$PORT
- $PORT:$PORT
environment:
- TRAKT_ID=$TRAKT_ID
- TRAKT_SECRET=$TRAKT_SECRET
- LOG_LEVEL=$LOG_LEVEL
volumes:
- ./scrobblex:/data
- ./scrobblex:/app/data
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "scrobblex",
"description": "Self-hosted app that enables Plex scrobbling integration with Trakt via webhooks",
"version": "0.1.0",
"version": "0.2.0",
"main": "src/index.js",
"type": "module",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ app.get('/', async (req, res) => {
app.get('/authorize', async (req, res) => {
const code = req.query.code;
const redirect_uri = `${req.protocol}://${req.get('host')}/authorize`;
const tokens = await authRequest({ code, grant_type: 'authorization_code', redirect_uri });
const tokens = await authorizeRequest({ code, grant_type: 'authorization_code', redirect_uri });
if (tokens) {
const data = JSON.stringify(tokens);
localStorage.setItem('tokens', data);
Expand Down
10 changes: 4 additions & 6 deletions src/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const findMovieRequest = async (payload) => {

const movie = response.data[0].movie;
logger.debug(movie);
const { title, year, ids } = movie;
logger.info(`🎬 Movie found: ${title} (${year}) - IDs: ${JSON.stringify(ids)}`);
const { title, year } = movie;
logger.info(`🎬 Movie found: ${title} (${year})`);

return movie;
} catch (err) {
Expand Down Expand Up @@ -66,11 +66,9 @@ export const findEpisodeRequest = async (payload) => {

const episode = response.data[0].episode;
logger.debug(episode);
const { season, number, title, ids } = episode;
const { season, number, title } = episode;
logger.info(
`📺 Episode found: S${season.toString().padStart(2, '0')}E${number
.toString()
.padStart(2, '0')} - ${title} - IDs: ${JSON.stringify(ids)}`,
`📺 Episode found: S${season.toString().padStart(2, '0')}E${number.toString().padStart(2, '0')} - ${title}`,
);
return episode;
} catch (err) {
Expand Down
Binary file added static/images/android-chrome-192x192.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 static/images/android-chrome-512x512.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 static/images/apple-touch-icon.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 static/images/favicon-16x16.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 static/images/favicon-32x32.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 static/images/favicon.ico
Binary file not shown.

0 comments on commit 139f5c7

Please sign in to comment.