An m3u
or m3u8
file is just a list of links (one per line) mixed with comments. I used the following small Python program to download all parts of the playlist one-by-one:
#!/usr/bin/env python3
import subprocess
import os
def dump(playlist):
urls = []
with open(playlist, 'r') as fh:
for line in fh:
if line[0] == '#':
continue
urls.append(line.strip())
count = 1
for url in urls:
dumpfile = 'part%04d.ts' % count
count += 1
if os.path.exists(dumpfile):
print('Skipping %s...' % dumpfile)
cmd = [
'mplayer',
'-dumpfile', dumpfile,
'-dumpstream',
url
]
print('%s -> %s' % (url, dumpfile))
rc = subprocess.call(cmd)
if rc != 0:
raise Exception('dump failed')
if __name__ == '__main__':
import sys
playlist = sys.argv[1]
dump(playlist)
If the parts are MPEG .ts
files ("transport stream"), see this question how to join them: Use ffmpeg copy codec to combine *.ts files into a single mp4
For other types of files, you will probably need tools. (see here for mp3)