30 lines
880 B
Python
Executable File
30 lines
880 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from subprocess import run, PIPE
|
|
|
|
DIRECTORIES = [{"type": "ssh", "host": "oreo@oldboy", "directory": "/media/hdd/content"},
|
|
{"type": "local", "directory": "/home/oreo/Media"}]
|
|
|
|
def make_filters(extensions):
|
|
s = []
|
|
for i, ext in enumerate(extensions):
|
|
s.append("-iname")
|
|
s.append(f"\"{ext}\"")
|
|
if i < len(extensions) - 1:
|
|
s.append("-or")
|
|
return s
|
|
|
|
def get_local_files(directory, extensions):
|
|
return ["find", directory, "-type", "f"] + make_filters(extensions)
|
|
|
|
def get_remote_files(host, directory, extensions):
|
|
return ["ssh", host, f"find {directory} -type 'f' {' '.join(make_filters(extensions))}"]
|
|
|
|
def run_command(cmd):
|
|
res = run(cmd, stdout=PIPE, stderr=PIPE, text=True)
|
|
return res.stdout.split("\n"), res.returncode
|
|
|
|
choices = dict()
|
|
|
|
'*.mp4', '*.mkv', '*.webm', '*.opus'
|