Giter Site home page Giter Site logo

plex-tools's Introduction

GoshDarned Tools

Utilities and scripts for plex using the Plex API to clean up your Plex Music library.


Deduplex: deduplex.py

This script will search your Plex Music Library for duplicates. It will provide information for you to decide which ones you want to clean. You can choose to "Safe Clean" (place all duplicates in a playlist) or delete.

Prerequisites

  • Plex Login credentials (either token or username/password)
    see Plex API Login documentation for more details.
  • Your Plex server URL
  • Python 3.11

Quick Start

  • Install dependencies
git clone [email protected]:johnsturgeon/plex-tools.git
cd plex-tools

NOTE: Recommended: Use a virtual env

pip install -r requirements.txt
  • Run the script python deduplex.py
  • The script will walk you through the entire process

Questions / Comments / Requests?

Join our discussion.

Detailed walk-through

Detailed walk through for Deduplex

Usage

python deduplexs.py

The script will walk you through an initial configuration, Optionally offer to save the config in a .env file, and begin the search

.env

If the .env file does not exist, you can opt to create it

image

Setup

The setup process will attempt to connect to your plex server using credentials supplied in the .env file. If successful, it will search for duplicates.

image

Safe Mode

Safe mode will move duplicate tracks to a playlist for you to review and delete in Plex yourself.

image

If you choose not to enable safe mode, then your duplicates will be deleted directly

Instructions

You will (optionally) be shown some brief instructions for how to choose your duplicates, it will be more obvious once you begin.

image

Duplicate chooser

Each song that has duplicate(s) files will present you with a choice for choosing which songs to delete

image

Final review

You will be asked if you'd like to review the actual files that you've chosen for clean-up then, either the files will be placed into a playlist (safe delete) or deleted.

plex-tools's People

Contributors

johnsturgeon avatar

Stargazers

CochraneServer avatar Keenan Villani-Holland avatar Ricky Dominguez avatar Jedidja avatar  avatar  avatar Justin B. Alcorn avatar  avatar Andrew Snape avatar Alberto Paladino avatar Riley avatar  avatar

Watchers

 avatar CochraneServer avatar

plex-tools's Issues

Remove unused methods

    def is_duplicate(self, other):
        return self.hash_val == other.hash_val

    def is_identical(self, other):
        return self.track == other.track

Along with property
self.hash_val = str(f"{self.title}{self.artist}{self.album}{self.duration}")

Feature Request: Sync ratings to and from Plex Database to IDv3 tags

I'm currently going through the process of tagging my ~10k track library but am worried as I know my plex library may not last forever. Ten years is a good run for many software applications.

Any way - it would be awesome to have the ability to sync track ratings from the plex database into mp3 IDv3 rating tag. I've seen some discussion regarding exacltly which tag ratings are stored in, as it can differ between media library applications such as MediaMonkey / MusicBee / AIMP. Perhaps the rating field could be user-definible to make this feature more adaptable.

According to id3.org the rating tag is the "Popularimeter" field - https://id3.org/id3v2.3.0.

Make a method that can compare the Shazam track to the JHSTrack

    def mapped_filepath(self, path_map: Dict[str, str]) -> str:
        """
        Replaces the remote root of the file with the local root given
        Args:
            path_map: Dictionary in the form of
               {
                  remote_root1: local_root1,
                  remote_root2: local_root2,
                  ...
               }

        Returns:
            the full local path the current track
        """
        new_path: str = self.filepath
        for key, value in path_map.items():
            if key in self.filepath:
                new_path = self.filepath.replace(key, value)
        return new_path

[Feature request] Option to add automatic sorting based on bitrate

Issue: I have a library with over 120 000 songs, and I ran this program, and there are 1034 duplicates found. There seems to be no option to just automatically go through the songs. It's unfortunately unusable for that reason.

Proposed solution: Add a feature, which asks the user if they want to use an automatic process, which uses few different methods for sorting. Some that came into my mind:

  1. Creation date: delete either the older or the newer duplicates
  2. Size: Delete either the larger one or smaller one
  3. Bitrate: Delete either the one with higher bitrate or the one with lower
  4. Album or single: If the track has album and single versions, select which one to prefer
  5. Regex recognition: for example if the track name has (1) in it, you could use regex to detect that

Those options could be merged so let's say "I want the songs where creation date does not matter, but if the track is bigger, and has larger bit rate and has (1) in the file name, delete it right away"

Justification: Better user experience for users with a tad larger libraries. Also helps users to gain more power over which versions they want to keep and which to delete.

Write unit tests

Now that it looks like there will be some contributors, I think it's time to start to write some unit tests.

Write authentication in a modular way

I'm going to use the same authentication .env workflow as the other scripts, so it only makes sense to write it so that the other script can eventually just include it.

Prompt for root folder mapping

Many times this won't be run on the same machine as a remote Plex server, therefore we need to create a 'map' to the root of the library folder with a folder that's accessible to the script.

Add AcoustID fingerprinting for double checking result

So it seems that Shazam API is not great. The first album I threw at it was "Acoustic Alchemy" "Against the Grain" and unfortunately it mis-matched several songs opting instead for the version where they were performing with an orchestra.

I think as a fallback, we could try acoustID (or maybe even the other way around). The downside is that this will require the user to install "Chromaprint"

Another option is SoundHound, but this would require registration for an API key.

Neither option is great.

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.