Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import shutil
- import re
- import os
- def get_file_list(filelist):
- with open('%s' % filelist, 'r') as playlist:
- ts_filenames = [line.rstrip() for line in playlist
- if line.rstrip().endswith('.ts?null=')]
- count = 0
- fo = open("filelist.txt", "wb")
- for ts_file in ts_filenames:
- count = count + 1
- fo.write(ts_file)
- fo.write("\n")
- fo.close()
- print 'Total files : %d' %count
- def newfile(newname,filelist):
- with open('%s' % filelist, 'r') as playlist:
- ts_filenames = [line.rstrip() for line in playlist
- if line.rstrip().endswith('.ts?null=')]
- with open(newname, 'wb') as merged:
- for ts_file in ts_filenames:
- result = re.search('segment(.*)?null=', ts_file)
- filename = result.group(1).replace("?", "")
- with open("temp/segment%s" %(filename), 'rb') as mergefile:
- shutil.copyfileobj(mergefile, merged)
- print "Done"
- def main():
- if not os.path.exists('temp'):
- os.makedirs('temp')
- # get_file_list ( file name )
- filelist = 'index_0_av.m3u8'
- get_file_list(filelist)
- # load the list to the download manager 'DownThemAll!'
- # save them to the folder 'temp'
- # after downloading use this one
- ֳ#newname = 'newfile.ts'
- ֳ#newfile(newname,filelist)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement