-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexportSeries.py
More file actions
40 lines (29 loc) · 1.17 KB
/
exportSeries.py
File metadata and controls
40 lines (29 loc) · 1.17 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
import sys,requests,re,os
from requests.auth import HTTPDigestAuth
import config, handleSeries
#Digest login source server
sourceauth = HTTPDigestAuth(config.sourceuser, config.sourcepassword)
#Source Engage Server data
searchrequest = config.engageserver + config.seriesSearchendpoint + sys.argv[1]
print searchrequest
# check if Series exists, else create
handleSeries.handleSeries(sys.argv[1])
#Opencast sends an Object if list cotains only one Item instead of list
def jsonMakeObjectToList(jsonobject):
if (not isinstance(jsonobject, list)):
tmpObject = jsonobject
jsonobject = []
jsonobject.append(tmpObject)
return jsonobject
else:
return jsonobject
# Get mediapackage from search service
searchresult = requests.get(searchrequest, auth=sourceauth, headers=config.header)
mediapackagesearch = searchresult.json()['search-results']['result']
mediapackagesearch=jsonMakeObjectToList(mediapackagesearch)
#ingest each Episode
for mediapackage in mediapackagesearch:
print "Ingesting id: "+ mediapackage['mediapackage']['id'] + "\n"
command = 'python exportEpisode.py '+ mediapackage['id']
print command +"\n"
os.system(command)