-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
fetch-videos.py
19 lines (16 loc) · 991 Bytes
/
fetch-videos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import json
import yaml
import requests
def json_to_yaml(url, yaml_file, pages=1):
with open(yaml_file, 'w') as f:
# Write a comment at the beginning of the YAML file
f.write("# This file is automatically generated from {}\n".format(url))
f.write("# Any manual changes will be overwritten during the next build!\n\n")
for i in range(pages):
response = requests.get(url + '&page=' + str(i))
data = response.json().get('topic_list').get('topics')
yaml.dump(data, f, default_flow_style=False)
# Fetch data from Techlore forum and output
json_to_yaml('https://discuss.techlore.tech/c/content/techlore/20.json?order=created', '_data/_en/forum/latest-techlore-videos.yml', 5)
json_to_yaml('https://discuss.techlore.tech/c/content/surveillance-report/21.json?order=created', '_data/_en/forum/latest-surveillance-report-videos.yml')
json_to_yaml('https://discuss.techlore.tech/c/content/techlore-clips/19.json?order=created', '_data/_en/forum/latest-techlore-clips-videos.yml')