-
Notifications
You must be signed in to change notification settings - Fork 11
/
generate_commands.py
63 lines (53 loc) · 1.49 KB
/
generate_commands.py
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
57
58
59
60
61
62
63
#!/usr/bin/python3
""" Upload talks
"""
import json
import yaml
TALKS = yaml.load(open('talks.yaml'))
desc = """
PyCon Thailand: https://2018.th.pycon.org/
{title}
Speaker: {speaker}
------------
Description:
{description}
------------
Bio:
{bio}
"""
META_TMPL = {
"title": "my test title",
"description": "my test description",
"tags": ["python", ],
"privacyStatus": "public",
"embeddable": True,
"license": "creativeCommon",
"publicStatsViewable": True,
# "publishAt": "2017-06-01T12:05:00+02:00",
"categoryId": "22", # People & Blogs (like PyCon US)
"recordingdate": "2018-06-16",
"location": {
"latitude": 13.7205,
"longitude": 100.498368
},
"locationDescription": "Knowledge Exchange Center – KX",
"playlistTitles": ["PyCon Thailand 2018"],
"language": "en"
}
with open('commands.sh', 'w') as commands:
for talk in TALKS:
if 'file' not in talk:
commands.write('# "{}" missing\n'.format(talk['title']))
continue
talk['description'] = desc.format(**talk)
meta = {}
meta.update(META_TMPL)
meta.update(talk)
fn = talk['file']
if "/17/" in fn:
meta['recordingdate'] = "2018-06-17"
jsonfn = '{}.json'.format(fn)
with open(jsonfn, 'w') as meta_json:
json.dump(meta, meta_json)
command = './youtubeuploader_linux_amd64 -metaJSON "{}" -filename "{}"\n'.format(jsonfn, fn)
commands.write(command)