Add README, initial FastAPI setup, and missing configuration files
This commit is contained in:
parent
de7109b580
commit
d3b4ce51e5
28
README.md
28
README.md
@ -1 +1,27 @@
|
|||||||
# file-organizer
|
# file-organizer
|
||||||
|
|
||||||
|
This is a custom made software to perform maintenance on downloaded files for DarkBird's anime website.
|
||||||
|
|
||||||
|
# System Overview
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
|
||||||
1
config/patterns.txt
Normal file
1
config/patterns.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
^\[Erai-raws\] (.*) - .*$
|
||||||
BIN
docs/overview.png
Normal file
BIN
docs/overview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 511 KiB |
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
requests
|
||||||
|
fastapi
|
||||||
24
src/main.py
24
src/main.py
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import re
|
import re
|
||||||
import json
|
|
||||||
import requests
|
import requests
|
||||||
|
from fastapi import FastAPI
|
||||||
|
|
||||||
def login_qbittorrent(api_url, username, password):
|
def login_qbittorrent(api_url, username, password):
|
||||||
login_url = f'{api_url}/api/v2/auth/login'
|
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.")
|
print(f"The config file {config_file_path} does not exist.")
|
||||||
patterns = []
|
patterns = []
|
||||||
|
|
||||||
if len(patterns) > 0:
|
app = FastAPI()
|
||||||
# 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}")
|
@app.get("/")
|
||||||
print(f"Downloading files: {downloading}")
|
async def root():
|
||||||
group_files_by_prefix(os.path.join(os.getcwd(), 'testfiles'), patterns, downloading)
|
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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user