Giter Club home page Giter Club logo

medialytics's Introduction

Medialytics 2.2.1

A free analytics tool for Plex server content


What is Medialytics?

Plex itself, as well as other tools, generate statistics regarding your server activity (most watched, most active, etc.) but they don't report much on the nature of your media content itself. Medialytics is a small client-side app that runs in the browser and generates statistics specifically about the content of your server, e.g. top production studio across a libary.

header

visualizations

visualizations-2

Main features

  • Charts for genre, country, decade, studio, actor, and director analysis
  • Statistics for size and duration of entire library
  • Statistics for longest (duration), oldest (release date), and earliest / latest additions (to library)
  • Detect unmatched library items
  • Watched/unwatched comparison across genres, countries, decades, and studios

How does it work?

Plex servers generate an XML feed that returns a list of libraries associated with a server, as well as the content within each library. Medialytics parses that XML feed and performs calculations on the content to aggregate and display statistics.

When the page loads, two API calls are made to your server: one returns available libraries, the other returns a list of recently added media. After selecting an available library, a call will be made to the corresponding endpoint that returns that library's data. The larger the library, the longer this call may take. The response is then parsed, stats are aggregated, and (depending on the library type) the UI displays relevant data and charts.

Please note, currently Medialytics only supports Movie and TV libraries (audio, image, etc. have been excluded) but you may customize the code to your liking.

What is it built with?

Version 2.0 was rebuilt with Vue 2, Axios for API calls, and I am still using the robust D3/C3 libraries for charts.

SECURITY WARNING:

This application relies upon using the private Plex token of your server, which you do not want to share with anyone (a malicious user can leverage it to access your server as an administrator). This is a limitation due to the way Plex leverages the token itself, there is no "read-only" option.

I am not liable for any damages or inconvenience caused by the improper sharing of your token, it is your responsibility to ensure it is never shared with anyone. Additionally, you should not host your copy of Medialytics anywhere that is publicly accessible, as the token itself is sent as part of the API request. Medialytics is only recommended for local usage at this time (just drag the html file into your browser, no server needed), but you are welcome to host it securely if you have the knowledge base to do so safely (at your own risk).

Getting Started

Clone the repository to a local directory on your computer, or download the repository as a zip file and extract the contents. Open the contents in a text editor and do the following option:

Within the Application

  1. At the top of scripts.js, set the serverIp variable equal to your Plex server's public IP (found in Plex Settings > Remote Access)
  2. At the top of scripts.js, set the serverToken variable equal to your PRIVATE plex token. Do not share this value with anyone! If compromised, generate a new one (instructions on locating and generating a token)
  3. Drag index.html into a browser
  4. You should now see your server IP in the "Targeted Server" section of the page, and links to any available libraries on that server (Movie and TV only).

With Docker

There are 2 ways, you likely want the first set of instructions.

Simple Installation with Docker Compose

Set up:

  1. Copy .env.sample from the repository as .env
  2. Set the SERVER_IP variable equal to your Plex server's public IP (found in Plex Settings > Remote Access)
  3. Set the SERVER_TOKEN variable equal to your PRIVATE plex token. Do not share this value with anyone! If compromised, generate a new one (instructions on locating and generating a token)

This assumes you followed the instructions and have a .env file in the same repo as a docker-compose.yml file with the following:

version: "3.9"
services:
  medialytics:
    image: ghcr.io/drewpeifer/medialytics:latest
    container_name: medialytics
    environment:
      - SERVER_IP=${SERVER_IP}
      - SERVER_TOKEN=${SERVER_TOKEN}
    ports:
      - "8088:80"

Finally run with:

  1. Run the image
    docker compose up -d
  2. Go to http://localhost:8088/ You should now see your server IP in the "Targeted Server" section of the page, and links to any available libraries on that server (Movie and TV only).

Run and Build Locally with Docker

  1. Copy .env.sample from the repository as .env
  2. Set the SERVER_IP variable equal to your Plex server's public IP (found in Plex Settings > Remote Access)
  3. Set the SERVER_TOKEN variable equal to your PRIVATE plex token. Do not share this value with anyone! If compromised, generate a new one (instructions on locating and generating a token)
  4. Run the image
    docker compose up -d
  5. Go to http://localhost:8088/ You should now see your server IP in the "Targeted Server" section of the page, and links to any available libraries on that server (Movie and TV only).

If you know HTML/CSS/JS you can edit the code to your liking. All the application logic and parsing is done in scripts.js, styling is in styles.css, and the page elements are in index.html.

Anyone is welcome to fork / contribute / utilize for non-commercial purposes. Credit for use elsewhere is appreciated but not required.

Troubleshooting / FAQ

Medialytics is not designed for libraries with non-video content (e.g. music, photos, or audiobook functionality is untested). Only Movie and TV libraries will be parsed by default.

If your libraries do not automatically load after following the instructions above, you may need to refer to the documentation for Plex XML interactions. The following steps should help clear up any basic issues:

  1. Confirm that you have entered the correct values for your (public) serverIp and (very private) serverToken at the top of the medialytics/js/scripts.js file.
  2. Confirm that your public IP (found in Plex web Settings > Remote Access) is correct and resolves in a local browser
  3. Confirm that you are using the correct / most current plex token (related documentation)
  4. Near the top of scripts.js, set the debugMode variable equal to true. Now return to the browser, refresh the page, and there should be a message saying that debug mode is enabled. Press F12 or ctrl+click to open the developer tools for your browser, and navigate to the console. You should see information printed about your server's available libraries, and if you select a library in the UI more info will be displayed in the console.

How recent is this data?

Data is retrieved from Plex in real time. When you load the page or select a library, you are making a fresh request to the targeted server each time.

Why is some of the metadata for my library missing?

Plex pulls all its metadata from external agents like theTVDB.com which are crowd-sourced information. Some of the more obscure titles have incomplete data, especially when it comes to ratings, so if you see an empty or "undefined" value it is most likely appearing as empty or "undefined" in the Plex web interface as well. I have chosen not to report on undefined values, but there may be edge cases I haven't considered.

Related documentation

For anyone who wishes to fork and modify this repo, here are some links you may find useful:

  1. Plex XML docs (for retrieving and parsing data)
  2. Plex token docs (for token management)
  3. Vue 2 docs (for general app logic and architecture)
  4. Axios docs (for API calls)
  5. D3.js and C3.js docs (for customizing and adding new charts)
  6. Guide to Flexbox (for UI editing)

medialytics's People

Contributors

drewpeifer avatar jzucker2 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

medialytics's Issues

Plex service name not working

Heya,

External domain works, but for some odd reason, internal Docker DNS service name does not.

  medialytics:
    image: ghcr.io/drewpeifer/medialytics:latest
    container_name: Medialytics
    environment:
      - SERVER_IP=plex
      - SERVER_TOKEN=$PLEXTOKEN
    networks:
      pihole:
        ipv4_address: '172.22.0.111'
    ports:
      - "27015:80"
    depends_on:
      - plex
    restart: always

Is there any way to get this working? Seems odd going out of the network just to come back in to get the relevant stats.

I can use the internal server IP (http://192.168.etc.etc:port), but given that Docker can work in this way, it may be worthwhile investigating to see if it can be used.

Charts for decade and studio statistics not generating

Hey there, I've just stumbled upon your tool and as an statistics nerd I absolutely love it, but sadly when I use it I see everything except the charts for "Movies By Decade", "TV Shows By Decade", "Movies By Studio (Top 50)" and "TV Shows By Studio (Top 50)". Could you maybe help me fix this problem, so I can use your amazing tool to its full potential? Thank you very much in advance.
medialytics_screenshot

Security issue: Token is shared in source

If you look at script.js when running via a reverse proxy, it shares the token of the Plex server in plain text which is a massive issue.

////// WARNING
// Never share the following token with anyone! Do not host this on a public server with the token in place!
// Keep it secret, keep it safe! If compromised, generate a new one: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
const serverToken = 'plaintexttokenhere',// ex: 'ad2T-askdjasd9WxJVBPQ'
serverIp = 'https://myplexdomain.com',// ex: 'http://12.345.678.90:32400'
libraryListUrl = serverIp + '/library/sections?X-Plex-Token=' + serverToken,

I understand that there is a warning you should not host your copy of Medialytics anywhere that is publicly accessible, but storing it in plain text may not be the best way of going about it.

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.