-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinks.py
More file actions
29 lines (24 loc) · 951 Bytes
/
links.py
File metadata and controls
29 lines (24 loc) · 951 Bytes
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
# pip install requests
# pip install git+https://github.com/gregmccoy/sproutvideo-python@master
#https://stackoverflow.com/questions/8247605/configuring-so-that-pip-install-can-work-from-github
from sprout.client import SproutClient
import json
def getLinks(token, tags):
sprout = SproutClient(token)
video_data = sprout.tag.get()
# writeJSONfile(video_data,'video_data.json')
videos = {}
for tag in tags:
videos[tag] = getVideosByTag(video_data, tag)
writeJSONfile(videos,'videos.json')
return videos
def getVideosByTag(json_obj, name):
dict = [json_obj][0]['tags']
for entry in dict:
if entry['name'] == name:
return entry
def writeJSONfile(json_obj,file_name):
# write videos to file
# https://stackoverflow.com/questions/12309269/how-do-i-write-json-data-to-a-file
with open(file_name, 'w') as outfile:
json.dump(json_obj, outfile, sort_keys=True, indent=4)