2022-01-26 17:54:29 +07:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2022-01-26 17:13:42 +07:00
|
|
|
from glob import glob
|
|
|
|
import shutil
|
|
|
|
import os
|
2022-01-26 17:50:28 +07:00
|
|
|
import subprocess
|
|
|
|
import re
|
2022-01-26 17:13:42 +07:00
|
|
|
|
2022-01-26 20:06:24 +07:00
|
|
|
source_path = '/mnt/Download/finished/'
|
2022-01-26 20:05:44 +07:00
|
|
|
dest_path = '/mnt/Download/PostProcess/'
|
2022-01-26 17:13:42 +07:00
|
|
|
|
2022-01-26 18:42:49 +07:00
|
|
|
section_folders = ['4K-Movies', '4K-Series', 'Movies', 'Series']
|
2022-01-26 18:21:52 +07:00
|
|
|
|
2022-01-26 20:05:44 +07:00
|
|
|
# source_path = 'C:/Test/finished'
|
|
|
|
# dest_path = "C:/Test/PostProcess"
|
2022-01-26 18:21:52 +07:00
|
|
|
|
|
|
|
|
2022-01-26 17:52:58 +07:00
|
|
|
print("Checking if rar files and unraring...")
|
2022-01-26 20:04:26 +07:00
|
|
|
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")
|
2022-01-26 17:50:28 +07:00
|
|
|
if rar_file:
|
2022-01-26 18:52:28 +07:00
|
|
|
print(f"Found rar file {rar_file}")
|
2022-01-26 20:05:44 +07:00
|
|
|
subprocess.run(["/usr/bin/unrar", 'e', rar_file[0], '-idq', ''])
|
2022-01-26 17:13:42 +07:00
|
|
|
|
2022-01-26 20:04:26 +07:00
|
|
|
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))
|