diff --git a/README.md b/README.md index ebfdb1c..a4b9e95 100644 --- a/README.md +++ b/README.md @@ -1 +1,27 @@ -# file-organizer \ No newline at end of file +# file-organizer + +This is a custom made software to perform maintenance on downloaded files for DarkBird's anime website. + +# System Overview + +![System Overview](docs/overview.png) + +The application consist of a simple API with a single endpoint which starts a job and returns its ID. Then the job is orchestrated on a different thread following these steps: + +1. Filtering:\ +Fetch from the qbittorrent API the files that are currently being downloaded in order to filter them out of the process. +2. Deduplication:\ +Invoke a [Czkawka](https://github.com/qarmin/czkawka) process to identify duplicate files, keep the appropiate version for each episode. +3. Moving:\ +Using regex, identify the directory where each file should be located, and the new name it should have. +4. Log storage:\ +Store all the logs for the current job in order to be able to debug and keep trazability of the process. + +# Roadmap: +- [x] Be able to move and rename files based on a regex +- [ ] Read qbittorrent credentials from .env file +- [ ] Implement API endpoint using FastAPI +- [ ] Deduplicate files using Czkawka +- [ ] Add unit tests +- [ ] Add logging +- [ ] Create another endpoint to retrieve the logs of a job \ No newline at end of file diff --git a/config/patterns.txt b/config/patterns.txt new file mode 100644 index 0000000..299ff23 --- /dev/null +++ b/config/patterns.txt @@ -0,0 +1 @@ +^\[Erai-raws\] (.*) - .*$ \ No newline at end of file diff --git a/docs/overview.png b/docs/overview.png new file mode 100644 index 0000000..d66472f Binary files /dev/null and b/docs/overview.png differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..af93f53 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +fastapi \ No newline at end of file diff --git a/src/main.py b/src/main.py index 635a410..ee726c4 100644 --- a/src/main.py +++ b/src/main.py @@ -1,8 +1,8 @@ import os import shutil import re -import json import requests +from fastapi import FastAPI def login_qbittorrent(api_url, username, password): login_url = f'{api_url}/api/v2/auth/login' @@ -84,12 +84,18 @@ else: print(f"The config file {config_file_path} does not exist.") patterns = [] -if len(patterns) > 0: - # TODO: READ USER AND PASS FROM ENV FILE - cookies = login_qbittorrent('http://qbittorrent.xdarkbird.duckdns.org', 'USER', 'PASS') - downloading = get_qbittorrent_files_downloading('http://qbittorrent.xdarkbird.duckdns.org', cookies) - logout_qbittorrent('http://qbittorrent.xdarkbird.duckdns.org', cookies) +app = FastAPI() - print(f"Patterns: {patterns}") - print(f"Downloading files: {downloading}") - group_files_by_prefix(os.path.join(os.getcwd(), 'testfiles'), patterns, downloading) +@app.get("/") +async def root(): + return {"Hello": "World"} + +# if len(patterns) > 0: +# # TODO: READ USER AND PASS FROM ENV FILE +# cookies = login_qbittorrent('http://qbittorrent.xdarkbird.duckdns.org', 'USER', 'PASS') +# downloading = get_qbittorrent_files_downloading('http://qbittorrent.xdarkbird.duckdns.org', cookies) +# logout_qbittorrent('http://qbittorrent.xdarkbird.duckdns.org', cookies) + +# print(f"Patterns: {patterns}") +# print(f"Downloading files: {downloading}") +# group_files_by_prefix(os.path.join(os.getcwd(), 'testfiles'), patterns, downloading)