Skip to content

Commit 6c93de9

Browse files
committed
chore: Update urllib.parse imports and handle URL paths consistently
1 parent 7121a09 commit 6c93de9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

base.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import traceback
77
from datetime import datetime, timezone
88
from decimal import Decimal
9-
from urllib.parse import parse_qs, unquote, urlsplit
9+
from urllib.parse import parse_qs, unquote, urlsplit, urlunparse, urlparse
1010

1111
import cloudscraper
1212
import requests
@@ -210,7 +210,7 @@ def rd(self):
210210
r = requests.get(
211211
"https://www.real.discount/api-web/all-courses/?store=Udemy&page=1&per_page=500&orderby=date&free=1&editorschoices=0",
212212
headers=headers,
213-
timeout=(10,30)
213+
timeout=(10, 30),
214214
).json()
215215
except requests.exceptions.Timeout:
216216
self.rd_error = "Timeout"
@@ -576,6 +576,20 @@ def remove_duplicate_courses(self):
576576
for key in data:
577577
new_data[key] = []
578578
for title, link in data[key]:
579+
parsed_url = urlparse(link)
580+
path = parsed_url.path
581+
if not path.endswith("/"):
582+
path += "/"
583+
link = urlunparse(
584+
(
585+
parsed_url.scheme,
586+
parsed_url.netloc,
587+
path,
588+
parsed_url.params,
589+
parsed_url.query,
590+
parsed_url.fragment,
591+
)
592+
)
579593
if link not in existing_links:
580594
new_data[key].append((title, link))
581595
existing_links.add(link)

0 commit comments

Comments
 (0)