Puyodead1 / udemy-downloader

A Udemy downloader that can download courses, with DRM support.
MIT License
1.26k stars 291 forks source link

[Bug]: FileNotFoundError: [Errno 2] No such file or directory: when processing asset with special character on Windows #217

Closed DavesNotHereDude closed 4 months ago

DavesNotHereDude commented 4 months ago

What happened?

Error Provided:

[01:35:18] [udemy-downloader] [parse_new:1787] INFO: > Processing 1 asset(s) for lecture... Traceback (most recent call last): File "C:\u\main.py", line 2067, in main() File "C:\u\main.py", line 2060, in main parse_new(udemy, udemy_object) File "C:\u\main.py", line 1823, in parse_new file = open(file_path, "w") ^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'C:\u\out_dir\learn-digital-marketing-course\07 - YouTube Marketing\004 Whenever-you-provide-a-link-to-your-channel-add-sub-confirmation-1-to-the-end-of-your-channel-s-URL-and-a-pop-under-will-automatically-appear-on-your-channel-prompting-visitors-to-subscribe..url'


When attempting to process asset:

image

Element:

Whenever you provide a link to your channel, add “?sub_confirmation=1” to the end of your channel’s URL and a pop-under will automatically appear on your channel prompting visitors to subscribe.

Expected Result

I believe the ? within the element is preventing a filename to be created (in Windows), causing the script to fail/end.

Expected Result could be to rewrite special character to supported character, or, report failure and bypass asset to move onto remaining assets.

Branch

master/main

What operating systems are you seeing the problem on?

Windows

Relevant log output

04/20 13:35:18 [NOTICE] Downloading 1 item(s)

04/20 13:35:18 [NOTICE] Download complete: C:/u/out_dir/learn-digital-marketing-course/07 - YouTube Marketing/004 How to Increase YouTube Subscribers by 400%_es.vtt

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
93b819|OK  |   139KiB/s|C:/u/out_dir/learn-digital-marketing-course/07 - YouTube Marketing/004 How to Increase YouTube Subscribers by 400%_es.vtt

Status Legend:
(OK):download completed.
[01:35:18] [udemy-downloader] [process_caption:1564] DEBUG:       > Download return code: 0
[01:35:18] [udemy-downloader] [process_caption:1574] INFO:     > Converting caption to SRT format...
[01:35:18] [udemy-downloader] [process_caption:1576] INFO:     > Caption conversion complete.
[01:35:18] [udemy-downloader] [parse_new:1787] INFO:     > Processing 1 asset(s) for lecture...
Traceback (most recent call last):
  File "C:\u\main.py", line 2067, in <module>
    main()
  File "C:\u\main.py", line 2060, in main
    parse_new(udemy, udemy_object)
  File "C:\u\main.py", line 1823, in parse_new
    file = open(file_path, "w")
           ^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\u\\out_dir\\learn-digital-marketing-course\\07 - YouTube Marketing\\004 Whenever-you-provide-a-link-to-your-channel-add-sub-confirmation-1-to-the-end-of-your-channel-s-URL-and-a-pop-under-will-automatically-appear-on-your-channel-prompting-visitors-to-subscribe..url'

Other information

Puyodead1 For President

Puyodead1 commented 4 months ago

path is too long, use --id-as-course-name

Puyodead1 For President

haha

DavesNotHereDude commented 4 months ago

My bad, that works.