From cc785ec4e7df7b285e15ca4fccb7f67282ae8d54 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:01:08 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=B5=8B=E7=BB=98=E7=AB=99=E9=87=87?= =?UTF-8?q?=E9=9B=86.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/测绘站采集.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/py/测绘站采集.py b/py/测绘站采集.py index 4c29bf8..16a6d83 100644 --- a/py/测绘站采集.py +++ b/py/测绘站采集.py @@ -428,13 +428,24 @@ simplified_text = converter.convert(traditional_text) # 将转换后的简体字写入txt文件 with open('综合源.txt', 'w', encoding='utf-8') as file: file.write(simplified_text) + + + + #TXT转M3U# +import datetime def txt_to_m3u(input_file, output_file): # 读取txt文件内容 with open(input_file, 'r', encoding='utf-8') as f: lines = f.readlines() # 打开m3u文件并写入内容 + now = datetime.datetime.utcnow() + datetime.timedelta(hours=8) + current_time = now.strftime("%m-%d %H:%M") with open(output_file, 'w', encoding='utf-8') as f: + f.write(f'#EXTINF:-1 group-title="更新时间",请您欣赏\n') + f.write(f'https://vd2.bdstatic.com/mda-nk3am8nwdgqfy6nh/sc/cae_h264/1667555203921394810/mda-nk3am8nwdgqfy6nh.mp4\n') + f.write(f'#EXTINF:-1 group-title="{current_time}",虚情的爱\n') + f.write(f'https://vd2.bdstatic.com/mda-mi1dd05gmhwejdwn/sc/cae_h264/1630576203346678103/mda-mi1dd05gmhwejdwn.mp4\n') f.write('#EXTM3U x-tvg-url="https://live.fanmingming.com/e.xml" catchup="append" catchup-source="?playseek=${(b)yyyyMMddHHmmss}-${(e)yyyyMMddHHmmss}"\n') # 初始化genre变量 genre = '' @@ -454,6 +465,7 @@ def txt_to_m3u(input_file, output_file): f.write(f'{channel_url}\n') # 将txt文件转换为m3u文件 txt_to_m3u('综合源.txt', '综合源.m3u') + #任务结束,删除不必要的过程文件# files_to_remove = ['组播源.txt', "TW.txt", "a.txt", "主.txt", "b.txt", "b1.txt", "港澳.txt", "省市.txt", "df.txt", "df1.txt", "少儿1.txt", "sr2.txt", \ "c2.txt", "c1.txt", "DD.txt", "f.txt", "f1.txt"]