r0oth3x49 / udemy-dl

A cross-platform python based utility to download courses from udemy for personal offline use.
MIT License
4.83k stars 1.19k forks source link

Issue with open file in utf-8 with russian charset #533

Closed karankevich-aleksey closed 3 years ago

karankevich-aleksey commented 3 years ago

Describe the bug Need to fix line 92 in _shared.py some thing like such: file_data = [i.strip().lower() for i in open(filename, encoding='utf-8') if i]

To Reproduce Steps to reproduce the behavior:

  1. udemy course url: https://www.udemy.com/course/ittensive-python-advanced
  2. Run the following command to reproduce the error. python udemy-dl.py https://www.udemy.com/course/ittensive-python-advanced -k cookie.txt
  3. See error Traceback (most recent call last): File "udemy-dl.py", line 1453, in main() File "udemy-dl.py", line 1112, in main udemy.course_download(path=options.output, language=options.language, quality=options.quality, unsafe=options.unsafe) File "udemy-dl.py", line 504, in course_download self.download_lectures_and_captions(lecture_best=lecture_best, lecture_title=lecture_title, inner_index=inner_index, lectures_count=lectures_count, lecture_subtitles=lecture_subtitles, language=language, lecture_assets=lecture_assets, filepath=filepath, unsafe=unsafe) File "udemy-dl.py", line 422, in download_lectures_and_captions self.download_assets(lecture_assets=lecture_assets, filepath=filepath, unsafe=unsafe) File "udemy-dl.py", line 327, in download_assets assets.download(filepath=filepath, unsafe=unsafe, quiet=True, callback=self.show_progress) File "c:\Users\amk\Desktop\udemy-dl-master\udemy_shared.py", line 126, in download return self._write_external_links(filepath, unsafe) File "c:\Users\amk\Desktop\udemy-dl-master\udemy_shared.py", line 92, in _write_external_links file_data = [i.strip() for i in open(filename) if i] File "c:\Users\amk\Desktop\udemy-dl-master\udemy_shared.py", line 92, in file_data = [i.strip() for i in open(filename) if i] File "C:\Users\amk\AppData\Local\Programs\Python\Python38\lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 52: character maps to

Python Environment (please complete the following information):

r0oth3x49 commented 3 years ago

can you attach the file here so that i can reproduce and fix.

YamidDev commented 3 years ago

i have same issue