-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]: Integrazione del download delle videolezioni presenti nel vecchio portale elearning #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
import httpx | ||
import bs4 | ||
|
||
from .datatypes import Material, Videostore | ||
from .datatypes import Material, Videostore, Videostore_old | ||
from . import session, urls | ||
|
||
async def get_material(year: int) -> dict[str, Material]: | ||
|
@@ -53,7 +53,7 @@ async def get_videostores(year: int) -> dict[str, Videostore]: | |
page = bs4.BeautifulSoup(response.content, "html.parser") | ||
videostores = {} | ||
|
||
data_regex = re.compile(r"sviluppo\.videolezioni\.vis\?cor=(\d+)") | ||
data_regex = re.compile(r"(sviluppo\.videolezioni\.vis\?cor=(\d+))|(javascript:void\(null\);)") | ||
raw_videostores = page.find_all("a", {"onclick": re.compile(r"showDivVideoteca\('\w+'\)")}) | ||
videolessons_group = page.find_all("div", {"class": "policorpo"}) | ||
for videostore, raw_videolessons in zip(raw_videostores, videolessons_group): | ||
|
@@ -70,9 +70,26 @@ async def get_videostores(year: int) -> dict[str, Videostore]: | |
continue | ||
|
||
videolesson_name = videolesson.text.strip() | ||
cor, = data_regex.search(videolesson["href"]).groups() | ||
videolessons[videolesson_name] = \ | ||
if data_regex.match(videolesson["href"]).group(1): | ||
cor = data_regex.search(videolesson["href"]).group(2) | ||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
videolessons[videolesson_name] = \ | ||
Videostore(year, videostore_name, videolesson_name, cor) | ||
else: | ||
inc_regex = re.compile(r"dokeosLez\(\'(\d+)\'\)") | ||
inc, = inc_regex.match(videolesson["onclick"]).groups() | ||
data = await session.get( | ||
httpx.URL( | ||
urls.did/"pls/portal30/sviluppo.materiale.json_dokeos_par", | ||
params={"inc": inc} | ||
) | ||
) | ||
data.raise_for_status() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Check wether it's safe to raise an error in this part of code, or if it should just return instead. |
||
data_json = data.json() | ||
videolessons[videolesson_name] = \ | ||
Videostore_old(year, videostore_name, videolesson_name, inc, data_json['utente'], data_json['data'], data_json['token'] | ||
) | ||
|
||
|
||
|
||
videostores[videostore_name] = videolessons | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this module isn't used anywhere.