-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylists.py
33 lines (27 loc) · 897 Bytes
/
playlists.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
"""
Copyright (C) 2014, Jill Huchital
"""
USHAHIDI_API_KEY = '5435a4f76d18ed0f54deba52'
USHAHIDI_QUERY_URL = 'http://api.crisis.net/item/?sources=youtube'
import requests
def ushahidi_data():
videos = []
headers = {'Authorization': 'Bearer ' + USHAHIDI_API_KEY}
try:
r = requests.get(USHAHIDI_QUERY_URL, headers=headers)
json_data = r.json();
for d in json_data['data']:
if 'source' in d and d['source'] == 'youtube' and 'remoteID' in d and 'contentEnglish' in d:
videos.append(d['remoteID'])
except:
print 'something bad'
return videos
def get_all_playlists():
retval = []
ushahidi_playlist = ushahidi_data()
new_playlist = dict(playlist_name = "SYRIA",
playlist_videos = ushahidi_playlist)
print new_playlist
retval.append(new_playlist)
print retval
return retval