N_m3u8DL-RE icon indicating copy to clipboard operation
N_m3u8DL-RE copied to clipboard

Ability to auto select video by how many segments it has

Open num421337 opened this issue 2 years ago • 2 comments

Common links I use have two primary formats both exactly the same except one has 1 segment and the other has multiple, if I have it auto select it will go for the one with multiple and end up downloading the same thing multiple times. This happens with both Video and Audio, is there a command that I can have it automatically choose the audio and video with 1 segment and the best quality otherwise?

num421337 avatar Sep 19 '22 01:09 num421337

What the streams look like? Please paste the streams screenshot

nilaoda avatar Sep 19 '22 02:09 nilaoda

image image

the ones I'd want to auto select are the 1280x720 with one segment and the highest bitrate, and then the audio as well with 1 segment and the highest bitrate

num421337 avatar Sep 19 '22 02:09 num421337

FYI what i do is grab the output then regex on the segment count to check for e.g. the below. it checks if there is 4 digits of segment count, then 3 etc etc.. on the 1080p stream. you could adapt yours to do similar. change the 1080 to 720, etc (code in python)

proc = subprocess.run(f'N_m3u8DL-RE "{self.mpd}"',stdout=subprocess.PIPE, text=True)

    try:
        regex_video_id = re.search("1080.+(video=\d{7}).+\s.\s\d{**4**}",proc.stdout)
        print(regex_video_id.group(1))
        regex_audio_id = re.search(".(audio.+=\d{6})\s.+mp4a.{1,25}\d{4}\sSegment",proc.stdout)
        print(regex_audio_id.group(1))
    except:
        print("failed first regex")
        try:
            regex_video_id = re.search("1080.+(video=\d{7}).+\s.\s\d{3}",proc.stdout)
            print(regex_video_id.group(1))
        except:

....

pythonkenyard avatar Nov 12 '22 12:11 pythonkenyard

Available in new version

nilaoda avatar Dec 18 '22 15:12 nilaoda