[FEATURE] exclude segments from HLS playlists #22925

Open
opened 2026-02-21 12:32:23 -05:00 by deekerman · 2 comments
Owner

Originally created by @mukarator on GitHub (Feb 14, 2021).

Checklist

  • I'm reporting a feature request
  • I've verified that I'm running youtube-dl version 2021.02.10
  • I've searched the bugtracker for similar feature requests including closed ones

Description

I came across several sites I downloaded some videos from, where the first segment in the playlist (m3u8) is advertising, age restriction or copyright warning.

example: https://puhutv.com/cukur-115-bolum-izle or any other video from the site

  1. download the video (lowest quality just for the test):
C:\>youtube-dl -v -c --no-check-certificate -f hls-395-0 https://puhutv.com/cukur-115-bolum-izle
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-c', '--no-check-certificate', '-f', 'hls-395-0', 'https://puhutv.com/cukur-115-bolum-izle']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2021.02.10
[debug] Python version 3.4.4 (CPython) - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 2021-01-09-git-2e2891383e-full_build-www.gyan.dev, ffprobe 2021-01-09-git-2e2891383e-full_build-www.gyan.dev
[debug] Proxy map: {}
[puhutv] cukur-115-bolum: Downloading JSON metadata
[puhutv] cukur-115-bolum: Downloading video JSON
[puhutv] 23958: Downloading m3u8 information
[puhutv] 23958: Downloading m3u8 information
[puhutv] 23958: Downloading m3u8 information
[puhutv] 23958: Downloading m3u8 information
[puhutv] 23958: Downloading m3u8 information
[puhutv] 23958: Downloading m3u8 information
[debug] Invoking downloader on 'http://ck8di1zz.rocketcdn.com/2021/02/09/62319_6cf726d97d248ef73d285d3ab173a872_max_2160p.smil/62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4_chunk.m3u8?r=6'
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1495
[download] Destination: 115. Bölüm 4. Sezon 115. Bölüm-23958.mp4
[download] 100% of 499.26MiB in 11:12
[debug] ffmpeg command line: ffprobe -show_streams "file:115. Bölüm 4. Sezon 115. Bölüm-23958.mp4"
[ffmpeg] Fixing malformed AAC bitstream in "115. Bölüm 4. Sezon 115. Bölüm-23958.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:115. Bölüm 4. Sezon 115. Bölüm-23958.mp4" -c copy -f mp4 "-bsf:a" aac_adtstoasc "file:115. Bölüm 4. Sezon 115. Bölüm-23958.temp.mp4"
  1. copy & paste in the browser the m3u8 link from the ytdl output to download and inspect the playlist :
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:7
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.944,
/rtuk_6_360.ts
#EXT-X-DISCONTINUITY
#EXTINF:6.006,
62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4-n_0_0_0.ts
#EXTINF:6.006,
62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4-n_1_0_0.ts
#EXTINF:6.006,
62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4-n_2_0_0.ts
...
etc.

rtuk_6_360.ts contains the age restriction warning that shows in the beginning of the video, that I want to exclude and download only the main movie. It is even encoded with different parameters than the rest of the video.

My proposal is for option to filter out such unwanted segments from a m3u8 or dash playlist (just like individual videos can be skipped from ordinary playlist with --playlist-start, --playlist-end and --playlist-items options). e.g. something in this manner:

--segment-start, --segment-end, --segment-items

Note my request for this feauture is as general option and not for these specific sites only as I think it will be more flexible if it can be used with the generic extractor as well.

Originally created by @mukarator on GitHub (Feb 14, 2021). <!-- ###################################################################### WARNING! IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE ###################################################################### --> ## Checklist <!-- Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl: - First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2021.02.10. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED. - Search the bugtracker for similar feature requests: http://yt-dl.org/search-issues. DO NOT post duplicates. - Finally, put x into all relevant boxes (like this [x]) --> - [x] I'm reporting a feature request - [x] I've verified that I'm running youtube-dl version **2021.02.10** - [x] I've searched the bugtracker for similar feature requests including closed ones ## Description <!-- Provide an explanation of your issue in an arbitrary form. Please make sure the description is worded well enough to be understood, see https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient. Provide any additional information, suggested solution and as much context and examples as possible. --> I came across several sites I downloaded some videos from, where the first segment in the playlist (m3u8) is advertising, age restriction or copyright warning. example: https://puhutv.com/cukur-115-bolum-izle or any other video from the site 1) download the video (lowest quality just for the test): ``` C:\>youtube-dl -v -c --no-check-certificate -f hls-395-0 https://puhutv.com/cukur-115-bolum-izle [debug] System config: [] [debug] User config: [] [debug] Custom config: [] [debug] Command-line args: ['-v', '-c', '--no-check-certificate', '-f', 'hls-395-0', 'https://puhutv.com/cukur-115-bolum-izle'] [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251 [debug] youtube-dl version 2021.02.10 [debug] Python version 3.4.4 (CPython) - Windows-7-6.1.7601-SP1 [debug] exe versions: ffmpeg 2021-01-09-git-2e2891383e-full_build-www.gyan.dev, ffprobe 2021-01-09-git-2e2891383e-full_build-www.gyan.dev [debug] Proxy map: {} [puhutv] cukur-115-bolum: Downloading JSON metadata [puhutv] cukur-115-bolum: Downloading video JSON [puhutv] 23958: Downloading m3u8 information [puhutv] 23958: Downloading m3u8 information [puhutv] 23958: Downloading m3u8 information [puhutv] 23958: Downloading m3u8 information [puhutv] 23958: Downloading m3u8 information [puhutv] 23958: Downloading m3u8 information [debug] Invoking downloader on 'http://ck8di1zz.rocketcdn.com/2021/02/09/62319_6cf726d97d248ef73d285d3ab173a872_max_2160p.smil/62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4_chunk.m3u8?r=6' [hlsnative] Downloading m3u8 manifest [hlsnative] Total fragments: 1495 [download] Destination: 115. Bölüm 4. Sezon 115. Bölüm-23958.mp4 [download] 100% of 499.26MiB in 11:12 [debug] ffmpeg command line: ffprobe -show_streams "file:115. Bölüm 4. Sezon 115. Bölüm-23958.mp4" [ffmpeg] Fixing malformed AAC bitstream in "115. Bölüm 4. Sezon 115. Bölüm-23958.mp4" [debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:115. Bölüm 4. Sezon 115. Bölüm-23958.mp4" -c copy -f mp4 "-bsf:a" aac_adtstoasc "file:115. Bölüm 4. Sezon 115. Bölüm-23958.temp.mp4" ``` 2) copy & paste in the browser the m3u8 link from the ytdl output to download and inspect the playlist : ``` #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:7 #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:5.944, /rtuk_6_360.ts #EXT-X-DISCONTINUITY #EXTINF:6.006, 62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4-n_0_0_0.ts #EXTINF:6.006, 62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4-n_1_0_0.ts #EXTINF:6.006, 62319__6cf726d97d248ef73d285d3ab173a872__P240.mp4-n_2_0_0.ts ... etc. ``` **rtuk_6_360.ts** contains the age restriction warning that shows in the beginning of the video, that I want to exclude and download only the main movie. It is even encoded with different parameters than the rest of the video. My proposal is for option to filter out such unwanted segments from a m3u8 or dash playlist (just like individual videos can be skipped from ordinary playlist with --playlist-start, --playlist-end and --playlist-items options). e.g. something in this manner: --segment-start, --segment-end, --segment-items Note my request for this feauture is as general option and not for these specific sites only as I think it will be more flexible if it can be used with the generic extractor as well.
Author
Owner

@mukarator commented on GitHub (Feb 14, 2021):

@dstftw I made some changes to the description, I hope it meets all requirements now

@mukarator commented on GitHub (Feb 14, 2021): @dstftw I made some changes to the description, I hope it meets all requirements now
Author
Owner

@dirkf commented on GitHub (Apr 1, 2024):

Continuation of #15748.

@dirkf commented on GitHub (Apr 1, 2024): Continuation of #15748.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#22925
No description provided.