Skip to content

f-o/upx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UPX Logo
Torrent Upload Helper Script

A Python utility to automate the process of generating screenshots from video files, uploading them to image hosting services, and preparing torrent descriptions with mediainfo. This script is designed to streamline the workflow for content uploaders, especially those sharing on private trackers.

FeaturesRequirementsInstallationConfigurationUsageModifying the ScriptNotesSupport

Features

  • Takes input as either a single file or a folder
  • If folder input: lists video files and asks user to select one
  • Generates screenshots at configurable intervals using ffmpeg
  • Uploads screenshots to one of 3 image hosts:
    • Catbox
    • ImgBB
    • PtScreens
  • Generates mediainfo for the video file
  • Creates a torrent file using mkbrr
  • Generates a description file with uploaded image URLs and mediainfo
  • Stores preferences in a config file for future runs

Requirements

  • Python 3.7+
  • ffmpeg
  • ffprobe
  • curl
  • vcsi (for contact sheets)
  • mkbrr (for torrent creation)

Installation

  1. Clone the repository:
git clone https://github.com/f-o/upx.git
cd upx
  1. Make a virtual environment (optional but recommended):
python3 -m venv venv
source venv/bin/activate
  1. Install Python dependencies:
pip install -r requirements.txt
  1. (Optional) Add an alias to run the script using the virtual environment.
alias upx='/path/to/upx/venv/bin/python3 /path/to/upx/upx.py'

Configuration

The config.json file stores your preferences:

{
    "num_screenshots": 6,
    "screenshot_start_time": 10,
    "mediainfo_file": "~/mediainfo.txt",
    "description_file": "~/description.txt",
    "torrent_output_dir": "~/",
    "image_hosts": {
        "catbox": {
            "name": "Catbox",
            "endpoint": "https://catbox.moe/user/api.php",
            "userhash": ""
        },
        "imgbb": {
            "name": "ImgBB",
            "endpoint": "https://api.imgbb.com/1/upload",
            "api_key": ""
        },
        "ptscreens": {
            "name": "PtScreens",
            "endpoint": "https://ptscreens.com/api/1/upload",
            "api_key": ""
        }
    },
    "description_template": "[size=3]Previews[/size][spoiler]\n[align=center]\n{screenshots}\n[/align]\n[/spoiler]\n\n[size=3]Mediainfo[/size][spoiler]\n[code]{mediainfo}[/code]\n[/spoiler]",
    "last_image_host": "",
    "last_tracker_name": "",
    "last_tracker_announce_url": ""
}
  • num_screenshots: Number of screenshots to generate (default is 6)
  • screenshot_start_time: Time (in seconds) to start taking screenshots (default is 10)
  • mediainfo_file: Path to save the generated mediainfo text file
  • description_file: Path to save the generated description text file
  • torrent_output_dir: Directory to save the generated torrent file
  • image_hosts: Configuration for supported image hosts (script will automatically prompt for necessary credentials if not set)
  • description_template: A template for the description file, using {mediainfo} and {screenshots} as placeholders
  • last_image_host: Stores the last used image host for convenience
  • last_tracker_name: Stores the last used tracker name for convenience
  • last_tracker_announce_url: Stores the last used tracker announce URL for convenience

Usage

Run the script:

python upx.py

Alternatively, if you set up the alias:

upx

The script will:

  1. Ask which image host to use
  2. Ask if you want to generate a contact sheet (requires vcsi)
  3. Ask which tracker you want to create the torrent for (stores announce URL for future runs)
  4. Ask for a file or folder path
  5. If folder: ask which single video file to use for screenshots
  6. Generate screenshots at configured intervals
  7. Upload screenshots to your chosen host
  8. Generate mediainfo for the video file
  9. Generate a description file with uploaded image URLs and mediainfo
  10. Create a torrent file with the specified announce URL

Modifying the Script

The code is intentionally made simple to allow for easy modifications. You can easily modify:

  • Screenshot count (change num_screenshots in config.json)
  • Screenshot timing (change screenshot_start_time in config.json)
  • Upload endpoints in the config.json
  • Add new image host functions (add function like upload_to_newhost() and update upload_screenshots())

Notes

  • Temporary screenshot files are stored in a temp_screenshots folder and automatically cleaned up
  • Mkbrr workers is set to 4 for faster torrent creation, adjust in create_torrent() if needed
  • Make sure to have the required tools (ffmpeg, curl, vcsi, mkbrr) installed and in your system PATH for the script to work properly
  • This script is based off of an old bash script I wrote for personal use, so there may be some quirks or edge cases that haven't been fully handled. Feel free to contribute improvements!

Support

This project is free and open source.
If you find it useful, please consider supporting the project by donating.

Buy Me A Coffee

About

🖼️ A Python utility to automate the process of generating screenshots from video files, uploading them to image hosting services, and preparing torrent descriptions with mediainfo. Supports Catbox, ImgBB, & PtScreens.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages