You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These playlists are similar enough that I think you could just combine the text contents, but strip out the first three tags from the second one to avoid duplicating them.
Here is some code to do that; it doesn't assume the number of tags to skip is 3.
importm3u8# Read in the playlists# playlist_1_text = ...# playlist_2_text = ...# Split them into linesplaylist_1_lines=playlist_1_text.splitlines()
playlist_2_lines=playlist_2_text.splitlines()
# Take the lines from playlist 1, then add in any non-duplicates from playlist 2line_set=set(playlist_1_lines)
combined_lines=playlist_1_lines+ [xforxinplaylist_2_linesifxnotinline_set]
playlist_combined_text='\n'.join(combined_lines)
# Parse the combined lines to put the media tags back at the topcombined_playlist=m3u8.loads(playlist_combined_text)
combined_playlist_text=combined_playlist.dumps()
print(combined_playlist_text)
file 1.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="1",NAME="none",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="chunklist_5_audio_LQjVYCeD_llhls.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="1"
chunklist_2_video_LQjVYCeD_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="1"
chunklist_1_video_LQjVYCeD_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="1"
chunklist_0_video_LQjVYCeD_llhls.m3u8
file 2.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="5",NAME="none",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="chunklist_5_audio_lHv4VsCh_llhls.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="5"
chunklist_2_video_lHv4VsCh_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="5"
chunklist_1_video_lHv4VsCh_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="5"
chunklist_0_video_lHv4VsCh_llhls.m3u8
i want append mutiple m3u8 to one file m3u8
thank you very much!
sory my english so bad
The text was updated successfully, but these errors were encountered: