Skip to content

Commit

Permalink
chore: Improve error handling, fix CV, and add last updated filter
Browse files Browse the repository at this point in the history
  • Loading branch information
techtanic committed Sep 2, 2024
1 parent 4f51abe commit 2bd08fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 7 additions & 8 deletions base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,11 @@ def idc(self):
for index, item in enumerate(all_items):
self.idc_progress = index
title = item.h2.string
link_num=item['href'].split('/')[4]
if link_num=="85":
link_num = item["href"].split("/")[4]
if link_num == "85":
continue
link = (
f"https://idownloadcoupon.com/udemy/{link_num}/"
)

link = f"https://idownloadcoupon.com/udemy/{link_num}/"

r = requests.get(
link,
allow_redirects=False,
Expand Down Expand Up @@ -793,8 +791,9 @@ def check_course(self, course_id, coupon_code=None):
url += f",redeem_coupon&couponCode={coupon_code}"

r = self.client.get(url).json()
with open("test/check_course.json", "w") as f:
json.dump(r, f, indent=4)
if self.debug:
with open("test/check_course.json", "w") as f:
json.dump(r, f, indent=4)
amount = (
r.get("purchase", {})
.get("data", {})
Expand Down
10 changes: 8 additions & 2 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ def scrape():
courses_last_updated_lo = [
[
sg.Text("Past"),
sg.Spin([i for i in range(1, 48)], initial_value=udemy.settings["course_update_threshold_months"], key="course_update_threshold_months"),
sg.Spin(
[i for i in range(1, 48)],
initial_value=udemy.settings["course_update_threshold_months"],
key="course_update_threshold_months",
),
sg.Text("Month(s)"),
]
]
Expand Down Expand Up @@ -637,7 +641,9 @@ def scrape():
filter(None, values["title_exclude"].split("\n"))
)
udemy.settings["min_rating"] = float(values["min_rating"])
udemy.settings["course_update_threshold_months"] = int(values["course_update_threshold_months"])
udemy.settings["course_update_threshold_months"] = int(
values["course_update_threshold_months"]
)
udemy.settings["save_txt"] = values["save_txt"]
udemy.settings["discounted_only"] = values["discounted_only"]
udemy.save_settings()
Expand Down

0 comments on commit 2bd08fa

Please sign in to comment.