This is a personal projects that aims to be the perfect online student. It auromatically joins zoom meetings, records classes and mirrors a pre-recorded video to a virtual loopback camera. Keep in mind that this is only meant to work on linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. import requests
  2. from html.parser import HTMLParser
  3. import sys
  4. import json
  5. import re
  6. import datetime
  7. from urllib3.exceptions import InsecureRequestWarning
  8. import selenium
  9. from selenium import webdriver
  10. from selenium.webdriver.common.keys import Keys
  11. requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
  12. now = datetime.datetime.now()
  13. proxies = {"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"}
  14. headers = {
  15. "Host":"portal.tedankara.k12.tr",
  16. "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
  17. "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  18. "Accept-Language":"en-US,en;q=0.5",
  19. "Accept-Encoding":"gzip, deflate",
  20. "Content-Type":"application/x-www-form-urlencoded",
  21. "Origin":"https://portal.tedankara.k12.tr",
  22. "Connection":"close",
  23. "Referer":"https://portal.tedankara.k12.tr/login",
  24. "DNT":"1"
  25. }
  26. class JDParser(HTMLParser):
  27. def handle_starttag(self, tag, attrs):
  28. self.attributes = {}
  29. for attr in attrs:
  30. self.attributes[attr[0]] = attr[1]
  31. def get_meetings(uname, passwd):
  32. url = "https://portal.tedankara.k12.tr/login"
  33. r = requests.get(url,verify=False)
  34. cookies = r.cookies
  35. content = r.content
  36. lines = content.splitlines()
  37. line = list(filter(lambda x: b'_token' in x, lines))[0].decode("utf-8")
  38. parser = JDParser()
  39. parser.feed(line)
  40. parser.feed(line)
  41. parser.close()
  42. _token = parser.attributes["content"]
  43. data = "_token={}&kimlikno={}&sifre={}".format(_token,uname,passwd)
  44. r = requests.post(url,data=data,cookies=cookies,headers=headers,verify=False)
  45. cookies = r.cookies
  46. r = requests.get("https://portal.tedankara.k12.tr/veli/zoom",cookies=cookies,verify=False, headers=headers)
  47. content = r.json()
  48. data = {"current_day": content["current_day"],
  49. "current_class": content["current_class"],
  50. "current_student": content["current_student"]}
  51. headers2 = {"Host":"portal.tedankara.k12.tr",
  52. "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
  53. "Accept":"application/json, text/plain, */*",
  54. "Accept-Language":"en-US,en;q=0.5",
  55. "Accept-Encoding":"gzip, deflate",
  56. "X-Requested-With":"XMLHttpRequest",
  57. "Content-Type":"application/json;charset=utf-8",
  58. "Origin":"https://portal.tedankara.k12.tr",
  59. "Connection":"close",
  60. "Referer":"https://portal.tedankara.k12.tr/",
  61. "DNT":"1"}
  62. headers2["X-XSRF-TOKEN"] = r.cookies["XSRF-TOKEN"]
  63. headers2["X-CSRF-TOKEN"] = _token
  64. r = requests.post("https://portal.tedankara.k12.tr/veli/zoom",cookies=r.cookies,verify=False, json=data, headers=headers2)
  65. classes = r.json()
  66. meetings = []
  67. for i in classes["meetings"]:
  68. data = "_token={}&student={}&id={}".format(_token, content["students"][0],i["meeting_id"])
  69. r = requests.post("https://portal.tedankara.k12.tr/veli/yoklama",allow_redirects=False, cookies=cookies,verify=False, data=data, headers=headers)
  70. data = r.content.decode()
  71. if "Location" not in data:
  72. continue
  73. for j in data.split("\n"):
  74. items = j.split(" ")
  75. if items[0] == "Location:":
  76. invitation = items[-1]
  77. try:
  78. m = re.compile("https:\/\/zoom\.us\/j\/([0-9]*)\?.*pwd=([^#]*)")
  79. g = m.search(invitation)
  80. meeting_url = f"zoommtg://zoom.us/join?confno={g.group(1)}&zc=0&browser=chrome&pwd={g.group(2)}"
  81. http_url = f"https://zoom.us/j/{g.group(1)}?pwd={g.group(2)}"
  82. meetings.append({"meeting_url": meeting_url,
  83. "class": i["topic"],
  84. "time":i["meeting_time"],
  85. "http_url":http_url})
  86. except Exception as e:
  87. print(e)
  88. return meetings