Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
fixed #340, trailing space issue in windows 10 ..
Browse files Browse the repository at this point in the history
  • Loading branch information
r0oth3x49 committed Mar 9, 2019
1 parent 85a5465 commit 2580b0a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions udemy/_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def __init__(self):
def _clean(self, text):
ok = re.compile(r'[^\\/:*?"<>|]')
text = "".join(x if ok.match(x) else "_" for x in text)
return re.sub('\.+$', '', text.rstrip()) if text.endswith(".") else text.rstrip()
text = re.sub(r'\.+$', '', text.strip())
return text

def _course_name(self, url):
# mobj = re.search(r'(?i)(?:(.+)\.com/(?P<course_name>[a-zA-Z0-9_-]+))', url, re.I)
Expand Down Expand Up @@ -525,7 +526,7 @@ def _real_extract(self, url=''):
text = '\r' + fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fg + sb + "Downloading course information .. "
self._spinner(text)
lecture_index = entry.get('object_index')
lecture_title = self._sanitize(entry.get('title'))
lecture_title = self._clean(self._sanitize(entry.get('title')))
lecture = "{0:03d} {1!s}".format(lecture_index, lecture_title)
unsafe_lecture = u'{0:03d} '.format(lecture_index) + entry.get('title')
data, subs = self._html_to_json(view_html, lecture_id)
Expand Down Expand Up @@ -563,7 +564,7 @@ def _real_extract(self, url=''):
text = '\r' + fc + sd + "[" + fm + sb + "*" + fc + sd + "] : " + fg + sb + "Downloading course information .. "
self._spinner(text)
lecture_index = entry.get('object_index')
lecture_title = self._sanitize(entry.get('title'))
lecture_title = self._clean(self._sanitize(entry.get('title')))
lecture = "{0:03d} {1!s}".format(lecture_index, lecture_title)
unsafe_lecture = u'{0:03d} '.format(lecture_index) + self._clean(entry.get('title'))
data = asset.get('stream_urls')
Expand Down

0 comments on commit 2580b0a

Please sign in to comment.