Git Product home page Git Product logo

kitsu-plex-scrobbler's Introduction

Features/Constraints

  • Watches Plex log file for activity and submits to Kitsu
  • Supports kitsu, thetvdb and hama agents. (Use kitsu for best results)
  • thetvdb and hama agents require tvdb/anidb mappings for the media to exist in Kitsu's database
  • Must run on same machine as Plex Media Server

Run it

Running with Node.js
  1. Install PostgreSQL
  2. Create a database
  3. Install current Node.js
  4. Run npm install
  5. Set env vars and run npm start
Running with Docker
  1. Install Docker
  2. Set env vars and run docker-compose up
Env vars
Var Default Value Description Node Docker
PLEX_HOST http://localhost:32400 Plex Media Server host Optional Optional
(Docker for Mac/Windows users should set this to http://host.docker.internal:<plex port>)
PLEX_LOGS none Location of your Plex Media Server log files (instructions)
Common locations:
  • macOS: "~/Library/Logs/Plex Media Server"
  • Linux: "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs"
  • Windows: "~\\AppData\\Local\\Plex Media Server\\Logs"
  • FreeBSD: "/usr/local/plexdata/Plex Media Server/Logs"
    Required Required
    PORT 8929 Port for web server to listen on Optional Optional
    DATABASE_URL postgres://postgres@localhost:5432/kitsu-plex-scrobbler Connection URL for your PostgreSQL database Optional Ignored
    POSTGRES_PORT 5434 Port for included PostgreSQL database to listen on Ignored Optional
    Setting env vars for a command
    • Unix/Bash-like Shell: VAR1="value 1" docker-compose up
    • Windows PowerShell: $env:VAR1 = "value 1"; docker-compose up

    Use it

    • After starting the scrobbler, navigate to http://localhost:<PORT> in your browser
    • Login with your Plex account credentials. Important: The owner of the Plex server must be the first to login
    • Configure settings (These will only apply when watching via your Plex account)
      • Choose which libraries you want to scrobble for your Plex account
      • Connect your Kitsu account
    • Watch something on Plex and your Kitsu library will be updated

    Screenshots

    Acknowledgements

    Thanks to

    kitsu-plex-scrobbler's People

    Contributors

    matthewdias avatar

    Stargazers

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

    Watchers

     avatar  avatar  avatar  avatar

    Forkers

    arno500

    kitsu-plex-scrobbler's Issues

    [Bug] Error when using docker-compose

    For some reason, using the same options works in docker run, but throws this error in docker-compose.

    Docker for Mac:

      kitsu-plex-scrobbler:
        image: matthewdias/kitsu-plex-scrobbler
        privileged: true
        restart: always
        network_mode: host
        environment:
          - KITSU_CLIENT=dd031b32d2f56c990b1425efe6c42ad847e7fe3ab46bf1299f05ecd856bdb7dd
          - KITSU_SECRET=54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151
          - KITSU_USERNAME=<username>
          - KITSU_PASSWORD=<password>
          - PLEX_HOST=http://host.docker.internal:32400
          - PLEX_TOKEN=<token>
          - PLEX_LOG="/logs/Plex Media Server.log"
          - PLEX_LIBRARIES=Anime
        volumes:
          - "/Users/Matthew/Library/Logs/Plex Media Server:/logs"
    
    events.js:173
        throw err; // Unhandled 'error' event
        ^
    
    Error [ERR_UNHANDLED_ERROR]: Unhandled error. (watch for "/logs/Plex Media Server.log" failed: undefined)
        at Tail.emit (events.js:171:17)
        at Tail.watch (/app/node_modules/tail/lib/tail.js:100:12)
        at new Tail (/app/node_modules/tail/lib/tail.js:84:10)
        at Object.<anonymous> (/app/src/index.js:7:14)
        at Module._compile (internal/modules/cjs/loader.js:678:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
        at Module.load (internal/modules/cjs/loader.js:589:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
        at Function.Module._load (internal/modules/cjs/loader.js:520:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] start: `node src/index.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2018-05-10T04_29_03_550Z-debug.log
    ERROR: "start" exited with 1.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] start-docker: `run-p start inotify`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] start-docker script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2018-05-10T04_29_03_869Z-debug.log
    

    Docker scrobbler container "./wait-for-postgres.sh: not found"

    I tried to run docker-compose from windows 10 and got this error:

    scrobbler_1  | /bin/sh: 1: ./wait-for-postgres.sh: not found
    kitsu-plex-scrobbler_scrobbler_1 exited with code 127
    

    postgres container seems to run fine, but scrobbler fails to run after.

    Notifications

    Not sure how useful this would be. Maybe have it be configurable for updates and errors.

    Plex Server Login Connection Refused

    After staring the scrobbler service when trying to log in to plex on the web app I get the following error:

    scrobbler_1  | Error: connect ECONNREFUSED 172.17.0.1:32400
    scrobbler_1  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
    

    Not sure what is causing it. Could be a local configuration ion my plex server or netowrk.

    Also, I'm running my plex server on windows. Not sure if that makes a difference.

    SQLite database option

    It would be nice to add an SQLite database option. This would allow the docker container to run without needing an external database server/container. Currently PostgreSQL seems like it might be a little overkill since the app is mainly using the database to store token credentials.

    Docker Script Error

    [email protected] start-docker /app
    scrobbler_1 | > NODE_ENV=production knex migrate:latest && run-p start inotify
    scrobbler_1 |
    scrobbler_1 | Using environment: production
    scrobbler_1 | Already up to date
    scrobbler_1 |
    scrobbler_1 | > [email protected] start /app
    scrobbler_1 | > npm run build && NODE_ENV=production node src/server/index.js
    scrobbler_1 |
    scrobbler_1 |
    scrobbler_1 | > [email protected] inotify /app
    scrobbler_1 | > cd /logs && /app/node_modules/inotify-proxy/bin/inotify-proxy ./PMS\ Plugin\ Logs > /dev/null
    scrobbler_1 |
    scrobbler_1 | sh: 1: cd: can't cd to /logs
    scrobbler_1 | npm ERR! code ELIFECYCLE
    scrobbler_1 | npm ERR! errno 2
    scrobbler_1 | npm ERR! [email protected] inotify: cd /logs && /app/node_modules/inotify-proxy/bin/inotify-proxy ./PMS\ Plugin\ Logs > /dev/null
    scrobbler_1 | npm ERR! Exit status 2
    scrobbler_1 | npm ERR!
    scrobbler_1 | npm ERR! Failed at the [email protected] inotify script.
    scrobbler_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    scrobbler_1 |
    scrobbler_1 | npm ERR! A complete log of this run can be found in:
    scrobbler_1 | npm ERR! /root/.npm/_logs/2020-03-06T20_40_48_300Z-debug.log
    scrobbler_1 | ERROR: "inotify" exited with 2.
    scrobbler_1 | npm ERR! code ELIFECYCLE
    scrobbler_1 | npm ERR! errno 1
    scrobbler_1 | npm ERR! [email protected] start-docker: NODE_ENV=production knex migrate:latest && run-p start inotify
    scrobbler_1 | npm ERR! Exit status 1
    scrobbler_1 | npm ERR!
    scrobbler_1 | npm ERR! Failed at the [email protected] start-docker script.
    scrobbler_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    scrobbler_1 |
    scrobbler_1 | npm ERR! A complete log of this run can be found in:
    scrobbler_1 | npm ERR! /root/.npm/_logs/2020-03-06T20_40_48_411Z-debug.log

    Postgres Error

    The server is spamming this and it wont scrobble anything to kitsu.

    LOG: invalid length of startup packet

    Support multiple users

    Initially make users that are allowed to scrobble configurable, maybe eventually allow each user to be associated with a kitsu account.

    Possible Plex Log format changed, monitor is broken

    This log no longer adds a let matches = line.match(/Library item (\d+) \'(.*?)\' got played by account (\d+)!.*?/) line when you play something on plex account.

    But adds this
    May 01, 2019 18:49:57.518 [0x7f708ebf5700] WARN - Unable to load episode file ["seasons/1/episodes/3.xml"]

    Plex Media Server.log

    May 01, 2019 18:48:46.234 [0x7f70a5bfe700] INFO - Plex Media Server v1.14.1.5488-cc260c476 - ubuntu PC x86_64 - build: linux-ubuntu-x86_64 ubuntu - GMT 03:00
    May 01, 2019 18:48:46.234 [0x7f70a5bfe700] INFO - Linux version: 4.19.0-0.bpo.4-amd64 (#1 SMP Debian 4.19.28-2~bpo9+1 (2019-03-27)), language: en-US
    May 01, 2019 18:48:46.234 [0x7f70a5bfe700] INFO - Processor Intel(R) Core(TM) i5-3330 CPU @ 3.00GHz
    May 01, 2019 18:48:46.234 [0x7f70a5bfe700] INFO - /usr/lib/plexmediaserver/Plex Media Server
    May 01, 2019 18:48:46.249 [0x7f70b1c93800] INFO - OCSP: Successfully retrieved response from cache.
    May 01, 2019 18:48:48.160 [0x7f70a13ff700] WARN - Crash: Crash reporting disabled
    May 01, 2019 18:48:49.349 [0x7f7099ffd700] WARN - Sync: Couldn't get sync lists without subscription.
    May 01, 2019 18:48:49.600 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=1): Cannot begin transaction. database is locked
    May 01, 2019 18:48:50.450 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=2): Cannot begin transaction. database is locked
    May 01, 2019 18:48:51.150 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=3): Cannot begin transaction. database is locked
    May 01, 2019 18:48:51.550 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=4): Cannot begin transaction. database is locked
    May 01, 2019 18:48:52.351 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=5): Cannot begin transaction. database is locked
    May 01, 2019 18:48:52.952 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=6): Cannot begin transaction. database is locked
    May 01, 2019 18:48:53.938 [0x7f708e3f4700] ERROR - Error response for update: 2 (Agent not found).
    May 01, 2019 18:48:54.026 [0x7f708ebf5700] ERROR - Error response for update: 2 (Agent not found).
    May 01, 2019 18:48:54.127 [0x7f708e3f4700] ERROR - Error response for update: 2 (Agent not found).
    May 01, 2019 18:48:54.154 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=7): Cannot begin transaction. database is locked
    May 01, 2019 18:48:54.558 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=8): Cannot begin transaction. database is locked
    May 01, 2019 18:48:55.367 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=9): Cannot begin transaction. database is locked
    May 01, 2019 18:48:55.984 [0x7f70913fa700] ERROR - Failed to begin transaction (../Library/MetadataCollection.cpp:173) (tries=10): Cannot begin transaction. database is locked
    May 01, 2019 18:48:55.984 [0x7f70913fa700] ERROR - Fixup 29DatabaseFixupsSyncCollections threw an exception: Cannot begin transaction. database is locked
    May 01, 2019 18:48:55.985 [0x7f7096bff700] WARN - Took too long (3.220000 seconds) to start a transaction on ../Plugins/PluginDatabaseState.cpp:112
    May 01, 2019 18:48:55.985 [0x7f7096bff700] WARN - Transaction that was running was started on thread 0x7f7095bfd700 at ../Plugins/PluginDatabaseState.cpp:112
    May 01, 2019 18:48:56.148 [0x7f7095bfd700] WARN - Took too long (3.250000 seconds) to start a transaction on ../Plugins/PluginDatabaseState.cpp:112
    May 01, 2019 18:48:56.148 [0x7f7095bfd700] WARN - Transaction that was running was started on thread 0x7f7096bff700 at ../Plugins/PluginDatabaseState.cpp:112
    May 01, 2019 18:48:56.259 [0x7f70963fe700] WARN - Took too long (3.250000 seconds) to start a transaction on ../Plugins/PluginDatabaseState.cpp:112
    May 01, 2019 18:48:56.259 [0x7f70963fe700] WARN - Transaction that was running was started on thread 0x7f7096bff700 at ../Plugins/PluginDatabaseState.cpp:112
    May 01, 2019 18:49:10.231 [0x7f709c3ff700] INFO - Refreshing paths watched by LibraryUpdateManager
    May 01, 2019 18:49:45.245 [0x7f70877f8700] ERROR - QueryParser: Invalid field 'onlyTransient' found, ignoring.
    May 01, 2019 18:49:49.583 [0x7f70a43ff700] ERROR - Failed to delete session directory (boost::filesystem::remove: No such file or directory: "/srv/dev-disk-by-id-ata-ST1000LM024_HN-M101MBB_S35TJ9CG801410-part3/plexmediaserver/Library/Application Support/Plex Media Server/Cache/Transcode/Sessions/plex-transcode-lpdp9shqqrvklv4e9sin8iub-a433c88a-1dae-439c-92a7-c005d5c1cf0a/chunk-stream0-00121.m4s")
    May 01, 2019 18:49:57.518 [0x7f708ebf5700] WARN - Unable to load episode file ["seasons/1/episodes/3.xml"]
    May 01, 2019 18:53:34.636 [0x7f70a2bfe700] WARN - LongPoll: Got error, closing.

    how to install

    I can't seem to figure out how to install the scribbler on Linux.
    How can I create env vars and what am I supposed to do with docker-compose up?

    Any help is appreciated.

    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.