format, fix no id detection
This commit is contained in:
2
login.py
2
login.py
@ -6,7 +6,7 @@
|
|||||||
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
|
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/11/25 16:22:08 by tomoron #+# #+# #
|
# Created: 2024/11/25 16:22:08 by tomoron #+# #+# #
|
||||||
# Updated: 2025/08/11 18:00:29 by tomoron ### ########.fr #
|
# Updated: 2025/10/10 01:56:15 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|||||||
25
scrap.py
25
scrap.py
@ -6,7 +6,7 @@
|
|||||||
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
|
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/11/25 16:39:19 by tomoron #+# #+# #
|
# Created: 2024/11/25 16:39:19 by tomoron #+# #+# #
|
||||||
# Updated: 2025/08/28 23:15:18 by tomoron ### ########.fr #
|
# Updated: 2025/10/10 01:58:11 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -39,34 +39,49 @@ print(pushover_req_data)
|
|||||||
if(len(sys.argv) != 2):
|
if(len(sys.argv) != 2):
|
||||||
print("missing team id, usage :", sys.argv[0], "<subscribe url>")
|
print("missing team id, usage :", sys.argv[0], "<subscribe url>")
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
project_id = sys.argv[1].split('/')[-2]
|
project_id = sys.argv[1].split('/')[-2]
|
||||||
team_id = sys.argv[1].split('?')[-1].split('=')[-1]
|
team_id = sys.argv[1].split('?')[-1].split('=')[-1]
|
||||||
|
|
||||||
print("team id :", team_id, "\nproject_id :", project_id)
|
print("team id :", team_id, "\nproject_id :", project_id)
|
||||||
|
|
||||||
start_search_date = date.today().strftime("%Y-%m-%d")
|
start_search_date = date.today().strftime("%Y-%m-%d")
|
||||||
end_search_date = (date.today() + timedelta(days=3)).strftime("%Y-%m-%d")
|
end_search_date = (date.today() + timedelta(days=3)).strftime("%Y-%m-%d")
|
||||||
|
|
||||||
getUrl = f"https://projects.intra.42.fr/projects/{project_id}/slots.json?start={start_search_date}&end={end_search_date}"
|
getUrl = f"https://projects.intra.42.fr/projects/{project_id}/slots.json?start={start_search_date}&end={end_search_date}"
|
||||||
if (len(team_id)):
|
if ( not "https://" in team_id):
|
||||||
getUrl = f"&team_id={team_id}"
|
getUrl += f"&team_id={team_id}"
|
||||||
|
|
||||||
print(getUrl)
|
print(getUrl)
|
||||||
|
|
||||||
connIntra = Intra42()
|
connIntra = Intra42()
|
||||||
found = set();
|
found = set();
|
||||||
|
|
||||||
while(True):
|
while(True):
|
||||||
try:
|
try:
|
||||||
res = connIntra.get_available_slot(getUrl)
|
res = connIntra.get_available_slot(getUrl)
|
||||||
|
|
||||||
if(type(res) == type({})):
|
if(type(res) == type({})):
|
||||||
print("probably invalid url")
|
print("probably invalid url")
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for x in res:
|
for x in res:
|
||||||
if x["ids"] not in found:
|
if x["ids"] not in found:
|
||||||
start = dateutil.parser.isoparse(x["start"]).strftime("%d/%m at %H:%M")
|
start = dateutil.parser.isoparse(x["start"]).strftime("%d/%m at %H:%M")
|
||||||
end = dateutil.parser.isoparse(x["end"]).strftime("%d/%m at %H:%M")
|
end = dateutil.parser.isoparse(x["end"]).strftime("%d/%m at %H:%M")
|
||||||
text = "slot found starting " + start + " ,ending " + end;
|
|
||||||
|
text = "slot found starting on " + start + " ,ending on " + end;
|
||||||
|
|
||||||
pushover_req_data["message"] = text
|
pushover_req_data["message"] = text
|
||||||
response = requests.post("https://api.pushover.net/1/messages.json", data=pushover_req_data)
|
response = requests.post("https://api.pushover.net/1/messages.json", data=pushover_req_data)
|
||||||
|
|
||||||
print("request sent", response.status_code, response.text)
|
print("request sent", response.status_code, response.text)
|
||||||
print("\a" + text);
|
print("\a" + text);
|
||||||
|
|
||||||
found.add(x["ids"])
|
found.add(x["ids"])
|
||||||
time.sleep(5);
|
time.sleep(5);
|
||||||
except:
|
except Exception as e:
|
||||||
|
time.sleep(1)
|
||||||
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user