diff --git a/8093/78b6da46-ecd8-46fb-a857-423ca6da8196.png b/8093/78b6da46-ecd8-46fb-a857-423ca6da8196.png deleted file mode 100644 index 09a37cc..0000000 Binary files a/8093/78b6da46-ecd8-46fb-a857-423ca6da8196.png and /dev/null differ diff --git a/8093/8093.mp3 b/8093/8093.mp3 deleted file mode 100644 index 43aef59..0000000 Binary files a/8093/8093.mp3 and /dev/null differ diff --git a/8093/8093note.txt b/8093/8093note.txt deleted file mode 100644 index d24c98c..0000000 --- a/8093/8093note.txt +++ /dev/null @@ -1,6 +0,0 @@ -“想尽一切办法集中注意力 不让自己被灾难(或任何坏事)改变” -* 思考都是物理器官分泌的化学物质的化学反应,有时非常不稳定; -* 晃晃脑袋真的管用 -* 逼自己运动、睡觉,缓几天,想法会非常不一样。 -* 专注于做原来一直做的事情 —— 比如,李笑来写书 -* 拼命想,除了当下对自己冲击最大的事情之外,还有什么值得好好想想? “以冲击为起点不保证正确、全面、完整”…… diff --git a/courses/temp.mp3 b/courses/temp.mp3 new file mode 100644 index 0000000..3324720 Binary files /dev/null and b/courses/temp.mp3 differ diff --git a/ffmpegDown.py b/ffmpegDown.py new file mode 100644 index 0000000..d692745 --- /dev/null +++ b/ffmpegDown.py @@ -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() \ No newline at end of file diff --git a/temp.mp3 b/temp.mp3 deleted file mode 100644 index d1c6346..0000000 Binary files a/temp.mp3 and /dev/null differ