Comments (14)
一直在稳定运行中
from tv.
我是我我自己frok的仓库,不过好像运行了,我想改时间,这里面的定时是北京时间还是美国时间还是英国时间?我自己一天只需要一次或两次就够了。另外一个是我看到有某卫视中文台,为何没有输出到最终的itvlist?卫视和其他可否自己选择输出的台,有些不想要
from tv.
itvtest.py 这条我改成5为什么还是跑出8条结果呢?result_counter = 5 # 每个频道需要的个数
from tv.
时间好像是加八就是北京时间
from tv.
这个文件没有运行,所以改了没用
from tv.
我改了CCTVpy和卫视py看有没有用,时间我百度了是UTC时间,差不多搞明白了。就是看大佬能否做个功能卫视和其他可否自己选择输出的台,有些不想要不要输出,最好有凤凰那三个台。
from tv.
大佬,我仿照你的脚本想抓去港澳台,为什么它不动呢?请指教。
run gangao 0s
Run python /home/runner/work/IPTVTEST/IPTVTEST/gangao.py
python /home/runner/work/IPTVTEST/IPTVTEST/gangao.py
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.12.2/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.2/x64/lib
import os
import re
import time
import datetime
import threading
from queue import Queue
import requests
import eventlet
eventlet.monkey_patch()
线程安全的队列,用于存储下载任务
task_queue = Queue()
线程安全的列表,用于存储结果
results = []
channels = []
error_channels = []
with open("itv.txt", 'r', encoding='utf-8') as file:
lines = file.readlines()
for line in lines:
line = line.strip()
if line:
channel_name, channel_url = line.split(',')
if '凤凰' in channel_name and '翡翠' in channel_name and '明珠' in channel_name:
channels.append((channel_name, channel_url))
定义工作线程函数
def worker():
while True:
# 从队列中获取一个任务
channel_name, channel_url = task_queue.get()
try:
channel_url_t = channel_url.rstrip(channel_url.split('/')[-1]) # m3u8链接前缀
lines = requests.get(channel_url).text.strip().split('\n') # 获取m3u8文件内容
ts_lists = [line.split('/')[-1] for line in lines if line.startswith('#') == False] # 获取m3u8文件下视频流后缀
ts_lists_0 = ts_lists[0].rstrip(ts_lists[0].split('.ts')[-1]) # m3u8链接前缀
ts_url = channel_url_t + ts_lists[0] # 拼接单个视频片段下载链接
# 多获取的视频数据进行5秒钟限制
with eventlet.Timeout(5, False):
start_time = time.time()
content = requests.get(ts_url).content
end_time = time.time()
response_time = (end_time - start_time) * 1
if content:
with open(ts_lists_0, 'ab') as f:
f.write(content) # 写入文件
file_size = len(content)
# print(f"文件大小:{file_size} 字节")
download_speed = file_size / response_time / 1024
# print(f"下载速度:{download_speed:.3f} kB/s")
normalized_speed = min(max(download_speed / 1024, 0.001), 100) # 将速率从kB/s转换为MB/s并限制在1~100之间
#print(f"标准化后的速率:{normalized_speed:.3f} MB/s")
# 删除下载的文件
os.remove(ts_lists_0)
result = channel_name, channel_url, f"{normalized_speed:.3f} MB/s"
results.append(result)
numberx = (len(results) + len(error_channels)) / len(channels) * 100
print(f"可用频道:{len(results)} 个 , 不可用频道:{len(error_channels)} 个 , 总频道:{len(channels)} 个 ,总进度:{numberx:.2f} %。")
except:
error_channel = channel_name, channel_url
error_channels.append(error_channel)
numberx = (len(results) + len(error_channels)) / len(channels) * 100
print(f"可用频道:{len(results)} 个 , 不可用频道:{len(error_channels)} 个 , 总频道:{len(channels)} 个 ,总进度:{numberx:.2f} %。")
# 标记任务完成
task_queue.task_done()
创建多个工作线程
num_threads = 10
for _ in range(num_threads):
t = threading.Thread(target=worker, daemon=True)
#t = threading.Thread(target=worker, args=(event,len(channels))) # 将工作线程设置为守护线程
t.start()
#event.set()
添加下载任务到队列
for channel in channels:
task_queue.put(channel)
等待所有任务完成
task_queue.join()
def channel_key(channel_name):
match = re.search(r'\d+', channel_name)
if match:
return int(match.group())
else:
return float('inf') # 返回一个无穷大的数字作为关键字
对频道进行排序
results.sort(key=lambda x: (x[0], -float(x[2].split()[0])))
#results.sort(key=lambda x: channel_key(x[0]))
now_today = datetime.date.today()
将结果写入文件
result_counter = 5 # 每个频道需要的个数
with open("gangao.txt", 'w', encoding='utf-8') as file:
channel_counters = {}
file.write('港澳频道,#genre#\n')
for result in results:
channel_name, channel_url, speed = result
if '凤凰' in channel_name and '翡翠' in channel_name and '明珠' in channel_name:
if channel_name in channel_counters:
if channel_counters[channel_name] >= result_counter:
continue
else:
file.write(f"{channel_name},{channel_url}\n")
channel_counters[channel_name] += 1
else:
file.write(f"{channel_name},{channel_url}\n")
channel_counters[channel_name] = 1
with open("gangao.m3u", 'w', encoding='utf-8') as file:
channel_counters = {}
#file.write('港澳频道,#genre#\n')
for result in results:
channel_name, channel_url, speed = result
if '凤凰' in channel_name and '翡翠' in channel_name and '明珠' in channel_name:
if channel_name in channel_counters:
if channel_counters[channel_name] >= result_counter:
continue
else:
file.write(f"#EXTINF:-1 group-title="港澳频道",{channel_name}\n")
file.write(f"{channel_url}\n")
channel_counters[channel_name] += 1
else:
file.write(f"#EXTINF:-1 group-title="港澳频道",{channel_name}\n")
file.write(f"{channel_url}\n")
channel_counters[channel_name] = 1
from tv.
if '凤凰' in channel_name and '翡翠' in channel_name and '明珠' in channel_name:
channels.append((channel_name, channel_url))
这里写错了,好多台没有,只留凤凰试试
from tv.
好的,我试试,大老。但是如果要多几个台呢?翡翠,明珠我搜了itv里面是有一两个台的。
另外,建议大佬把其它那里增加几个筛除广告的几个台。
if '卫视' not in channel_name and 'QTV' not in channel_name and '购物' not in channel_name and 'CCTV' not in channel_name and '测试' not in channel_name and '凤凰' not in channel_name and '翡翠' not in channel_name and '明珠' not in channel_name:
channels.append((channel_name, channel_url))
from tv.
中间不用and用or,就是多个频道了
from tv.
谢谢大老,我刚问了chatgpt, 我看到它也是这么写的,我来试一下。
from tv.
👍
from tv.
大佬,跑是跑成功了,但是都没有输出,应该都是用不了的,大佬能加多几个找源的地方就好了。
from tv.
没有合适的了
from tv.
Related Issues (20)
- 最好把节目名称弄的规范一些 HOT 1
- docker里面会报错“递归超过了最大的深度” HOT 10
- docker版本每次都要手动吗 HOT 3
- python3: can't open file '/app/itvall.py': [Errno 2] No such file or directory HOT 1
- /ZHGXTV/ HOT 2
- 有些网络问题:速度太慢,播放不流畅,可否优化 HOT 8
- itv_all(1080).py line 33 issue HOT 6
- sudo docker run liuxipo/itvall HOT 12
- 大佬,能增加非酒店的源么,比如电信,移动的盒子的?酒店源失效好像非常快,有时候出来10分钟就没了。 HOT 17
- 运行sudo docker run liuxipo/itvall 出现下面的报错 HOT 1
- 请求大佬 能不能直接在docker搞个端口映射 容器运行好后 让容器保持运行 设置多长时间抓取一次 最后我们直接访问http://本地ip:端口/itvall/itvlist.txt 就行了 就不用再映射到外面目录了 HOT 3
- 你好老大。我对你的组播地址很感兴趣 HOT 24
- 收到您的组播脚本规则了,但是遇到点小问题 HOT 1
- docker pull liuxipo/itvall:latest HOT 1
- 群晖docker运行完不保存文件 HOT 4
- 关于组播的一点意见 HOT 2
- 请问大佬,fofa 是否可以实现登录,这样查询的数据可能会多点 HOT 2
- 大佬 搜索直播源出问题了 HOT 3
- 建议给docker版本加上自建web服务,可以设置定时自动执行刷新任务 HOT 1
- m3u 完整格式问题 在某些软件在线订阅频道获取失败 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tv.