generated from WebexSamples/Webex-Samples-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecordings.py
63 lines (58 loc) · 2.4 KB
/
recordings.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
import json
import list_recordings
import download_recordings
from dotenv import load_dotenv
from pathlib import Path
dotenv_path = Path('.env')
load_dotenv(dotenv_path=dotenv_path)
tokenPath = list_recordings.os.path.dirname(list_recordings.os.path.abspath(__file__))
filename = list_recordings.os.path.join(tokenPath, 'token.json')
with open (filename, 'r') as openfile:
token = json.load(openfile)
bearer = token["token"]
if bearer == "":
print("No stored token. \nEnter your access token.\n")
token = input("> ")
while token == "":
print("No token entered. Try again.\n")
token = input("> ")
bearer = {"token":token}
with open('token.json', 'w') as updateToken:
json.dump(bearer, updateToken)
bearer = token
else:
print('Current Token: '+str(bearer))
headers = {
"Accept":"application/json",
"Content-Type":"application/json",
"Authorization":"Bearer "+str(bearer)
}
if not list_recordings.os.path.exists("Downloaded-Recordings/"):
list_recordings.os.makedirs("Downloaded-Recordings/")
print("This app can be used to collect all recordingIds and associated hostEmails and then download all recordings locally.")
print("First you'll choose option 1 to collect recording data and the app will terminate.")
print("After all recording data has been collected then run the app again and choose option 2 to download all recordings.\n")
print("Select an option:")
print("1 - List all recordings and save to .csv file.")
print("2 - Download recordings.\n")
run = True
while run:
choice = input("> ")
print("You selected "+choice)
try:
if choice == "1":
site_url = input("Enter the Webex site URL you want to pull recordings from.\nFor example: sitename.webex.com. \n\n> ")
weeks = input("Enter the number of weeks you would like to pull recording data for. \n\n> ")
print("Listing recordings and saving to file, please wait...\n")
result = list_recordings.list(headers, site_url, weeks)
print("Finished!")
run = result
elif choice == "2":
print("Downloading recordings...\n")
result = download_recordings.getDownloadLinks(headers)
print("Finished!")
run = result
else:
print("Invalid option.\nTry again.\n\n> ")
except Exception as e:
print(e)