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

When I try to download a course with the command and session cookies, it asks me for an access token #621

Closed estebanardila57 closed 3 years ago

estebanardila57 commented 3 years ago

image

I don't know what happened before, I could copy the session cookies in the cookie file and call them from the command file, and this was enough, now I don't know if there was any change or I'm doing something wrong but it asks me for an access touch I must enter my account and password if I want to download, until recently it did not happen, I do not know if there was any change in undemy what process am I doing wrong

geffchang commented 3 years ago

I get this issue too.

mklie commented 3 years ago

Same here. Tried to debug through PyCharm and block with Access token request is skipped as expected, so I'm not sure where it's from (suspecting, I'm not python ninja yet).

 if not args.username and not args.password and not args.cookies:
        # check if we already have a session..
        configs = load_configs()
        if not configs:
            # if not ask user for user/pass or access token (cookie)
            args.username = getpass.getuser(prompt="Username : ")
            args.password = getpass.getpass(prompt="Password : ")
            if args.username and args.password:
                print("\n")
            if not args.username and not args.password:
                print("")
                args.cookies = getpass.get_access_token(prompt="Access Token : ")
                if args.cookies:
                    print("\n")

Thanks!

estebanardila57 commented 3 years ago

Thank you very much for answering, fortunately you can enter the username and password and download normally, it does not seem the safest thing to do but while this is solved so I am doing it, I think there was a change in the udemy session cookies since this week, unfortunately delete my old session cookies to check if the problem starts here, because I tried idiotically removing my python version and installing an older one like 3.7.2 but it didn't solve it, thanks for giving an idea of what could possibly be happening, but I'm also not a python ninja to go into files and change something, hopefully it's just udemy problem

mklie commented 3 years ago

No worries, I wish I can fix and help all of us. Looks like it's self._login method that doesn't like how access_token provided:

class InternUdemyCourse(UdemyCourse, Udemy):
    def __init__(self, *args, **kwargs):
        self._info = ""
        super(InternUdemyCourse, self).__init__(*args, **kwargs)

    def _fetch_course(self):
        if self._have_basic:
            return
        auth = {}
        if not self._cookies:
            auth = self._login(username=self._username, password=self._password)
        if not auth and self._cookies:
            auth = self._login(acces_token=self._cookies)
r0oth3x49 commented 3 years ago

@estebanardila57 , @mklie thanks for spotting that part but issue was at different place which i have fixed. if still you guys face the issue then reopen this issue again i will investigate.

mklie commented 3 years ago

@r0oth3x49 Thanks a lot, Nasir!

estebanardila57 commented 3 years ago

@ estebanardila57 , @mklie gracias por detectar esa parte, pero el problema estaba en un lugar diferente que he solucionado. Si todavía se enfrentan al problema, vuelva a abrir este problema, lo investigaré. thank you very much, you are the best :)