FileBotROuGGy/filebot.py
2022-01-26 20:05:44 +07:00

31 lines
1.0 KiB
Python

#!/usr/bin/python3
from glob import glob
import shutil
import os
import subprocess
import re
source_path = Path('/mnt/Download/finished/')
dest_path = '/mnt/Download/PostProcess/'
section_folders = ['4K-Movies', '4K-Series', 'Movies', 'Series']
# source_path = 'C:/Test/finished'
# dest_path = "C:/Test/PostProcess"
print("Checking if rar files and unraring...")
for section in section_folders:
if os.path.exists(os.path.join(source_path, section)):
for dir in os.listdir(os.path.join(source_path, section)):
rar_file = glob(f"{os.path.join(source_path, section, dir, '')}*rar")
if rar_file:
print(f"Found rar file {rar_file}")
subprocess.run(["/usr/bin/unrar", 'e', rar_file[0], '-idq', ''])
for section in section_folders:
if os.path.exists(os.path.join(source_path, section)):
for dir in os.listdir(os.path.join(source_path, section)):
shutil.move(os.path.join(source_path, section, dir), os.path.join(dest_path, section))