import requests
from datetime import datetime
# Data Visualization: Coding Graph: tracking by hours
# shibafu=green, sora=blue, ajisai=purple, momiji=red, ichou=yellow, kuro =black
USERNAME = "YOUR USERNAME"
TOKEN = "YOUR TOKEN"
GRAPH_ID = "YOUR GRAPH ID"
GRAPH_ID2 = "Top Movies"
pixela_endpoint = "https://pixe.la/v1/users"
user_parameters = {
"token": TOKEN,
"username": USERNAME,
"agreeTermsOfService": "yes",
"notMinor": "yes",
}
# response = requests.post(url=pixela_endpoint, json=user_parameters)
#print(response.text)
graph_endpoint = f"{pixela_endpoint}/{USERNAME}/graphs"
graph_config = {
"id": GRAPH_ID,
"name": "Programmatic Graph",
"unit": "hours",
"type": "float",
"color": "ajisai"
}
headers = {
"X-USER-TOKEN": TOKEN
}
#POST
# response = requests.post(url=graph_endpoint, json=graph_config, headers=headers)
# print(response.text)
pixel_creation_endpoint = f"{pixela_endpoint}/{USERNAME}/graphs/{GRAPH_ID}"
# REMEMBER, IF YOU HAVE DATA FROM PREVIOUS DAYS, SET THE DATE UNDERNEATH HERE,
THEN UNCOMMENT IT OUT AND COMMENT THE DATETIME.NOW()
#today = datetime(year=2022, month=3, day=24)
today = datetime.now()
# print(f'today is day {(today.strftime("%m-%d-%Y"))} ')
pixel_data = {
"date": today.strftime("%Y%m%d"),
"quantity": input("How many hours have you studied today?"),
}
#THIS IS FOR UPDATING PIXEL PROGRESS DATA
response = requests.post(url=pixel_creation_endpoint, json=pixel_data, headers=headers)
print(response.text)
update_endpoint = f"{pixela_endpoint}/{USERNAME}/graphs/{GRAPH_ID}/{today.strftime('%Y%m%d')}"
# new_pixel_data = {
# "quantity": "7"
# }
# response = requests.put(url=update_endpoint, json=new_pixel_data, headers=headers)
#THIS IS FOR DELETING PIXEL PROGRESS DATA
# delete_endpoint = f"{pixela_endpoint}/{USERNAME}/graphs/{GRAPH_ID}/{today.strftime('%Y%m%d')}"
# response = requests.delete(url=delete_endpoint, headers=headers)
print(response.text)