r0oth3x49 / udemy-dl

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

max() arg is an empty sequence #3

Closed aztazt closed 7 years ago

aztazt commented 7 years ago

Hello,

I have an issue with this command : python udemy-dl.py -u specialspam@gmail.com -p myPa$$w0rdisKewl https://www.udemy.com/learn-microsoft-excel-formulas-and-functions-with-examples/

(coupon code = BLOG_FREE)

The script downloads the first 2 videos then crash with the following output :

[*] : Lecture : '002 Course-Resources-Formulas.zip' (already downloaded). Traceback (most recent call last): File "udemy-dl.py", line 475, in <module> main() File "udemy-dl.py", line 406, in main udemy.ExtractAndDownload() File "udemy-dl.py", line 295, in ExtractAndDownload _url = max(urls, key=urls.get) ValueError: max() arg is an empty sequence

Any idea ? Thanks in advance

EDIT

It seems like it's because chapter 3 is empty (no video and no file), then videos_dict[chap].items() contains this :

` [ ('001 0101 Welcome to the course!', {'https://udemy-assets-on-demand2.udemy.com/2015-12-10_11-36-03-d9cad445afd01bd3ed6237b0b39d8f12/WebHD_720p.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '720', 'https://udemy-assets-on-demand.udemy.com/2015-12-10_11-36-03-d9cad445afd01bd3ed6237b0b39d8f12/WebHD_480.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '480', 'https://udemy-assets-on-demand2.udemy.com/2015-12-10_11-36-03-d9cad445afd01bd3ed6237b0b39d8f12/WebHD.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '360'}),

('002 Course-Resources-Formulas.zip', {'label': 'download', 'file': 'https://udemy-assets-on-demand.udemy.com/2015-12-12_15-08-15-30bcf7d2876a1ce6ccafeebb5479d8d7/2ea281a9-32a9-4957-b11e-530de969fed0.zip?nva=20170706163040&download=True&filename=Course-Resources-Formulas.zip&token=xxxxxxxxxxxxxxxxxxxx'}), ('002 Download Working Files, Ongoing Support & How to Instantly Contact Me', {}),

('004 0102 How to Best View This Course', {'https://udemy-assets-on-demand2.udemy.com/2015-12-10_12-58-55-e2549cd030adb9ee755f3670fa46a39a/WebHD_720p.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '720', 'https://udemy-assets-on-demand2.udemy.com/2015-12-10_12-58-55-e2549cd030adb9ee755f3670fa46a39a/WebHD_480.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '480', 'https://udemy-assets-on-demand2.udemy.com/2015-12-10_12-58-55-e2549cd030adb9ee755f3670fa46a39a/WebHD.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '360'}),

('005 0103 How to Review this Course and Obtain Your Certificate of Completion', {'https://udemy-assets-on-demand2.udemy.com/2015-12-10_13-00-31-daad5e22acbe759fdf88b123d5b2bd55/WebHD_720p.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '720', 'https://udemy-assets-on-demand.udemy.com/2015-12-10_13-00-31-daad5e22acbe759fdf88b123d5b2bd55/WebHD_480.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '480', 'https://udemy-assets-on-demand2.udemy.com/2015-12-10_13-00-31-daad5e22acbe759fdf88b123d5b2bd55/WebHD.mp4?nva=20170706163040&token=xxxxxxxxxxxxxxxxxxxx': '360'})

]`

I think the code could be improved to handle that.

r0oth3x49 commented 7 years ago

@aztazt thanks. Improved code quality to handle the error. let me know if you still face the same problem.