minor article template changes

This commit is contained in:
Puyodead1 2024-08-29 00:37:51 -04:00
parent 2d6a3020aa
commit 3e79463330
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC
2 changed files with 18 additions and 13 deletions

14
main.py
View File

@ -481,12 +481,14 @@ class Udemy:
return _temp return _temp
def _extract_article(self, asset, id): def _extract_article(self, asset, id):
return [{ return [
{
"type": "article", "type": "article",
"body": asset.get("body"), "body": asset.get("body"),
"extension": "html", "extension": "html",
"id": id, "id": id,
}] }
]
def _extract_ppt(self, asset, lecture_counter): def _extract_ppt(self, asset, lecture_counter):
_temp = [] _temp = []
@ -1114,7 +1116,7 @@ class Session(object):
self._headers["Authorization"] = "Bearer {}".format(bearer_token) self._headers["Authorization"] = "Bearer {}".format(bearer_token)
self._headers["X-Udemy-Authorization"] = "Bearer {}".format(bearer_token) self._headers["X-Udemy-Authorization"] = "Bearer {}".format(bearer_token)
def _get(self, url, params = None): def _get(self, url, params=None):
for i in range(10): for i in range(10):
session = self._session.get(url, headers=self._headers, cookies=cj, params=params) session = self._session.get(url, headers=self._headers, cookies=cj, params=params)
if session.ok or session.status_code in [502, 503]: if session.ok or session.status_code in [502, 503]:
@ -1679,12 +1681,12 @@ def parse_new(udemy: Udemy, udemy_object: dict):
if asset_type == "article": if asset_type == "article":
body = asset.get("body") body = asset.get("body")
lecture_path = os.path.join( # stip the 03d prefix
chapter_dir, "{}.html".format(sanitize_filename(lecture_title))) lecture_path = os.path.join(chapter_dir, "{}.html".format(sanitize_filename(lecture_title)))
try: try:
with open("./templates/article_template.html", "r") as f: with open("./templates/article_template.html", "r") as f:
content = f.read() content = f.read()
content = content.replace("__title_placeholder__", lecture_title) content = content.replace("__title_placeholder__", lecture_title[4:])
content = content.replace("__data_placeholder__", body) content = content.replace("__data_placeholder__", body)
with open(lecture_path, encoding="utf8", mode="w") as f: with open(lecture_path, encoding="utf8", mode="w") as f:
f.write(content) f.write(content)

View File

@ -30,23 +30,26 @@
margin: 0 auto; margin: 0 auto;
} }
.heading { .heading {
margin-bottom: 2.4rem; margin-bottom: 24px;
font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Helvetica, Arial, sans-serif, font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Helvetica, Arial, sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-weight: 700; font-weight: 700;
line-height: 1.2; line-height: 1.2;
letter-spacing: 0; letter-spacing: 0;
font-size: 3.2rem; font-size: 32px;
max-width: 36em; max-width: 36em;
} }
.article-asset-container { .article-asset-container {
padding: 2.4rem; padding: 2.4rem;
} }
.article-asset-container p {
font-size: 19px;
}
code { code {
background-color: #fff; background-color: #fff;
border: 1px solid #d1d7dc; border: 1px solid #d1d7dc;
color: #b4690e; color: #b4690e;
font-size: 90%; font-size: 80%;
padding: 0.2rem 0.4rem; padding: 0.2rem 0.4rem;
font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace; font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace;
} }