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

Downloading course aborts due to error "TypeError: 'encoding' is an invalid keyword argument for this function" #541

Closed EnoqueEsteves closed 3 years ago

EnoqueEsteves commented 3 years ago

Describe the bug When downloading some courses the udemy-dl.py utility abandons the download process leaving the downloaded course incomplete.

To Reproduce Steps to reproduce the behavior:

  1. udemy course url: [e.g https://www.udemy.com/machinelearning/] '...'
  2. Run the following command to reproduce the error.
    udemy-dl.py "https://www.udemy.com/course/terraform-fast-track" -k authcookie.txt --skip-sub -q 1080 -o ../downloads/udemy 
  3. See error
    Traceback (most recent call last):
      File "./udemy-dl/udemy-dl.py", line 1453, in <module>
        main()
      File "./udemy-dl/udemy-dl.py", line 1108, in main
        udemy.course_download(skip_captions=options.skip_captions, path=options.output, quality=options.quality, unsafe=options.unsafe)
      File "./udemy-dl/udemy-dl.py", line 490, in course_download
        self.download_lectures_only(lecture_best=lecture_best, lecture_title=lecture_title, inner_index=inner_index, lectures_count=lectures_count, lecture_assets=lecture_assets, filepath=filepath, unsafe=unsafe)
      File "./udemy-dl/udemy-dl.py", line 414, in download_lectures_only
        self.download_assets(lecture_assets=lecture_assets, filepath=filepath, unsafe=unsafe)
      File "./udemy-dl/udemy-dl.py", line 327, in download_assets
        assets.download(filepath=filepath, unsafe=unsafe, quiet=True, callback=self.show_progress)
      File "/mnt/e/utilities/udemy-dl/udemy/_shared.py", line 126, in download
        return self._write_external_links(filepath, unsafe)
      File "/mnt/e/utilities/udemy-dl/udemy/_shared.py", line 92, in _write_external_links
        file_data = [i.strip().lower() for i in open(filename, encoding='utf-8') if i]
    TypeError: 'encoding' is an invalid keyword argument for this function

Expected behavior Expect the application to download the full coarse or the new deltas (changes compared to previously downloaded) successfully

Screenshots If applicable, add screenshots to help explain your problem. image

Python Environment (please complete the following information):

Additional context I believe this might be related to #540

r0oth3x49 commented 3 years ago

@EnoqueEsteves use python3 instead, python2 will be removed completely in next version and the error is specific to python2.

EnoqueEsteves commented 3 years ago

That did indeed resolve the issue - thank you