MagisterPy 0.1.2__tar.gz → 0.1.22__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ import json
2
+ from .magister_errors import *
3
+ class JsParser():
4
+ def __init__(self):
5
+ pass
6
+ def get_authcode_from_js(self,js_content:str):
7
+ try:
8
+ line = 1131
9
+ column = 18203
10
+ buffer = 200
11
+ authcode = ""
12
+ js_content = js_content.split("\n")[line][column:column+buffer]
13
+ start_list_index = None
14
+ content_list = [] #stores the 2 lists containing info about the authcode
15
+
16
+ #Find the first and the second list
17
+ for idx, _char in enumerate(js_content):
18
+
19
+ if _char == "[":
20
+ start_list_index = idx
21
+
22
+ if _char == "]" and (not (start_list_index is None)):
23
+
24
+ content_list.append(json.loads(js_content[start_list_index:idx+1]))
25
+
26
+ if len(content_list)>1:
27
+ break
28
+
29
+
30
+ convert_to_int = lambda a: int(a)
31
+
32
+ random_char_list, index_list = content_list
33
+
34
+ index_list = list(map(convert_to_int,index_list))
35
+
36
+
37
+ for idx in index_list:
38
+ authcode+= str(random_char_list[idx])
39
+
40
+ return authcode
41
+ except KeyboardInterrupt:
42
+ raise KeyboardInterrupt()
43
+ except Exception:
44
+ raise AuthcodeError()
45
+
46
+
47
+
48
+
@@ -19,5 +19,9 @@ class IncorrectCredentials(BaseMagisterError):
19
19
 
20
20
  class ConnectionError(BaseMagisterError):
21
21
  def __init__(self, message="\nCould not connect to Magister. Please check your internet connection"):
22
+ super().__init__(message)
23
+ self.message = message
24
+ class AuthcodeError(BaseMagisterError):
25
+ def __init__(self, message="\nCould not get the authcode from the javascript. This is likely due to magister updating their code structure, please update the package or create an issue if it the latest version"):
22
26
  super().__init__(message)
23
27
  self.message = message
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: MagisterPy
3
- Version: 0.1.2
3
+ Version: 0.1.22
4
4
  Summary: A Python package for retrieving information from magister
5
5
  Home-page: https://github.com/H3LL0U/MagisterPy
6
6
  Author: H3LL0U
@@ -17,6 +17,14 @@ Requires-Dist: idna==3.10
17
17
  Requires-Dist: requests==2.32.3
18
18
  Requires-Dist: soupsieve==2.6
19
19
  Requires-Dist: urllib3==2.2.3
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
20
28
 
21
29
  # MagisterPY
22
30
 
@@ -31,6 +39,10 @@ For more details, please refer to Magister's Terms of Service. (https://magister
31
39
  ```
32
40
  pip install git+https://github.com/H3LL0U/MagisterPy.git
33
41
  ```
42
+ or
43
+ ```
44
+ pip install MagisterPy
45
+ ```
34
46
 
35
47
  ## Contributing
36
48
  Feel free to create an issue if something doesn't work. It's only been tested on a singular school so far so it is to be expected. If you want to help add a feature it would be great as well! :D
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: MagisterPy
3
- Version: 0.1.2
3
+ Version: 0.1.22
4
4
  Summary: A Python package for retrieving information from magister
5
5
  Home-page: https://github.com/H3LL0U/MagisterPy
6
6
  Author: H3LL0U
@@ -17,6 +17,14 @@ Requires-Dist: idna==3.10
17
17
  Requires-Dist: requests==2.32.3
18
18
  Requires-Dist: soupsieve==2.6
19
19
  Requires-Dist: urllib3==2.2.3
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
20
28
 
21
29
  # MagisterPY
22
30
 
@@ -31,6 +39,10 @@ For more details, please refer to Magister's Terms of Service. (https://magister
31
39
  ```
32
40
  pip install git+https://github.com/H3LL0U/MagisterPy.git
33
41
  ```
42
+ or
43
+ ```
44
+ pip install MagisterPy
45
+ ```
34
46
 
35
47
  ## Contributing
36
48
  Feel free to create an issue if something doesn't work. It's only been tested on a singular school so far so it is to be expected. If you want to help add a feature it would be great as well! :D
@@ -11,6 +11,10 @@ For more details, please refer to Magister's Terms of Service. (https://magister
11
11
  ```
12
12
  pip install git+https://github.com/H3LL0U/MagisterPy.git
13
13
  ```
14
+ or
15
+ ```
16
+ pip install MagisterPy
17
+ ```
14
18
 
15
19
  ## Contributing
16
20
  Feel free to create an issue if something doesn't work. It's only been tested on a singular school so far so it is to be expected. If you want to help add a feature it would be great as well! :D
@@ -7,7 +7,7 @@ def parse_requirements(filename):
7
7
 
8
8
  setup(
9
9
  name="MagisterPy",
10
- version="0.1.2",
10
+ version="0.1.22",
11
11
  description="A Python package for retrieving information from magister",
12
12
  long_description=open("./README.MD").read(),
13
13
  long_description_content_type="text/markdown",
@@ -15,14 +15,10 @@ class TestJsParser(unittest.TestCase):
15
15
  self.parser = JsParser()
16
16
 
17
17
  def test_valid_authcode_extraction(self):
18
- with open(r"tests\test_javascripts\account-85bb24d85718eb247b7c.js") as file:
18
+ with open(r"tests\test_javascripts\account-56c22c13622e321fb1f1.js") as file:
19
19
  content = file.read()
20
- self.assertEqual(self.parser.get_authcode_from_js(content),"1ca5d248")
20
+ self.assertEqual(self.parser.get_authcode_from_js(content),"6380e45e80d5bb")
21
21
 
22
-
23
- with open(r"tests\test_javascripts\account-e6fb87fd4f567cbd37f5.js") as file:
24
- content = file.read()
25
- self.assertEqual(self.parser.get_authcode_from_js(content),"b7cf076f")
26
22
 
27
23
 
28
24
  if __name__ == "__main__":
@@ -1,43 +0,0 @@
1
- import json
2
-
3
- class JsParser():
4
- def __init__(self):
5
- pass
6
- def get_authcode_from_js(self,js_content:str):
7
- line = 1192
8
- column = 15476
9
- buffer = 200
10
- authcode = ""
11
- js_content = js_content.split("\n")[line][column:column+buffer]
12
- start_list_index = None
13
- content_list = [] #stores the 2 lists containing info about the authcode
14
-
15
- #Find the first and the second list
16
- for idx, _char in enumerate(js_content):
17
-
18
- if _char == "[":
19
- start_list_index = idx
20
-
21
- if _char == "]" and (not (start_list_index is None)):
22
-
23
- content_list.append(json.loads(js_content[start_list_index:idx+1]))
24
-
25
- if len(content_list)>1:
26
- break
27
-
28
- if len(content_list) == 2:
29
- convert_to_int = lambda a: int(a)
30
-
31
- random_char_list, index_list = content_list
32
-
33
- index_list = list(map(convert_to_int,index_list))
34
-
35
-
36
- for idx in index_list:
37
- authcode+= random_char_list[idx]
38
- if len(authcode) == 8:
39
- return authcode
40
- return None
41
-
42
-
43
-
File without changes
File without changes
File without changes
File without changes