-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.py
More file actions
57 lines (41 loc) · 1.25 KB
/
upload.py
File metadata and controls
57 lines (41 loc) · 1.25 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os, json, shutil
from pprint import pprint
import subprocess
def uploadfiles():
list = []
for root, dirs, files in os.walk("Finished/"):
for file in files:
if file.endswith(".json"):
list.append(os.path.join(root, file))
return list
def dict_to_array(d):
return [(k, v) for k, v in d.items()]
def buildCmd(item):
args = ['youtube-upload']
list = dict_to_array(item)
for pair in list:
args.append(pair[0])
args.append(pair[1])
#args.append("4/1AWtgzh6NymVvgYTbb6v1fm6evFfWWeVixnIjPf8sxu-F4EbJyNsB9SoQDd8")
args.pop()
return args
def openFile(file):
with open(file, 'r') as json_file:
content = json_file.read()
return json.loads(content)
def doUpload(item):
cmd = buildCmd(item)
print(f"[uploading {item['--title']}...]")
print(subprocess.check_output(cmd))
shutil.copyfile(f"Finished/{item['--title']}.json", f"Uploaded/{item['--title']}.json")
def main():
print("[start]")
files = uploadfiles()
for file in files:
item = openFile(file)
found = os.path.isfile(f"Uploaded/{item['--title']}.json")
if (found):
continue
doUpload(item)
if __name__ == "__main__":
main()