#!/usr/bin/python #encoding:utf-8 import urllib.request import os import ssl #add line 1 ssl._create_default_https_context = ssl._create_unverified_context #add line 2 for i in range(324,666):#起始位置要自己在浏览器的source来看 s = str(i) s = s.zfill(3) s = s + '.ts' url = 'https://v4.438vip.com/20180722/kxXgbrAR/900kb/hls/gADVKtd2281'+ s # 流文件地址自己获取 local = os.path.join('video', s) urllib.request.urlretrieve(url,local) print('download:', s) #print(url) #print(local)
下载好以后进行合并
#encoding:utf-8 import os dirs = "/video/new5/"#保存下载的流文件地址 mp4 = "/video/"#输出地址 filename = "视频文件名.ts" f = open(filename, 'wb+') for i in range(0,365):#起始地址根据下载的ts流文件获取 s = str(i) s = s.zfill(3) s = dirs + s + '.ts' print(s) for line in open(s, "rb"): f.write(line) f.flush() f.close() #如果以上方法整理出的视频有质量损失,在cmd.exe下使用copy /b F:\迅雷下载\out\*.ts F:\new.ts
标签:python,视频流,ts,print,import,line,下载 From: https://www.cnblogs.com/chentiao/p/17558585.html