| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 | #!/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'
 |