Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Features #75

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Use Ubuntu as base image
FROM ubuntu:latest

# Set the working directory
WORKDIR /app

# Install Python 3 and pip
# Print out Python and pip versions
RUN echo "[ ] Updating package lists..." && \
apt-get update && \
echo "[ ] Installing Python 3 and pip..." && \
apt-get install -y python3 python3-pip && \
echo "[ ] Cleaning up package cache..." && \
apt-get clean && \
echo "[ ] Creating a symbolic link for Python 3..." && \
ln -s /usr/bin/python3 /usr/bin/python && \
echo "[ ] Verifying Python and pip versions..." && \
python --version && \
pip --version

# Copy requirements.txt to the root directory of the image
COPY requirements.txt /requirements.txt

# Install Python dependencies from requirements.txt
RUN python3 -m pip install -r /requirements.txt

# Create a symbolic link from /app/plex_dupefinder.py to /plex_dupefinder
RUN ln -s /app/plex_dupefinder.py /plex_dupefinder

# Define a volume for the Python application
VOLUME /app

# Define default command
ENTRYPOINT ["/plex_dupefinder"]
78 changes: 78 additions & 0 deletions Dockerfile_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Dockerizing the Plex Dupefinder Python Application

This guide outlines the steps for Dockerizing the Plex Dupefinder Python application using Docker.

## Folder Structure

Ensure that your project has the following folder structure:

```
plex_dupefinder/
└── app/
└── Dockerfile # (Included from git checkout)
└── ... (all contents from the git checkout)
```

- `plex_dupefinder/`: Root directory for the Plex Dupefinder project.
- `app/`: Contains all files and directories retrieved from the git checkout, including the Dockerfile.

## Setting Up the Folder Structure

Follow these steps to set up the folder structure and retrieve your Python application files:

1. Open a terminal and navigate to the desired directory for your project.
2. Run the following command to clone your repository and create the `app/` folder:
```
git clone https://github.com/Hossy/plex_dupefinder.git app
```

This command clones your repository and creates the `/app` folder containing all files and directories from the git checkout, including the Dockerfile.

## Building the Docker Image

Follow these steps to build the Docker image for your Python application:

1. Open a terminal and navigate to the root directory of your project.
2. Run the following command to build the Docker image:
```
docker build -t plex_dupefinder app
```

This command builds the Docker image named `plex_dupefinder` using the Dockerfile located in the `app/` directory.

### Preserving the Locally-Built Image

To preserve the locally-built image when running `docker system prune`, follow these additional steps:

1. When building the Docker image, add a label to it using the `--label` flag:
```
docker build -t plex_dupefinder --label "preserve=true" app
```

This command adds the label `preserve=true` to the `plex_dupefinder` image.

2. When running `docker system prune`, use the `--filter` flag to exclude images with the `preserve=true` label:
```
docker system prune -af --filter "label!=preserve=true"
```

This command prunes all unused data (containers, networks, volumes, and images) except those with the `preserve=true` label, ensuring that the locally-built image is preserved from deletion.

## Running the Docker Container

Once the Docker image is built, you can run it as a Docker container using the following steps:

1. Run the following command to start a Docker container from the image:
```
docker run --rm --name plex_dupefinder -v plex_dupefinder/app:/app plex_dupefinder
```

- Replace `plex_dupefinder/app` with the absolute path to the `app/` directory on your system.

2. If running with `SKIP_OTHER_DUPES=false`, add the `-i` option to the `docker run` command:
```
docker run -i --rm --name plex_dupefinder -v plex_dupefinder/app:/app plex_dupefinder
```

The `-i` option ensures interactive mode, allowing input to be sent to the container.
33 changes: 33 additions & 0 deletions NewFeatures_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Additional Features in Plex Dupefinder

This document outlines the additional features added to the Plex Dupefinder Python application.

## Dry Run Option

The dry run option allows users to simulate the deletion process without actually deleting any files. This option is configured using the `DRY_RUN` parameter in the `config.json` file. When enabled, Plex Dupefinder will log potential delete operations without carrying them out.

Users can also pass the `--dry-run` parameter from the command line to temporarily activate this feature.

## Preventing Plex Optimized Versions

Plex Optimized Versions are automatically excluded from consideration as duplicates. This enhancement improves the accuracy of duplicate detection by excluding files that Plex has optimized for streaming.

However, to address rare instances where Plex incorrectly identifies files as non-optimized versions, users can configure the application to exclude files located under the "Plex Versions" folder from duplicate consideration. This option is controlled by the `SKIP_PLEX_VERSIONS_FOLDER` parameter in the `config.json` file. Media files under the "Plex Versions" folder will be ignored during duplicate identification, providing an additional layer of accuracy to the duplicate detection process.

## Handling Unavailable Media Files

The application now has the ability to remove entries from Plex for media files marked as 'Unavailable'. This functionality is controlled by the `FIND_UNAVAILABLE` parameter in the `config.json` file. Plex Dupefinder will attempt to delete the entry associated with unavailable media files, excluding cases where Plex reports a file size for an unavailable file. This precautionary measure prevents accidental deletion of valid files.

## Deleting Extra .TS Files

A new option, `FIND_EXTRA_TS`, allows users to delete all `.TS` files when a non-`.TS` file is present in the duplicate list. This feature is particularly useful for cleaning up recordings when a higher-quality, non-recorded version is available. By enabling this option, users can ensure that their media library remains clutter-free and optimized for better-quality content.

## Skipping Other Duplicate Checks (Batch Mode)

The `SKIP_OTHER_DUPES` option in the `config.json` file enables users to skip other duplicate checks when not using the `AUTO_DELETE` option. This allows features like `FIND_UNAVAILABLE` and `FIND_OTHER_TS` to be run in batch mode or on a scheduled task unattended, enhancing the flexibility and automation capabilities of Plex Dupefinder.

Alternatively, users can pass the `--skip-other-dupes` parameter from the command line to temporarily activate this feature.

## Docker Image Support

A Dockerfile is provided with Plex Dupefinder, allowing users to build a local image for running Plex Dupefinder instead of installing additional software locally. This enhances portability and simplifies the deployment process, enabling users to run Plex Dupefinder in various environments without additional dependencies. For detailed instructions on building and using the Docker image, please see `Dockerfile_README.md`.
5 changes: 5 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

config_path = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'config.json')
base_config = {
'DRY_RUN': False,
'PLEX_SERVER': 'https://plex.your-server.com',
'PLEX_TOKEN': '',
'PLEX_LIBRARIES': {},
Expand All @@ -23,6 +24,10 @@
'SKIP_LIST': [],
'SCORE_FILESIZE': True,
'AUTO_DELETE': False,
'SKIP_OTHER_DUPES': False,
'SKIP_PLEX_VERSIONS_FOLDER': True,
'FIND_UNAVAILABLE': False,
'FIND_EXTRA_TS': False,
'FIND_DUPLICATE_FILEPATHS_ONLY': False
}
cfg = None
Expand Down
Loading