2023-11-14 18:12:34 -05:00
|
|
|
import pprint
|
2022-12-07 14:10:10 -05:00
|
|
|
import requests
|
2023-11-14 18:12:34 -05:00
|
|
|
import Apikeys
|
2022-12-07 14:10:10 -05:00
|
|
|
|
2023-11-14 18:12:34 -05:00
|
|
|
APIKEY = Apikeys.CHUBB
|
|
|
|
|
URL = "https://api.northpass.com/v1/media"
|
|
|
|
|
pp = pprint.PrettyPrinter(indent=4)
|
2022-12-07 14:10:10 -05:00
|
|
|
|
|
|
|
|
|
2023-11-14 18:12:34 -05:00
|
|
|
def getMedia(APIKEY, URL):
|
|
|
|
|
list_data = []
|
2024-03-07 16:15:01 -05:00
|
|
|
scorm_ids = []
|
2023-11-14 18:12:34 -05:00
|
|
|
headers = {"accept": "application/json", "X-Api-Key": APIKEY}
|
|
|
|
|
URL = f"{URL}?limit=100"
|
|
|
|
|
response = requests.get(URL, headers=headers)
|
|
|
|
|
datas = response.json()
|
2024-03-07 16:15:01 -05:00
|
|
|
# pp.pprint(datas)
|
2022-12-07 14:10:10 -05:00
|
|
|
|
2023-11-14 18:12:34 -05:00
|
|
|
for data in datas["data"]:
|
|
|
|
|
file_type = data["attributes"]["file_type"]
|
2024-03-07 16:15:01 -05:00
|
|
|
file_name = data["attributes"]["file_name"]
|
|
|
|
|
created_date = data["attributes"]["created_at"]
|
2023-11-14 18:12:34 -05:00
|
|
|
id_val = data["id"]
|
2024-03-13 16:31:57 -04:00
|
|
|
if "2024-03-12" in created_date:
|
2024-03-07 16:15:01 -05:00
|
|
|
if "scorm" in file_type:
|
|
|
|
|
data_tuple = (id_val, created_date, file_name)
|
|
|
|
|
scorm_ids.append(id_val)
|
|
|
|
|
list_data.append(data_tuple)
|
|
|
|
|
# pp.pprint(list_data)
|
|
|
|
|
# print(len(list_data))
|
|
|
|
|
print(scorm_ids)
|
2022-12-07 14:10:10 -05:00
|
|
|
|
2023-11-14 18:12:34 -05:00
|
|
|
# def toCsv(json):
|
|
|
|
|
# js = pd.json_normalize(json, "data", ["data"])
|
|
|
|
|
# # csv = pd.Series(js)
|
|
|
|
|
# js.to_csv("/Users/normrasmussen/Documents/Northpass/Scripts/API_Tests/spsmedia3.csv")
|
2022-12-07 14:10:10 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-11-14 18:12:34 -05:00
|
|
|
getMedia(APIKEY, URL)
|