Puyodead1 / udemy-downloader

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

[Bug]: 'NoneType' object has no attribute 'group' #227

Closed jaan143 closed 3 months ago

jaan143 commented 5 months ago

What happened?

while downloading course i am getting this error in reaching specific lecture. i re-run script but still script giving error when reaching on this lecture.

[04:38:09] [udemy-downloader] [parse_new:1788] INFO: > Processing 0 asset(s) for lecture... Traceback (most recent call last): File "D:\data\downloader-master\main.py", line 2068, in if name == "main": ^^^^^^ File "D:\data\downloader-master\main.py", line 2061, in main

File "D:\data\downloader-master\main.py", line 1745, in parse_new index = lecture.get("index") # this is lecture_counter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\data\downloader-master\main.py", line 1006, in _parse_lecture if stream_urls and isinstance(stream_urls, dict): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\data\downloader-master\main.py", line 523, in _extract_sources out = self._extract_m3u8(download_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\data\downloader-master\main.py", line 587, in _extract_m3u8 asset_id = asset_id_re.search(url).group("id") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'group'

D:\data\downloader-master>

Expected Result

it will be great if can fix this issue and i can download this lecture

Branch

master/main

What operating systems are you seeing the problem on?

Windows

Relevant log output

No response

Other information

No response

jaan143 commented 4 months ago

@Puyodead1

something is wrong with only some courses which are giving this type of error

[06:14:03] [udemy-downloader] [_get:1115] ERROR: 403 Forbidden, retrying (attempt 8 )... [06:14:08] [udemy-downloader] [_get:1114] ERROR: Failed request https://www.udemy.com/course/dumisnetwork-javascript-basico/learn/ [06:14:08] [udemy-downloader] [_get:1115] ERROR: 403 Forbidden, retrying (attempt 9 )... Traceback (most recent call last): File "M:\data\downloader-master\main.py", line 2072, in main() File "M:\data\downloader-master\main.py", line 1942, in main course_id, course_info = udemy._extract_course_info(course_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\data\downloader-master\main.py", line 956, in _extract_course_info course_id = self._extract_subscription_course_info(url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\data\downloader-master\main.py", line 925, in _extract_subscription_course_info course_html = self.session._get(url).text ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'text'

Puyodead1 commented 4 months ago

@Puyodead1

something is wrong with only some courses which are giving this type of error

[06:14:03] [udemy-downloader] [_get:1115] ERROR: 403 Forbidden, retrying (attempt 8 )... [06:14:08] [udemy-downloader] [_get:1114] ERROR: Failed request https://www.udemy.com/course/dumisnetwork-javascript-basico/learn/ [06:14:08] [udemy-downloader] [_get:1115] ERROR: 403 Forbidden, retrying (attempt 9 )... Traceback (most recent call last): File "M:\data\downloader-master\main.py", line 2072, in main() File "M:\data\downloader-master\main.py", line 1942, in main course_id, course_info = udemy._extract_course_info(course_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\data\downloader-master\main.py", line 956, in _extract_course_info course_id = self._extract_subscription_course_info(url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\data\downloader-master\main.py", line 925, in _extract_subscription_course_info course_html = self.session._get(url).text ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'text'

use the feat/refactor branch

jaan143 commented 4 months ago

@Puyodead1 same text error in this branch also. may be you think it is because other language issue but some english courses also giving the same error.

swahpy commented 4 months ago

hi, I have the same issue and it worked after switch to feat/refactor branch.

jaan143 commented 4 months ago

@swahpy can you give me link of feat/refactor branch ? evan i am getting error in this branch also and personal plan also geting text error in feat/refactor branch evan i am using browser command

Puyodead1 commented 4 months ago

@swahpy can you give me link of feat/refactor branch ? evan i am getting error in this branch also and personal plan also geting text error in feat/refactor branch evan i am using browser command

It doesn't exist anymore. Use master

jaan143 commented 4 months ago

@Puyodead1 master branch is still not supporting personal pro plan account i am trying but getting 'Text' error. if you want i can show you full log file

Puyodead1 commented 4 months ago

@Puyodead1 master branch is still not supporting personal pro plan account i am trying but getting 'Text' error. if you want i can show you full log file

Yes it does, I can confirm that because I am using a trial account right now. You might not be using the latest version. Make sure you have the /learn part in the url

jaan143 commented 4 months ago

@Puyodead1 i am using url in this format https://www.udemy.com/course/my-master-system/learn/

yes i am using latest version of master branch and one more thing this new updated script is not removing enc files after dec.

jaan143 commented 4 months ago

@Puyodead1 please check this. this is with your latest script

M:\udemy-downloader-master_3>python main.py -c https://www.udemy.com/course/excel-for-analysts/learn -o M:\Tut --download-assets [06:09:56] [udemy-downloader] [pre_run:332] INFO: Output directory set to M:\Tut [06:09:57] [udemy-downloader] [main:1839] INFO: > Fetching course information, this may take a minute... [06:10:04] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:04] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 0 )... [06:10:06] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:06] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 1 )... [06:10:09] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:09] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 2 )... [06:10:11] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:11] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 3 )... [06:10:14] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:14] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 4 )... [06:10:17] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:17] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 5 )... [06:10:19] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:19] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 6 )... [06:10:22] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:22] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 7 )... [06:10:25] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:25] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 8 )... [06:10:27] [udemy-downloader] [_get:1118] ERROR: Failed request https://www.udemy.com/course/excel-for-analysts/learn [06:10:27] [udemy-downloader] [_get:1119] ERROR: 403 Forbidden, retrying (attempt 9 )... Traceback (most recent call last): File "M:\udemy-downloader-master_3\main.py", line 2016, in main() File "M:\udemy-downloader-master_3\main.py", line 1841, in main course_id, course_info = udemy._extract_course_info(course_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\udemy-downloader-master_3\main.py", line 960, in _extract_course_info course_id = self._extract_subscription_course_info(url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\udemy-downloader-master_3\main.py", line 927, in _extract_subscription_course_info course_html = self.session._get(url).text ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'text'

M:\udemy-downloader-master_3>

Puyodead1 commented 4 months ago

You're not using -sc or specifying a browser to extract cookies from

jaan143 commented 4 months ago

@Puyodead1 same error when i am using this command python main.py -c https://www.udemy.com/course/excel-for-analysts/learn/ -o M:\Tut -sc --download-assets

same error i am getting when using this command python main.py -c https://www.udemy.com/course/excel-for-analysts/learn/ -o M:\Tut -sc --download-assets --browser chrome

evan my bearer token is correct and working and i added it also in .env file but getting same above error

Puyodead1 commented 4 months ago

@Puyodead1 same error when i am using this command python main.py -c https://www.udemy.com/course/excel-for-analysts/learn/ -o M:\Tut -sc --download-assets

same error i am getting when using this command python main.py -c https://www.udemy.com/course/excel-for-analysts/learn/ -o M:\Tut -sc --download-assets --browser chrome

evan my bearer token is correct and working and i added it also in .env file but getting same above error

Bearer tokens will not work for subscription courses. Are you logged in to udemy in Chrome? Make sure you also close chrome before running the command

jaan143 commented 4 months ago

@Puyodead1 yes i am logged in to udemy in chrome i did not close chrome window before running the command.

let me try with 2 more things then i will confirm you its working or not.

swahpy commented 4 months ago

@swahpy can you give me link of feat/refactor branch ? evan i am getting error in this branch also and personal plan also geting text error in feat/refactor branch evan i am using browser command

hi, apologize for late reply. Just as Puyodead1 mentioned, feat/refactor was merged into main branch. So you can use main instead from now on.

swahpy commented 4 months ago

@Puyodead1 yes i am logged in to udemy in chrome i did not close chrome window before running the command.

let me try with 2 more things then i will confirm you its working or not.

hi jaan143, can you help to confirm if it works or not? Thank you.

jaan143 commented 3 months ago

@swahpy it is not working for me sadly :( i tried many time evan i am using --browser file also i export cookies.txt file in script directory and then i use command with this python main.py https://www.udemy.com/course/learn-real-world-ux/learn/ -o M:\Tut -sc --download-assets --browser file

but this is also giving me same error. I don't know @Puyodead1 how he is using this with subscription account @Puyodead1 if you are available then i can show you my cookies file and you can try to use it in your side to check where is the problem.

i really want this :(

jaan143 commented 3 months ago

@Puyodead1 i import this cookies.txt file in browser to check is it working fine or not where udemy was not login in that browser and cookies is imported successfully and udemy site loging in. so then i try to use --browser firefox also and --browser file too but both giving me error

File "M:\udemy-downloader-master_3\main.py", line 2016, in main() File "M:\udemy-downloader-master_3\main.py", line 1841, in main course_id, course_info = udemy._extract_course_info(course_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\udemy-downloader-master_3\main.py", line 960, in _extract_course_info course_id = self._extract_subscription_course_info(url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\udemy-downloader-master_3\main.py", line 927, in _extract_subscription_course_info course_html = self.session._get(url).text ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'text'

Puyodead1 commented 3 months ago

@swahpy it is not working for me sadly :( i tried many time evan i am using --browser file also i export cookies.txt file in script directory and then i use command with this python main.py https://www.udemy.com/course/learn-real-world-ux/learn/ -o M:\Tut -sc --download-assets --browser file

but this is also giving me same error. I don't know @Puyodead1 how he is using this with subscription account @Puyodead1 if you are available then i can show you my cookies file and you can try to use it in your side to check where is the problem.

i really want this :(

eeeeee, i suppose i can try, either email me cookies or login credentials. mailto:puyodead@proton.me

jaan143 commented 3 months ago

@Puyodead1 please check your email i sent and attached cookies.txt file

Puyodead1 commented 3 months ago

@Puyodead1 please check your email i sent and attached cookies.txt file

works perfectly fine for me python main.py -c "https://www.udemy.com/course/learn-real-world-ux/learn/"-sc --download-assets --browser file WindowsTerminal_DNDCJHNOGO

jaan143 commented 3 months ago

@Puyodead1 can you please reply that email with your this project ? or just main.py file i am evan using latest project which you updated 2 weeks ago but i don’t know why i am getting this error. so i want to use project which you run now to check this cookies

Puyodead1 commented 3 months ago

@Puyodead1 can you please reply that email with your this project ? or just main.py file i am evan using latest project which you updated 2 weeks ago but i don’t know why i am getting this error. so i want to use project which you run now to check this cookies

I am using the latest version, commit 745ea117de12eb0dd48253ba96652c2e196da7f4 from 3 weeks ago

jaan143 commented 3 months ago

@Puyodead1 as i told you before i am also using same project which you updated 2 weeks ago i think. but i am using portable python not installed python so may be this can be the reason or i am using other account with access token also in same project to download some enrolled courses and may be project is reading env file also with cookies file or may be python cache issue and i need to delete cache if have

On Sat, 10 Aug 2024 at 1:28 am, Puyodead1 @.***> wrote:

@Puyodead1 https://github.com/Puyodead1 can you please reply that email with your this project ? or just main.py file i am evan using latest project which you updated 2 weeks ago but i don’t know why i am getting this error. so i want to use project which you run now to check this cookies

I am using the latest version, commit 745ea11 https://github.com/Puyodead1/udemy-downloader/commit/745ea117de12eb0dd48253ba96652c2e196da7f4 from 3 weeks ago

— Reply to this email directly, view it on GitHub https://github.com/Puyodead1/udemy-downloader/issues/227#issuecomment-2278699792, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSRPSLHDHE7CXKWBNRQV7DZQUQ5BAVCNFSM6AAAAABKBXMMNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYGY4TSNZZGI . You are receiving this because you authored the thread.Message ID: @.***>

swahpy commented 3 months ago

@Puyodead1 as i told you before i am also using same project which you updated 2 weeks ago i think. but i am using portable python not installed python so may be this can be the reason or i am using other account with access token also in same project to download some enrolled courses and may be project is reading env file also with cookies file or may be python cache issue and i need to delete cache if have On Sat, 10 Aug 2024 at 1:28 am, Puyodead1 @.> wrote: @Puyodead1 https://github.com/Puyodead1 can you please reply that email with your this project ? or just main.py file i am evan using latest project which you updated 2 weeks ago but i don’t know why i am getting this error. so i want to use project which you run now to check this cookies I am using the latest version, commit 745ea11 <745ea11> from 3 weeks ago — Reply to this email directly, view it on GitHub <#227 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSRPSLHDHE7CXKWBNRQV7DZQUQ5BAVCNFSM6AAAAABKBXMMNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYGY4TSNZZGI . You are receiving this because you authored the thread.Message ID: @.>

you could debug the program to see what the exact error is and so try to fix it. pdb will provide much detailed information.

Puyodead1 commented 3 months ago

@Puyodead1 as i told you before i am also using same project which you updated 2 weeks ago i think. but i am using portable python not installed python so may be this can be the reason or i am using other account with access token also in same project to download some enrolled courses and may be project is reading env file also with cookies file or may be python cache issue and i need to delete cache if have On Sat, 10 Aug 2024 at 1:28 am, Puyodead1 @.**> wrote: @Puyodead1 https://github.com/Puyodead1 can you please reply that email with your this project ? or just main.py file i am evan using latest project which you updated 2 weeks ago but i don’t know why i am getting this error. so i want to use project which you run now to check this cookies I am using the latest version, commit 745ea11 <745ea11> from 3 weeks ago — Reply to this email directly, view it on GitHub <#227 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSRPSLHDHE7CXKWBNRQV7DZQUQ5BAVCNFSM6AAAAABKBXMMNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYGY4TSNZZGI . You are receiving this because you authored the thread.Message ID: @.**>

you could debug the program to see what the exact error is and so try to fix it. pdb will provide much detailed information.

its a python script, there is no pdb

jaan143 commented 3 months ago

@Puyodead1 i was right there was project cache issue and i deleted pycache folder and i remove bearer token of other account from env file and then i run project and it is working fine now. thank you so much for the help :)

jaan143 commented 3 months ago

@Puyodead1 Dear please can you help me about this error ? i am getting this in subscription course

[12:36:44] [udemy-downloader] [parse_new:1708] ERROR: > Error downloading asset Traceback (most recent call last): File "M:\udemy-downloader-master_4\main.py", line 1705, in parse_new ret_code = download_aria(download_url, chapter_dir, filename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "M:\udemy-downloader-master_4\main.py", line 1403, in download_aria process = subprocess.Popen(args) ^^^^^^^^^^^^^^^^^^^^^^ File "M:\WPy64-31230\python-3.12.3.amd64\Lib\subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "M:\WPy64-31230\python-3.12.3.amd64\Lib\subprocess.py", line 1538, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified