ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.9k stars 10k forks source link

oreilly.com video can not start first item video at Playlist #27136

Open vikiaiteam opened 3 years ago

vikiaiteam commented 3 years ago

Checklist

Verbose log

C:\Oreilly_Video\720P>youtube-dl -u xxx  -p xxx https://learning.oreilly.com/videos/cisco-ccna-200-301/9781789130089/
[safari:course] 9781789130089: Downloading course JSON
[download] Downloading playlist: Cisco CCNA 200-301: The Complete Guide to Getting Certified
[safari:course] playlist Cisco CCNA 200-301: The Complete Guide to Getting Certified: Collected 275 video ids (downloading 275 of them)
[download] Downloading video 1 of 275
[safari:api] 9781789130089/video28_3: Downloading part JSON
[safari] 9781789130089-video28_3: Downloading webpage
[Kaltura] 9781789130089-video28_3: Downloading webpage
[Kaltura] 0_om8prfbf: Downloading video info JSON
[Kaltura] 0_om8prfbf: Checking mp4-592 URL
[Kaltura] 0_om8prfbf: Downloading m3u8 information
[download] Destination: Standard, Extended and Named ACLs-0_om8prfbf.mp4
[download]   9.0% of 5.51MiB at 305.64KiB/s ETA 00:16

Description

WRITE DESCRIPTION HERE

october262 commented 3 years ago

youtube-dl --playlist-items 1,2,3 https://learning.oreilly.com/videos/cisco-ccna-200-301/9781789130089/

nahidx commented 3 years ago

Same here. Downloading playlist doesn't obey the original sequence, %(playlist_index) is also randomized. Which means --playlist-start doesn't work anymore on learning.oreilly.com.

nahidx commented 3 years ago

Adding course_json['chapters'] = sorted(course_json['chapters']) or course_json['chapters'].sort() right before line 254 fixes the issue for me.

https://github.com/ytdl-org/youtube-dl/blob/3cb1a5dc73f934f1810852d12971f99ab32f6c96/youtube_dl/extractor/safari.py#L247-L264

def _real_extract(self, url): 
    course_id = self._match_id(url) 

    course_json = self._download_json( 
        '%s/book/%s/?override_format=%s' % (self._API_BASE, course_id, self._API_FORMAT), 
        course_id, 'Downloading course JSON') 

    if 'chapters' not in course_json: 
        raise ExtractorError( 
            'No chapters found for course %s' % course_id, expected=True) 

    course_json['chapters'].sort()

    entries = [ 
        self.url_result(chapter, SafariApiIE.ie_key()) 
        for chapter in course_json['chapters']] 

    course_title = course_json['title'] 

    return self.playlist_result(entries, course_id, course_title)