Skip to content

Commit

Permalink
自动检索、筛选、测速,生成txt格式频道列表
Browse files Browse the repository at this point in the history
  • Loading branch information
redrainl authored Apr 23, 2024
1 parent 46a65ee commit 6709f51
Show file tree
Hide file tree
Showing 26 changed files with 1,927 additions and 0 deletions.
22 changes: 22 additions & 0 deletions speedtest/hoteliptv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
import sys
import requests

# 目标页面 URL
url = 'http://tonkiang.us/hoteliptv.php'

# 从命令行参数中获取搜索关键字
if len(sys.argv) < 2:
print("Usage: python test.py <search_keyword>")
sys.exit(1)

keyword = sys.argv[1]

# 构造 POST 请求参数
payload = {'search': keyword}

# 发送 POST 请求
response = requests.post(url, data=payload)

# 打印响应内容
print(response.text)
20 changes: 20 additions & 0 deletions speedtest/ip/Beijing_dianxin_186.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1.203.76.237:4022
1.202.10.44:8888
1.202.8.26:8888
123.56.129.203:4310
115.171.216.22:4000
115.171.216.54:4000
115.171.80.162:8888
115.171.251.148:8888
1.203.76.124:7788
1.203.77.99:4022
115.171.37.67:18888
1.202.116.98:87
1.203.77.117:7788
115.171.58.86:4000
106.120.13.217:18022
115.171.238.16:4022
1.203.76.184:7788
115.171.80.101:8888
1.202.117.132:87
1.203.184.77:4000
20 changes: 20 additions & 0 deletions speedtest/ip/Beijing_liantong_145.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
123.115.114.183:9000
114.254.90.42:8020
114.249.18.134:4022
123.113.248.110:8888
114.243.108.225:4000
114.252.199.35:10000
221.216.132.178:8118
111.199.1.184:8686
123.112.246.1:5555
111.196.131.234:8012
123.113.11.89:4022
123.118.4.153:4022
114.252.225.231:8000
114.246.218.57:8000
123.119.165.112:4022
61.149.175.178:4022
114.250.81.93:8686
61.48.31.231:1314
123.115.112.109:4000
123.113.144.69:3568
20 changes: 20 additions & 0 deletions speedtest/ip/Guangdong_332.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
183.31.9.16:9001
113.71.148.79:5555
61.140.234.179:4000
14.112.83.40:2222
61.140.124.156:8888
113.65.8.165:8000
113.86.204.95:9999
ddns.cyruslee.top:8888
183.54.210.111:9999
116.21.123.201:8000
113.87.227.121:5000
183.54.210.224:9999
183.7.13.129:4022
183.33.56.233:8686
14.154.193.230:4022
113.65.8.95:8000
59.34.138.131:4000
116.21.124.218:7777
183.30.202.236:8000
183.30.202.168:8000
20 changes: 20 additions & 0 deletions speedtest/ip/Henan_327.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
n.xmbyj.cn:8055
1.192.196.129:8055
1.192.196.145:8055
123.161.93.204:8089
123.101.98.21:2001
123.101.98.21:2000
1.196.152.60:2000
123.53.245.212:5566
106.42.109.14:2000
123.55.116.51:8888
1.192.6.63:8800
171.8.81.90:8800
1.197.118.80:3838
1.197.119.105:3838
123.149.206.177:8800
171.12.115.6:9000
123.55.105.199:8888
1.193.57.68:8800
1.197.0.132:8888
123.149.136.46:4022
20 changes: 20 additions & 0 deletions speedtest/ip/Jieyang_129.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
113.64.145.105:8081
27.41.251.17:801
27.41.251.239:801
183.31.9.16:9001
113.71.148.79:5555
61.140.234.179:4000
211.97.63.3:801
163.204.28.230:808
183.239.193.55:2223
183.238.248.84:9000
120.77.205.62:8087
14.112.83.40:2222
183.1.251.226:8081
61.140.124.156:8888
113.65.8.165:8000
183.1.251.226:8081
218.19.110.146:9999
183.33.56.233:8686
183.54.210.224:9999
14.154.193.230:4022
20 changes: 20 additions & 0 deletions speedtest/ip/Shanghai_103.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
116.233.180.72:8881
61.173.50.246:8222
101.224.204.43:4022
222.71.11.180:4022
139.196.151.191:2051
58.37.91.53:4000
116.233.174.144:10000
58.37.189.39:8088
116.232.152.207:8888
222.70.229.135:8888
218.80.73.144:18888
58.37.82.140:56789
58.32.40.232:18888
180.152.152.51:4022
101.83.128.184:4022
101.228.218.209:4022
222.70.172.214:4022
116.233.177.130:8881
114.83.211.208:4022
58.41.1.34:8001
20 changes: 20 additions & 0 deletions speedtest/ip/Sichuan_333.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
125.70.163.227:8888
118.112.90.84:8888
171.88.37.49:4022
118.122.103.235:4022
171.221.58.141:4000
vl15191373.imwork.net:8880
125.71.58.153:4022
61.157.50.231:4000
182.138.218.105:55555
171.213.47.174:5555
182.136.215.165:4022
221.237.36.88:8888
118.114.99.140:4022
222.209.49.222:8088
wouu.net:9977
171.213.2.98:4022
182.139.23.62:4022
182.138.228.93:4022
118.116.82.137:4022
221.237.114.81:4000
20 changes: 20 additions & 0 deletions speedtest/ip/Zhejiang_120.ip
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
115.206.161.85:8888
125.117.179.209:8888
125.125.198.173:8881
120.55.49.231:3095
122.224.232.226:8888
115.239.23.192:8858
123.97.14.140:9999
220.189.92.196:9999
122.246.144.61:9999
183.141.217.69:9999
115.208.94.173:8888
183.128.177.225:4022
115.239.96.172:7000
122.243.229.244:9999
220.189.92.253:9999
115.205.189.231:8000
125.126.87.78:9999
125.125.40.20:8000
125.118.60.208:4022
36.27.15.14:4022
178 changes: 178 additions & 0 deletions speedtest/multi_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/bash

#read -p "确定要运行脚本吗?(y/n): " choice

## 判断用户的选择,如果不是"y"则退出脚本
#if [ "$choice" != "y" ]; then
# echo "脚本已取消."
# exit 0
#fi

time=$(date +%m%d%H%M)
i=0

if [ $# -eq 0 ]; then
echo "请选择城市:"
echo "1. 上海电信(Shanghai_103)"
echo "2. 北京联通(Beijing_liantong_145)"
echo "3. 四川电信(Sichuan_333)"
echo "4. 浙江电信(Zhejiang_120)"
echo "5. 北京电信(Beijing_dianxin_186)"
echo "6. 揭阳酒店(Jieyang_129)"
echo "7. 广东电信(Guangdong_332)"
echo "8. 河南电信(Henan_327)"
echo "0. 全部"
read -t 10 -p "输入选择(1-8)或在10秒内无输入将默认选择全部: " city_choice

if [ -z "$city_choice" ]; then
echo "未检测到输入,自动选择全部选项..."
city_choice=0
fi

else
city_choice=$1
fi

# 根据用户选择设置城市和相应的stream
case $city_choice in
1)
city="Shanghai_103"
stream="udp/239.45.3.209:5140"
channel_key="上海电信"
;;
2)
city="Beijing_liantong_145"
stream="rtp/239.3.1.159:8000"
channel_key="北京联通"
;;
3)
city="Sichuan_333"
stream="udp/239.93.1.9:2192"
channel_key="四川电信"
;;
4)
city="Zhejiang_120"
stream="rtp/233.50.200.191:5140"
channel_key="浙江电信"
;;
5)
city="Beijing_dianxin_186"
stream="udp/225.1.8.37:8002"
channel_key="北京电信"
;;
6)
city="Jieyang_129"
stream="hls/38/index.m3u8"
channel_key="揭阳"
;;
7)
city="Guangdong_332"
stream="udp/239.77.1.19:5146"
channel_key="广东电信"
;;
8)
city="Henan_327"
stream="rtp/239.16.20.1:10010"
channel_key="河南电信"
;;
0)
# 如果选择是“全部选项”,则逐个处理每个选项
for option in {1..8}; do
bash ./multi_test.sh $option # 假定script_name.sh是当前脚本的文件名,$option将递归调用
done
exit 0
;;

*)
echo "错误:无效的选择。"
exit 1
;;
esac

# 使用城市名作为默认文件名,格式为 CityName.ip
filename="ip/${city}.ip"

# 搜索最新ip

echo "===============从tonkiang检索最新ip================="
python3 hoteliptv.py $channel_key >test.html
grep -o "href='hotellist.html?s=[^']*'" test.html>temp.txt
# sed -n "s/.*href='hotellist.html?s=\([^']*\)'.*/\1/p" temp.txt > $filename
sed -n "s/^.*href='hotellist.html?s=\([^:]*:[0-9]*\).*/\1/p" temp.txt > $filename
rm -f test.html


echo "===============检索完成================="

# 检查文件是否存在
if [ ! -f "$filename" ]; then
echo "错误:文件 $filename 不存在。"
exit 1
fi

lines=$(cat "$filename" | wc -l)
echo "$filename文件】内ip共计$lines"

while read line; do
i=$(($i + 1))
ip=$line
url="http://$ip/$stream"
if [ "$city" == "Jieyang_129" ]; then
echo $url
# 使用yt-dlp下载并解析下载速度
output=$(yt-dlp --ignore-config --no-cache-dir --output "output.ts" --download-archive new-archive.txt --external-downloader ffmpeg --external-downloader-args "-t 5" "$url" 2>&1)
a=$(echo "$output" | grep -oP 'at \K[0-9.]+M')
rm -f new-archive.txt output.ts
else
echo $url
curl $url --connect-timeout 3 --max-time 10 -o /dev/null >zubo.tmp 2>&1
a=$(head -n 3 zubo.tmp | awk '{print $NF}' | tail -n 1)
fi




echo "$i/$lines个:$ip $a"
echo "$ip $a" >> "speedtest_${city}_$time.log"
done < "$filename"

rm -f zubo.tmp
cat "speedtest_${city}_$time.log" | grep -E 'M|k' | awk '{print $2" "$1}' | sort -n -r >"result/result_${city}.txt"
cat "result/result_${city}.txt"
ip1=$(head -n 1 result/result_${city}.txt | awk '{print $2}')
ip2=$(head -n 2 result/result_${city}.txt | tail -n 1 | awk '{print $2}')
ip3=$(head -n 3 result/result_${city}.txt | tail -n 1 | awk '{print $2}')

sed "s/ipipip/$ip1/g" template/template_${city}.txt >tmp1.txt
sed "s/ipipip/$ip2/g" template/template_${city}.txt >tmp2.txt
sed "s/ipipip/$ip3/g" template/template_${city}.txt >tmp3.txt
cat tmp1.txt tmp2.txt tmp3.txt >txt/${city}.txt

rm -rf tmp1.txt tmp2.txt tmp3.txt


echo "上海电信,#genre#" >zubo.txt
cat txt/Shanghai_103.txt >>zubo.txt
echo "北京电信,#genre#" >>zubo.txt
cat txt/Beijing_dianxin_186.txt >>zubo.txt
echo "北京联通,#genre#" >>zubo.txt
cat txt/Beijing_liantong_145.txt >>zubo.txt
echo "河南电信,#genre#" >>zubo.txt
cat txt/Henan_327.txt >>zubo.txt
echo "广东电信,#genre#" >>zubo.txt
cat txt/Guangdong_332.txt >>zubo.txt
echo "四川电信,#genre#" >>zubo.txt
cat txt/Sichuan_333.txt >>zubo.txt
echo "浙江电信,#genre#" >>zubo.txt
cat txt/Zhejiang_120.txt >>zubo.txt
echo "广东揭阳,#genre#" >>zubo.txt
cat txt/Jieyang_129.txt >>zubo.txt

scp root@你的服务器:/iptv/mylist.txt .
# sed -i '/^上海电信/,$d' mylist.txt
sed -i '/^上海电信/,/^上海IPV6/{/^上海IPV6/!d;}' mylist.txt
cat zubo.txt mylist.txt >temp.txt && mv -f temp.txt mylist.txt
scp mylist.txt root@你的服务器:/iptv/mylist.txt

for a in result/*.txt; do echo "";echo "========================= $(basename "$a") ==================================="; cat $a; done

4 changes: 4 additions & 0 deletions speedtest/result/result_Beijing_dianxin_186.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
981k 1.203.76.124:7788
979k 115.171.216.22:4000
968k 115.171.216.54:4000
633k 115.171.251.148:8888
16 changes: 16 additions & 0 deletions speedtest/result/result_Beijing_liantong_145.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
977k 61.48.31.231:1314
977k 123.119.165.112:4022
977k 123.118.4.153:4022
977k 123.115.114.183:9000
977k 123.115.112.109:4000
977k 123.113.11.89:4022
977k 114.254.90.42:8020
977k 114.249.18.134:4022
977k 114.246.218.57:8000
977k 114.243.108.225:4000
977k 111.199.1.184:8686
977k 111.196.131.234:8012
848k 221.216.132.178:8118
841k 123.112.246.1:5555
492k 114.252.199.35:10000
403k 123.113.248.110:8888
Loading

0 comments on commit 6709f51

Please sign in to comment.