RahulShaw / LinuxAcademy-DL

Download videos from your LinuxAcademy account for offline viewing
MIT License
65 stars 44 forks source link

downloading not working, error Unsupported URL #40

Closed arm82 closed 3 years ago

arm82 commented 4 years ago

This is log

Executing for https://linuxacademy.com/cp/modules/view/id/314

ERROR: Unsupported URL: https://linuxacademy.com/cp/ssologin

Babadook007 commented 4 years ago

Has to be issues with cookies.txt .. Use prescribed plugin by Developer..

RahulShaw commented 3 years ago

I agree with @Babadook007, please update the cookies.txt file using this extension https://bit.ly/GoogleChrome-GetCookiesTxt and follow the instructions laid out here - https://github.com/RahulShaw/LinuxAcademy-DL#usage

Babadook007 commented 3 years ago

@RahulShaw I made a minor edit in my copy of driver.py - of - Taking try catch block inside for loop.. (with continue loop on exception) It helped me to download rest videos even if some video in middle failed... eg - I was getting error at 63rd video of total 80 videos. - Downloading: Managed Identity ... ERROR: unable to download video data: HTTP Error 400: Bad Request ERROR: unable to download video data: HTTP Error 400: Bad Request Downloading failed. Perhaps, the cookies have expired.

After moving try catch inside for loop.. I'm able to download rest ( 64-80).. earlier on exception it was coming out of program.

something you would consider to do more elegantly maybe in your next release?

adil-arif commented 3 years ago

@Babadook007 I am having the same issue. Can you tell me what changes did you make to the code to get it working?

adil-arif commented 3 years ago

I figured it out. Changed

try:
    for index, url in enumerate(urls, start=0):
        temp_list = [urls[index]]
        serial = str(index + 1)
        print(f'Downloading: {lessons[index]} ... ', end='', flush=True)
        ydl_opts = {
            'cookiefile': 'cookies.txt',
            'force_generic_extractor': True,
            'outtmpl': os.getcwd() + os.path.sep + title + os.path.sep + serial + '. ' + re.sub('[?/:]', '',
                                                                                                lessons[
                                                                                                    index]) + '.%(ext)s',
            'sleep_interval': 10,
            'retries': 10,
            'allsubtitles': True,
            'verbose': False,
            'quiet': True,
            'writesubtitles': True,
            'no_warnings': True
        }
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download(temp_list)
            temp_list.clear()
            print('\033[92m[Done \u2713]\033[0m')

    print('\n\033[92m** Downloads completed! **\033[0m\n')
except Exception as e:
    print(e)
    print('Downloading failed. Perhaps, the cookies have expired.')

to

 for index, url in enumerate(urls, start=0):
    try:
        temp_list = [urls[index]]
        serial = str(index + 1)
        print(f'Downloading: {lessons[index]} ... ', end='', flush=True)
        ydl_opts = {
            'cookiefile': 'cookies.txt',
            'force_generic_extractor': True,
            'outtmpl': os.getcwd() + os.path.sep + title + os.path.sep + serial + '. ' + re.sub('[?/:]', '',
                                                                                                lessons[
                                                                                                    index]) + '.%(ext)s',
            'sleep_interval': 10,
            'retries': 10,
            'allsubtitles': True,
            'verbose': False,
            'quiet': True,
            'writesubtitles': True,
            'no_warnings': True
        }
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download(temp_list)
            temp_list.clear()
            print('\033[92m[Done \u2713]\033[0m')

    except Exception as e:
           print(e)
           print('Downloading failed. Perhaps, the cookies have expired.')

print('\n\033[92m** Downloads completed! **\033[0m\n')