m3u8文件下载合并的一种方法
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 14 15:09:14 2018
@author: Y
""" import requests
import json #m3u8的文件路径
path = input("Enter m3u8 file path:").replace('\\','/')
print(path)
file = open(path,'r')
operation = input("是否要加上前缀?y/n\n").strip()
pre_link = ''
if operation == 'y':
pre_link = input("请输入前缀:").strip()
links = []
for i in file:
if '#' not in i:
i = i.strip()
links.append(pre_link+i)
file.close()
l = len(links)
print("总共有%d个片段..."%l)
length = len(str(len(links)))
n = 0
txt = ""
for link in links:
n = n + 1
print("还剩%d个片段未下载..."%(l-n))
if len(str(n)) < length:
name = '0'*(length-len(str(n))) + str(n) + ".ts"
else:
name = str(n)+".ts"
txt = txt + "file \'" + name + "\'\n"
jsonreq = json.dumps({'jsonrpc':'2.0', 'id':1,
'method':'aria2.addUri',
'params':[[link],{"out":name,"split":"5","max-connection-per-server":"16","seed-ratio":"0"}]})
c = requests.post('http://localhost:6800/jsonrpc', jsonreq)
file = open("E:\\aria2data\\filelist.txt","w")
file.write(txt)
file.close()
生成的ts文件用 ffmpeg 合并,命令行输入:ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.ts
https://xyne.archlinux.ca/projects/python3-aria2jsonrpc/
https://aur.archlinux.org/packages/python3-aria2jsonrpc/
https://xyne.archlinux.ca/projects/python3-aria2jsonrpc/src/
m3u8文件下载合并的一种方法的更多相关文章
- PHP中数组合并的两种方法及区别介绍
PHP数组合并两种方法及区别 如果是关联数组,如下: 复制代码代码如下: $a = array( 'where' => 'uid=1', 'order' => 'uid', ); $b = ...
- Oracle多行记录合并的几种方法
今天正好遇到需要做这个功能,顺手搜了一下网络,把几种方法都列出来,方便以后参考. 1 什么是合并多行字符串(连接字符串)呢,例如: SQL> desc test; Name Type Nulla ...
- 【转载】Python中如何高效实现两个字典合并,三种方法比较。
本文转载自:http://www.pythoner.com/13.html Python中将两个字典进行合并操作,是一个比较常见的问题.本文将介绍几种实现两个字典合并的方案,并对其进行比较. 对于这个 ...
- JQuery实现表格的相同单元格合并的三种方法
代码: <!DOCTYPE html> <html> <head> <title>merge.html</title> <meta h ...
- js 对象的合并(3种方法)转载
对象的合并 需求:设有对象 o1 ,o2,需要得到对象 o3 var o1 = { a:'a' }, o2 = { b:'b' }; // 则 var o3 = { a:'a', b:'b' } 方法 ...
- Python3 列表list合并的4种方法
方法1: 直接使用"+"号合并列表 aList = [1,2,3] bList = ['www', 'pythontab.com'] cList = aList + bList ...
- Python中字典合并的四种方法
字典是Python语言中唯一的映射类型.映射类型对象里哈希值(键,key)和指向的对象(值,value)是一对多的的关系,通常被认为是可变的哈希表.字典对象是可变的,它是一个容器类型,能存储任意个数的 ...
- upload控件上传json文件合并的两种方法
方法一: byte[] byte1 = FileUpload1.FileBytes; byte[] byte2 = FileUpload2.FileBytes; byte[] a1 = Encodin ...
- C#怎么实现文件下载功能的四种方法
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...
随机推荐
- [django]python异步神器-celery
python异步神器celery https://segmentfault.com/a/1190000007780963
- LuaFileSystem
bokeyuan_1234 lua的文件管理 lua没有自己的文件管理 只有读取和写入文件,但是可以通过调用lfs(LuaFileSystem),lfs是一个 用于lua进行文件访问的库,支持lua5 ...
- Python 类对象去重
注:set 对类对象去重,在于重写__eq__方法和__hash__方法,如果没有重写__hash__会导致People类对象不是可hash的 #!/usr/bin/env python # -*- ...
- Solutions_issues in pip
pip fails ssl verification Solution: $ python -m pip <command> --trusted-host files.pythonhost ...
- linux 下查看c 函数帮助
帮助文档 man man MANUAL SECTIONS The standard sections of the manual include: User Commands System Calls ...
- 1021 Deepest Root
这道题的关键在于如何求两个最远的结点,二叉树比较容易一直DFS就能找到,但是普通树就比较麻烦.要先找到一端,再去找另外一端,两端的并集就是答案.因为结点都是对称的,所以两端都是答案.还要注意去重,12 ...
- python repr和str
都是将对象转换为字符串 repr """ repr(object) -> string Return the canonical string representa ...
- Linux shell脚本 批量创建多个用户
Linux shell脚本 批量创建多个用户 #!/bin/bash groupadd charlesgroup for username in charles1 charles2 charles3 ...
- not value specified for parameter问题解决方案
前段时间遇到这个问题找了半天没有找到,今天又调试了突然发现出现这个问题的根本原因是sql语句中的参数没有赋值或者参数类型与数据库字段类型不匹配所导致的. 例如: String sql = " ...
- JavaScript 创建和浅析自定义对象
在Js中,除了Array.Date.Number等内置对象外,开发者可以通过Js代码创建自己的对象. 目录 1. 对象特性:描述对象的特性 2. 创建对象方式:对象直接量.new 构造函数.Objec ...