From c444b33d08025b31bbd0298b70ccd2c5f9be5f55 Mon Sep 17 00:00:00 2001 From: davnozdu <92220901+davnozdu@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:11:22 +0200 Subject: [PATCH] Add files via upload --- README.md | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20e7589..42c60ca 100644 --- a/README.md +++ b/README.md @@ -1 +1,130 @@ -# batinapka \ No newline at end of file + +# BatinaPapka + +**BatinaPapka** is a Python script designed to automatically rename video files in a specified directory based on search results from the Brave Search API. The script cleans up filenames by removing special characters, video hosting site names, and adds the publication date from search results. If the date cannot be found online, it defaults to the file's modification date. + +## Features + +- **Automatic Renaming**: Renames video files using titles and dates found via Brave Search API. +- **Date Handling**: Prioritizes online publication dates but uses file modification dates if none are found. +- **Cache Implementation**: Caches API responses to reduce redundant API calls. +- **File Extension Support**: Supports common video formats such as `.mp4`, `.avi`, `.mov`, `.mkv`, `.flv`, and `.wmv`. +- **Log Management**: Maintains a log file of renamed files and trims the log to the last 100 lines to save space. +- **Exclusion Filters**: Filters out irrelevant results like Wikipedia, IMDb, and other non-video hosting sites. + +## Installation + +### Download and Run the Script + +1. **Download the Script:** + - Download the `batinapapka.py` file from the repository. + - Save it to a directory on your computer. + +2. **Install Required Python Packages:** + Ensure you have Python 3 installed. Install the necessary dependencies using pip: + ```bash + pip install requests + ``` + +3. **Set Your Brave API Key:** + Open the `batinapapka.py` script in your favorite text editor and replace `"YOUR_API_KEY"` with your actual Brave API key. + + ```python + API_KEY = "YOUR_API_KEY" + ``` + +### Run Using Docker + +If you prefer to run the script using Docker, follow these steps: + +1. **Set Up the Docker Environment:** + Ensure Docker is installed on your system. + +2. **Prepare the Docker Compose File:** + Use the following Docker Compose configuration: + + ```yaml + version: '3.7' + + services: + rename_script: + image: python:3.9-slim + container_name: batinapapka + volumes: + - /share/YOUR_VIDEO_FOLDER:/share + command: > + sh -c " + apt-get update && + apt-get install -y cron iputils-ping vim nano mc && + pip install requests beautifulsoup4 && + echo '0 3 * * * /usr/local/bin/python /usr/src/app/batinapapka.py /share >> /var/log/cron.log 2>&1' > /etc/cron.d/rename_cron && + chmod 0644 /etc/cron.d/rename_cron && + crontab /etc/cron.d/rename_cron && + touch /var/log/cron.log && + cron && tail -f /var/log/cron.log + " + working_dir: /usr/src/app + stdin_open: true + tty: true + networks: + - rename_net + + networks: + rename_net: + driver: bridge + ``` + +3. **Build and Run the Docker Container:** + - Replace `/share/YOUR_VIDEO_FOLDER` with the path to the directory containing your video files. + - Deploy the stack or use the following command to start the container: + ```bash + docker-compose up -d + ``` + + The script will run daily at 3:00 AM, renaming any new video files according to the Brave Search results. + +## How to Get Your Brave API Key + +1. **Sign up for the Brave Search API:** + - Visit the [Brave Search API](https://brave.com/search/api/) page. + - Sign up for an account if you don't have one. + - Follow the instructions to obtain your API key. + +2. **Add the API Key to the Script:** + - Replace the placeholder in the script with your API key. + +## Usage + +1. **Run the Script Manually:** + To rename video files in a directory, run the following command: + + ```bash + python batinapapka.py /path/to/your/video/files + ``` + +2. **Run the Script via Docker:** + Once the Docker container is running, it will automatically rename files in the specified directory based on the schedule set in the Docker Compose file. + +## Example + +Before running the script: +``` +/path/to/your/video/files +├── video123.mp4 +├── movie_trailer.avi +``` + +After running the script: +``` +/path/to/your/video/files +├── 2024-01-01 Example Video Title.mp4 +├── 2023-12-31 Another Video Title.avi +``` + +## Contributing + +If you'd like to contribute to this project, please fork the repository and use a feature branch. Pull requests are welcome. + +## License + +This project is open-source and available under the MIT License.