GithubHelp home page GithubHelp logo

sureshfizzy / cinesync Goto Github PK

View Code? Open in Web Editor NEW
38.0 2.0 5.0 834 KB

CineSync is a Python & Bash based library management tool designed to organize debrid & local libraries without the support of Sonarr & Radarr

Shell 78.68% Python 21.32%

cinesync's Introduction

CineSync - Organize Your Debrid Library Easily

CineSync is a Python & Bash based library management system designed to facilitate the organization of debrid libraries for Shows efficiently, without the need for Sonarr. Users downloading from DMM Manager can easily sort their library into seasons, whether it's a single file or a folder. CineSync smoothly organizes the library and creates symbolic links, giving users full control over their data locally.

This project will seamlessly integrate with any files that need to be organized (TV shows for now). This project will also work with Zurg. Special thanks to yowmamasita.

General Info

CineSync works by creating symbolic links from the source directory to the destination directory and organizing them according to the user's preferences. This allows users to maintain a well-structured library without physically moving or duplicating the original files.

Features

  • Library Organization: Easily sort your library into seasons, regardless of file or folder structure.
  • Symbolic Link Creation: Create symbolic links to organize your library without moving or duplicating files.
  • Real-Time Monitoring for Files: Monitor the watch directory for any new files and automatically create symbolic links for them, ensuring your library stays updated in real-time.
  • Support for Single Symlinks Creation: CineSync now supports creating symbolic links for single files or folders, providing flexibility in managing your library.
  • Ability to Skip Already Present Symlinks: CineSync includes the ability to skip the creation of symbolic links for files or folders that are already present, even if the folder name is different. This feature ensures efficient management of your library by preventing duplicate symlinks.
  • Rename Files: Properly rename your files based on TMDB data .
  • Cross-Platform Support: Works on both Linux and Windows operating systems.

Real-Time Monitoring

CineSync offers a powerful real-time monitoring feature that allows users to keep track of changes in their library automatically. This feature is particularly useful for handling daily series or shows that are regularly downloaded. Here's how it works:

Real-Time Monitoring

  • Watch Directory: CineSync continuously monitors a designated watch directory where new files or folders are expected to be added.

  • Default Monitoring Interval: By default, CineSync checks the watch directory every 60 seconds for any changes. You can Increase/Decrease the time limit inside RealTime-Monitoring.py

  • Automatic Identification: When a new file or folder is detected in the watch directory, CineSync automatically identifies it.

  • Symbolic Link Creation: After identification, CineSync creates symbolic links for the newly added file or folder. These symbolic links ensure that the organization of the library remains intact without physically moving or duplicating the files.

  • Efficiency: Real-time monitoring ensures that users stay up-to-date with their library changes without manual intervention. It streamlines the process of handling daily series or shows by automatically organizing new additions.

  • Customization: Users have the flexibility to customize the monitoring interval according to their preferences or specific requirements.

By leveraging real-time monitoring in CineSync, users can effortlessly manage their library and maintain a well-organized collection of media files.

Getting Started

Requirements

  • Python 3.x
  • For Windows: Git Bash with symbolic links enabled
  • NSSM for Windows (if you want to enable real-time monitoring).
  • Zurg (optional)

Configuration Variables

Make sure to edit the .env value before running the script. Below are the configurable variables used in the script, along with their descriptions and default values:

Variable Description Default Value
SOURCE_DIR The directory paths where the source files are located. Multiple directories can be specified, separated by commas. /path/to/files
DESTINATION_DIR The path to the destination directory where the symlinks or files will be placed. /path/to/destination
LOG_LEVEL Defines the level of logging. Available options: DEBUG, INFO, WARNING. INFO
OVERRIDE_STRUCTURE Determines whether to maintain the same directory structure in the destination as in the source (false). Setting this to true will flatten the structure, not using the same structure as the source directory. false
RENAME_ENABLED Enable or disable file renaming functionality from TMDB. false
BEARER_TOKEN Your API read access token for TMDB. your-api-read-access-token

For Linux:

Here's an enhanced version of the instructions:

  1. Clone the Repository: Clone the CineSync repository from GitHub and navigate to the cloned directory:

    git clone https://github.com/sureshfizzy/CineSync.git && cd CineSync
    
  2. Install the Requirements: Install the required dependencies for CineSync:

    pip install -r requirements.txt
    
  3. Update Paths in .env: Open the .env file located inside the CineSync folder. Update the following paths:

    • SOURCE_DIR: Specify the path for the Source directory.
    • DESTINATION_DIR: Set the ultimate destination directory where you want to save the symbolic links.

    Note: Ensure that the paths are correctly updated to reflect your system's configuration.

  4. Execute CineSync: After updating the paths, execute the main script:

    bash CineSync.sh
    

    This will launch the CineSync interface, allowing you to perform various library management tasks, including full library scans, real-time monitoring, and more.

By following these steps and updating the necessary paths, you'll be able to successfully use CineSync to manage your debrid library.

For Windows:

  1. Install Python: Install Python from the official website: Python.org. Make sure to add Python to your system PATH during installation.

  2. Install Git Bash: Install Git Bash from Git for Windows. During installation, enable the symbolic links checkbox.

Git Bash

Enabling symbolic links is important for certain operations, so ensure that the checkbox for symbolic links is checked during installation.

  1. Edit .bashrc (Windows): Open Git Bash as an administrator and edit the .bashrc file. You can use the nano editor to open the file by running the following command:

    nano /etc/bash.bashrc
    

    Add the following line at the bottom of the file:

    export MSYS=winsymlinks:nativestrict
    

    Save the changes by pressing Ctrl + O, then press Enter to confirm. Exit the editor by pressing Ctrl + X.

    Important: Ensure that the export MSYS=winsymlinks:nativestrict line is added to the .bashrc file. This configuration is essential to ensure that symbolic links are handled correctly on Windows when using Git Bash. Without this setting, CineSync may copy files instead of creating symbolic links, leading to undesired behavior.

  2. Enable Windows Developer Mode:

    Enabling Developer Mode grants your system additional privileges necessary for certain operations, helping to prevent permission-related errors during development.

    To avoid "Operation not permitted" errors during symlink process, it's essential to enable Windows Developer Mode. Follow these steps:

    • Open Settings.
    • Go to Update & Security.
    • Click on For developers.
    • Enable the Developer mode option.
    • Restart the PC

    Developer Mode

  3. Clone the Repository:

    git clone https://github.com/sureshfizzy/CineSync.git
    
  4. Update Paths in .env: Open the .env file located inside the CineSync folder. Update the following paths:

    • SOURCE_DIR: Specify the path for the Source directory.
    • DESTINATION_DIR: Set the ultimate destination directory where you want to save the symbolic links.

    Note: Ensure that the paths are correctly updated to reflect your system's configuration.

  5. Run the Script:

    bash CineSync.sh
    

Real-Time Monitoring on Windows using NSSM

This guide will walk you through the process of setting up real-time monitoring for CineSync Monitor on Windows using NSSM (Non-Sucking Service Manager). Real-time monitoring ensures that CineSync Monitor runs continuously in the background as a system service.

Prerequisites

  • NSSM: Download and install NSSM from the official website: NSSM Releases

Installation Steps

1. Download and Install NSSM

  1. Download the latest version of NSSM from the official website.
  2. Extract the downloaded ZIP file to a location on your computer.
  3. Open the extracted folder and locate the nssm.exe executable.

2. Mount CineSync Monitor as a System Service

  1. Place NSSM Executable Inside the Scripts Folder: Move the nssm.exe executable into the Scripts folder.

  2. Run NSSM Install Command: Open a Command Prompt with administrative privileges, navigate to the Scripts folder, and run the following command:

    nssm install CineSync-Monitor
    

3. Configure NSSM

  1. Configure NSSM: In the NSSM GUI that appears:

    • Application Path: Choose the python.exe executable. You can find it by opening Git Bash and running which python.
    • Arguments: Pass the folder path where realtime-monitor.py is located, for example: C:\Users\YourUserName\Desktop\CineSync\Scripts\RealTime-Monitor.py.
    • Click "Install Service".

    NSSM

  2. Set Source and Destination Paths: Before running realtime-monitor.py as a system service, ensure that source and destination paths are correctly set inside library.sh.

  3. Run Real-Time Monitoring: After installation, the files will be watched in real-time, and symlinks will be created if any changes are detected.

  4. Removing the System Service: To remove the system service, simply type:

    nssm remove CineSync-Monitor
    

Additionally, you can also directly run the Python script on Git Bash if needed.

Usage

CineSync provides a user-friendly interface for managing your debrid library. Upon running the script, you'll be presented with a main menu where you can choose from various options:

Main Menu

  • 1) Edit .env file: Update Basic Configurations in this file.

  • 2) Full Library Scan: Perform a comprehensive scan of your entire library.

Full_Scan Full_ScanOP Full_ScanOP2 Full_ScanOP3
  • 3) Real-Time Monitoring (Linux Only): Enable real-time monitoring to stay updated on library changes. System services are automatically created, and the scan is triggered every 60 seconds. You can adjust the frequency inside RealTime-Monitor.py.
  • 4) Remove Broken Symlinks : Identify and remove broken symbolic links within your library.
  • 5) TMDB Renamer: Ability to perform renaming for all the files present in destination directory.

TMDB

  • 6) Exit: Quit the CineSync application.

Note: Real-Time Monitoring is currently supported only on Linux due to system service limitations on Windows. However, you can still manually trigger real-time monitoring using the provided instructions in the README.

Single File/Folder Symlink Creation

CineSync also supports the creation of single file or folder symlinks. Follow these steps to create a symlink for a single file or folder:

  1. Navigate to Scripts Folder:

    • Open your terminal or command prompt and navigate to the Scripts folder of the CineSync repository.
  2. Enter Series Name and Full Path:

    • Inside the Scripts folder, run the following command:
      bash ./library.sh "/mnt/Real-Debrid/remote/rclone/Shows/13.Reasons.Why.S03.1080p.WEBRip.x265-RARBG/13.Reasons.Why.S03E09.1080p.WEBRip.x265-RARBG.mp4"
      Replace "/mnt/Real-Debrid/remote/rclone/Shows/13.Reasons.Why.S03.1080p.WEBRip.x265-RARBG/13.Reasons.Why.S03E09.1080p.WEBRip.x265-RARBG.mp4" with the full path to the file or folder you want to create a symlink for.
  3. Execute Command:

    • Press Enter to execute the command.
Single_File Single_FileOP

By following these steps, you can easily create a symlink for a single file or folder using CineSync.

Integrating TMDB API for renaming files

CineSync can be enhanced by integrating the TMDB (The Movie Database) API to fetch additional metadata for your media library. Follow the steps below to set up and use the TMDB API with CineSync.

Prerequisites

  • A TMDB account. If you don't have one, you can create it here (https://www.themoviedb.org/).
  • A TMDB API key. You can obtain this from the TMDB API section.

Setting Up TMDB API

Get Your API Key:

  • Log in to your TMDB account.
  • Navigate to the API section of your account settings.
  • Generate a new API key or use an existing one, you need to use API READ ACCESS TOKEN key.
  • Update key in .env file

TMDB

Contributors

cinesync's People

Contributors

sureshfizzy avatar diego-dfc avatar

Stargazers

 avatar  avatar  avatar Dave Torres avatar Lazaros Totsas avatar  avatar  avatar David Howell avatar  avatar BFMC avatar  avatar 3TH01 avatar Lucas Gauvain avatar  avatar Kin♡ avatar  avatar  avatar  avatar  avatar boooosh avatar  avatar  avatar patrick avatar  avatar  avatar Prasad avatar  avatar Andres avatar Luke Biddell avatar  avatar  avatar  avatar  avatar  avatar  avatar Emmanuel EH Hall avatar  avatar SK Mezanul Haque avatar

Watchers

 avatar  avatar

cinesync's Issues

I may have found an huge optimization

Hi,

First of all thanks for your amazing work here with CineSync, I'm an order maniac and today I've been working for 3 hours trying to optimize Zurg and CineSync. I think I may have found a very good sorting scheme but I'd like to discuss with you since I'm not sure I'm on the right way.

Please, reach me out wherever you prefer, I have both telegram (nomorenecessary) or discord (nomorenecessary) and thanks in advance for your attention

Absolute Symlinks vs Relative

i discovered while generating my symlinks that CineSync creates absolute path symlinks vs relative path symlinks and my plex library doesn't detect media when symlinks are absolute path

current mount path is /home/username/mnt/zurg/shows, configured CineSync to generate symlinks in:

/home/username/media/zurg/shows (Where I have my Plex library media for Series configured)

e.g:

absolute

1883.S01E01.1883.2160p.WEB-DL.DDP5.1.H.265-NTb.mkv -> /home/username/mnt/zurg/shows/1883.S01.2160p.WEB-DL.DDP5.1.H.265-NTb/1883.S01E01.1883.2160p.WEB-DL.DDP5.1.H.265-NTb.mkv

vs

relative:

1883.S01E01.1883.2160p.WEB-DL.DDP5.1.H.265-NTb.mkv -> ../../../../../mnt/zurg/shows/1883.S01.2160p.WEB-DL.DDP5.1.H.265-NTb/1883.S01E01.1883.2160p.WEB-DL.DDP5.1.H.265-NTb.mkv

so i've ran this simple bash script to fix all my links to relative path for now.

Can we get an env option to create relative symlinks instead?

I'm not sure if this is just me, but i've always had to use relative symlinks for Plex on Linux

Rar files being symlinked

Would it be possible for the script to skip creating symlinks for rars and spilt rars I know it won't affect the files being played but would clean up the folders better.

Source paths in windows

Hi, thanks for this great program. I have an issue on windows 11, how can i make the script scan 2 source folders one for movies and one for shows?

I tried editing the env file and different ways to declare the source but it doesn't seem to scan both folders.

Thanks in advance

Random folders on root dir

This morning I logged into my server and randomly did an ls -la on my root folder / and noticed that there was 6 new folders made named Season 1-6 and looked inside them and found random symlinks for various different series in the one folder outside what I have set with in the library.sh file so not sure how they got made.

Screenshot_20240531-194206.png

Screenshot_20240531-193833.png

Systemd service not working

As stated in a comment on one of the other issues the realtime monitor doesn't want to work correctly and exits far too quickly. I have added loads of test content and let the monitor do its thing but hours later not symlinks have been made for the newly added content. I have even manually run the library.sh file and get the same result.

This is the script output

Running on Linux
OS Version: #1 ZEN SMP PREEMPT liquorix 6.8-16ubuntu1~jammy (2024-05-22)
Watching directory: /location 
Destination directory: /location
Scanning directory for changes...
Scan complete.

It's as if it doesn't want to scan anything.

Renaming of symlinks

Would it be possible for the script to rename the outputted symlinks and also rename the current ones. The reason I ask the media parser I use is very picky over file naming for instance this file

Tiger.King.Murder.Mayhem.and.Madness.S01E08.720p.WEB.X264-AMRAP[eztv].mkv

The parser doesn't like the likes of brackets etc in the naming of the files so would it be possible to customise the naming scheme for instance like this:

{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}

Naming convention

Any chance this could be set to use this naming convention so it could be used to move libraries between Plex debrid and the new riven app?

movies

  • Movie Title (year) (imdbid-ttxxxxx)
    ---- Movie Title (year) (imdbid-ttxxxxx).mkv

shows
-Show Title (year) (imdbid-ttxxxxx)
---- Season 01
----- Show Title - sO1e01 - episode title.mkv

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.