Skip to content

nichtlegacy/plex-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Ί Plex Contribution Graph

GitHub Workflow Status Made with Node.js JavaScript License

Transform your Plex movie watch history into a beautiful GitHub-style contribution graph

Plex contribution graph


✨ Features

Feature Description
🎨 Light & Dark Themes Automatically adapts to GitHub's theme preference
πŸ“Š Activity Heatmap GitHub-style contribution graph showing movie activity
☁️ Plex Cloud Integration Fetches watch history via community.plex.tv, no port-forwarding required
🎬 Movies Only Focused on your film collection (series support coming later)
πŸ“… Multi-Year Support Generate graphs spanning multiple years
πŸ’¬ Interactive Tooltips Hover over cells to see film details with release years
πŸ”„ Daily Updates Automated updates via GitHub Actions

πŸš€ Quick Start

1. Fork this Repository

Click the Fork button at the top-right of this page.

2. Get Your Plex Token

You need your X-Plex-Token. Find it in your browser's network tab when logged into Plex Web, or follow this guide.

3. Configure Secrets

Go to Settings > Secrets and variables > Actions and add:

  • PLEX_TOKEN: Your Plex authentication token
  • PLEX_USER: Your Plex username

4. Update Workflow Configuration

Edit .github/workflows/update-graph.yml and set your desired years.

5. Enable GitHub Actions

Go to Actions tab β†’ Enable workflows if prompted.

6. Run the Workflow

The graph updates daily at midnight UTC, or trigger manually via the Actions tab.

Note: You must have "Sync My Watch State and Ratings" enabled in your Plex account settings.


πŸ“– CLI Usage

# Install dependencies
npm install

# Basic usage (requires PLEX_TOKEN in .env or environment)
node src/cli.js -y 2025

# With options
node src/cli.js [options]

Arguments

Flag Description Default
-y <years> Year(s) to generate, comma-separated (e.g. 2025,2024) Current year
-w <day> Week start: sunday or monday sunday
-o <path> Output path (without extension) images/plex-graph
-g <bool> Enable username gradient: true or false true
-p Export PNG files in addition to SVG Disabled

Examples

# Single year
node src/cli.js -y 2025

# Multiple years
node src/cli.js -y 2025,2024

# Start week on Monday, with PNG export
node src/cli.js -y 2025 -w monday -p

# Custom output path
node src/cli.js -y 2025 -o images/my-graph

πŸ”§ GitHub Actions Setup

Workflow File

Create .github/workflows/update-graph.yml:

name: Update Plex Graph

# ╔════════════════════════════════════════════════════════════════╗
# β•‘  CONFIGURATION - Edit these values for your Plex profile       β•‘
# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
env:
  YEARS: "2025"                        # Years to generate (e.g. "2025,2024")
  EXPORT_PNG: "false"                  # Set to "true" to also generate PNG files
  WEEK_START: "sunday"                 # "sunday" or "monday"
  GRADIENT: "true"                     # "true" for colored name, "false" for white

on:
  schedule:
    - cron: "0 0 * * *"   # Daily at midnight UTC
  workflow_dispatch:       # Manual trigger

permissions:
  contents: write

jobs:
  update-graph:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      
      - run: npm ci
      
      - name: Generate Graph
        env:
          PLEX_TOKEN: ${{ secrets.PLEX_TOKEN }}
        run: |
          CMD="node src/cli.js -o images/plex-graph"
          
          if [ -n "${{ env.YEARS }}" ]; then CMD="$CMD -y ${{ env.YEARS }}"; fi
          if [ "${{ env.WEEK_START }}" = "monday" ]; then CMD="$CMD -w monday"; fi
          if [ "${{ env.GRADIENT }}" = "false" ]; then CMD="$CMD -g false"; fi
          if [ "${{ env.EXPORT_PNG }}" = "true" ]; then CMD="$CMD -p"; fi
          
          echo "Running: $CMD"
          eval $CMD

      - name: Commit and Push
        run: |
          git config --global user.name 'github-actions[bot]'
          git config --global user.email 'github-actions[bot]@users.noreply.github.com'
          git add images/
          
          if git diff --staged --quiet; then
            echo "No changes to commit"
          else
            TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M UTC")
            git commit -m "Update Plex graph - $TIMESTAMP"
            git push
          fi

Required Secrets

Secret Description
PLEX_TOKEN Your Plex authentication token

πŸ“‚ Project Structure

plex-graph/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── update-graph.yml  # GitHub Actions workflow
β”œβ”€β”€ fonts/
β”‚   β”œβ”€β”€ Inter-Bold.woff2
β”‚   β”œβ”€β”€ Inter-Medium.woff2
β”‚   β”œβ”€β”€ Inter-Regular.woff2
β”‚   └── Inter-SemiBold.woff2
β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ plex-graph-2025-dark.svg
β”‚   └── plex-graph-2025-light.svg
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli.js                # CLI entry point
β”‚   β”œβ”€β”€ fetcher.js            # Plex API data fetching
β”‚   β”œβ”€β”€ generator.js          # SVG generation
β”‚   β”œβ”€β”€ stats.js              # Statistics calculations
β”‚   └── exporter.js           # PNG export functionality
β”œβ”€β”€ plex-logo.svg             # Plex branding
β”œβ”€β”€ package.json
└── README.md

πŸ–ΌοΈ Embed in Your README

Add this to your profile README to display the graph with automatic theme switching:

<p align="center">
  <a href="https://www.plex.tv/" target="_blank">
    <picture>
      <source
        media="(prefers-color-scheme: dark)"
        srcset="https://github.com/YOUR_GITHUB_USERNAME/plex-graph/blob/main/images/plex-graph-2025-dark.svg"
      />
      <source
        media="(prefers-color-scheme: light)"
        srcset="https://github.com/YOUR_GITHUB_USERNAME/plex-graph/blob/main/images/plex-graph-2025-light.svg"
      />
      <img
        alt="Plex contribution graph"
        src="https://github.com/YOUR_GITHUB_USERNAME/plex-graph/blob/main/images/plex-graph-2025-light.svg"
      />
    </picture>
  </a>
</p>

Replace YOUR_GITHUB_USERNAME with your GitHub username.


πŸ› οΈ Requirements

  • Node.js v18 or higher
  • Plex account with "Sync Watch State" enabled
  • GitHub account with Actions enabled (for automated updates)

🀝 Contributing

Contributions are welcome! Feel free to:

  • πŸ› Report bugs
  • πŸ’‘ Suggest features
  • πŸ”§ Submit pull requests

πŸ“„ License

MIT License - see LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors