delete unused files

This commit is contained in:
Lostecho
2024-06-04 22:24:45 +08:00
parent a4c35ef4d8
commit 0a69ccf73d
6 changed files with 77 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

View File

@@ -1,6 +0,0 @@
“想尽一切办法集中注意力 不让自己被灾难(或任何坏事)改变”
* 思考都是物理器官分泌的化学物质的化学反应,有时非常不稳定;
* 晃晃脑袋真的管用
* 逼自己运动、睡觉,缓几天,想法会非常不一样。
* 专注于做原来一直做的事情 —— 比如,李笑来写书
* 拼命想,除了当下对自己冲击最大的事情之外,还有什么值得好好想想? “以冲击为起点不保证正确、全面、完整”……

BIN
courses/temp.mp3 Normal file

Binary file not shown.

77
ffmpegDown.py Normal file
View File

@@ -0,0 +1,77 @@
import os
import threading
import requests
from queue import Queue
# 假设m3u8文件的URL
m3u8_url = 'https://pili-vod.songy.info/9098b1ba-bbd6-44eb-b1b8-641c07750321.m3u8'
# 下载的.ts文件存放的目录
save_dir = './m3u8/mp4'
# 合并后的mp4文件名
output_mp4 = 'xy7nh.mp4'
# 下载.ts文件的函数
def download_ts(ts_url, session):
try:
response = session.get(ts_url, stream=True)
if response.status_code == 200:
ts_filename = ts_url.split('/')[-1]
with open(f"{save_dir}/{ts_filename}", 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Downloaded {ts_filename}")
except Exception as e:
print(f"Error downloading {ts_url}: {e}")
# 解析m3u8文件并获取所有.ts文件的URL
def parse_m3u8(m3u8_url):
with requests.Session() as session:
response = session.get(m3u8_url)
ts_urls = []
if response.status_code == 200:
for line in response.text.splitlines():
if line.endswith('.ts'):
ts_urls.append(line)
return ts_urls
# 多线程下载函数
def multithreaded_download(ts_urls):
# 创建线程安全的队列
queue = Queue()
for ts_url in ts_urls:
queue.put(ts_url)
# 创建会话,用于保持连接
with requests.Session() as session:
threads = []
for _ in range(10): # 假设我们使用10个线程
thread = threading.Thread(target=download_worker, args=(queue, session))
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
# 线程工作函数
def download_worker(queue, session):
while not queue.empty():
ts_url = queue.get()
download_ts(ts_url, session)
queue.task_done()
# 主函数
def main():
ts_urls = parse_m3u8(m3u8_url)
multithreaded_download(ts_urls)
# 下载完成后使用ffmpeg合并文件
os.system(f'ffmpeg -f concat -safe 0 -i "{save_dir}/file_list.txt" -c copy "{output_mp4}"')
if __name__ == '__main__':
main()

BIN
temp.mp3

Binary file not shown.