PhanTinhKhang / Skillshare-69DL

Working method to download skillshare courses (Updated 2023)
1 stars 3 forks source link

IndexError: list index out of range #1

Open Digi-Ralph opened 1 year ago

Digi-Ralph commented 1 year ago

doesn't download certain courses or it doesn't download the full list ..

Traceback (most recent call last): File "/root/.Skillshare-DL/dl.py", line 16, in main() File "/root/.Skillshare-DL/dl.py", line 11, in main dl.download_course_by_url(course_url) File "/root/.Skillshare-DL/skillshare.py", line 32, in download_course_by_url self.download_course_by_class_id(m.group(1)) File "/root/.Skillshare-DL/skillshare.py", line 88, in download_course_by_class_id video_id=video_id, File "/root/.Skillshare-DL/skillshare.py", line 147, in download_video if meta_res.json()['sources'][6]['container'] == 'MP4' and 'src' in meta_res.json()['sources'][6]: IndexError: list index out of range

Digi-Ralph commented 1 year ago

https://i.imgur.com/svpy0D0.png

basically index [6] in the sources array doesn't exist o it fails how to fix this ? i'm not python scripter but at leat how to make it skip the video and move on

costis-t commented 1 year ago

I created https://github.com/PhanTinhKhang/Skillshare-69DL/pull/2 which fixes my IndexError. If you still encounter it, give me a course id to check it.

In skillshare.py change

    if meta_res.json()['sources'][6]['container'] == 'MP4' and 'src' in meta_res.json()['sources'][6]:
           dl_url = meta_res.json()['sources'][6]['src']
           # break
    else:

to

    try:
        if meta_res.json()['sources'][6]['container'] == 'MP4' and 'src' in meta_res.json()['sources'][6]:
            dl_url = meta_res.json()['sources'][6]['src']
            # break
        else:
            dl_url = meta_res.json()['sources'][1]['src']
    except IndexError:
        dl_url = meta_res.json()['sources'][1]['src']

Mind the spaces, I did it on my phone. Each indentation should be 4 spaces. Something is wrong with my font/screen right now. whoops....