加入第三个源
This commit is contained in:
commit
f125bed323
|
@ -8,6 +8,8 @@
|
|||
|
||||
最后程序会在同类的源中选出延迟最低的一个,按频道优先级汇总,并输出一个m3u文件.
|
||||
|
||||
目前频道数量: 876
|
||||
|
||||
**!!!这个项目的代码还在进行中!!!**
|
||||
|
||||
#### 使用方法
|
||||
|
@ -20,11 +22,17 @@ python main.py
|
|||
|
||||
建议以docker的方式,直接在路由器上运行,本地检测地址访问,更为精准.
|
||||
|
||||
#### 已知问题
|
||||
- 访问速度慢,视频卡顿
|
||||
- 解决方案: 不要直接引用项目中的tv.m3u8文件,clone项目到本地,在本地网络环境下执行项目,生成新的文件
|
||||
- 电视,广播未分开
|
||||
- 暂时未处理,会v在后续版本进行分类
|
||||
|
||||
#### 目前资料来源
|
||||
---
|
||||
- https://www.jianshu.com/p/2499255c7e79
|
||||
- https://github.com/billy21/Tvlist-awesome-m3u-m3u8
|
||||
- V2ex - [Dotpy](https://www.v2ex.com/member/Dotpy) 提供1600+可用播放源
|
||||
|
||||
#### 运行环境
|
||||
---
|
||||
|
|
18
main.py
18
main.py
|
@ -7,6 +7,7 @@ import time
|
|||
import re
|
||||
from plugins import base
|
||||
from plugins import lista
|
||||
from plugins import dotpy
|
||||
|
||||
class Iptv (object):
|
||||
|
||||
|
@ -15,13 +16,18 @@ class Iptv (object):
|
|||
self.DB = db.DataBase()
|
||||
|
||||
def run(self) :
|
||||
Base = base.Source()
|
||||
urlList = Base.getSource()
|
||||
for item in urlList :
|
||||
self.addData(item)
|
||||
# Base = base.Source()
|
||||
# urlList = Base.getSource()
|
||||
# for item in urlList :
|
||||
# self.addData(item)
|
||||
|
||||
listA = lista.Source()
|
||||
urlList = listA.getSource()
|
||||
# listA = lista.Source()
|
||||
# urlList = listA.getSource()
|
||||
# for item in urlList :
|
||||
# self.addData(item)
|
||||
|
||||
Dotpy = dotpy.Source()
|
||||
urlList = Dotpy.getSource()
|
||||
for item in urlList :
|
||||
self.addData(item)
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ class Source (object) :
|
|||
sourceList = sourceList + pattern.findall(tmp[1])
|
||||
|
||||
for item in sourceList :
|
||||
print('Checking:' + str(item[0]))
|
||||
i = 1
|
||||
print('Checking[' + str(i) + ']:' + str(item[0]))
|
||||
i = i + 1
|
||||
netstat = self.T.chkPlayable(item[1])
|
||||
|
||||
if netstat > 0 :
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import tools
|
||||
import time
|
||||
import re
|
||||
|
||||
class Source (object) :
|
||||
|
||||
def __init__ (self):
|
||||
self.T = tools.Tools()
|
||||
self.now = int(time.time() * 1000)
|
||||
|
||||
def getSource (self) :
|
||||
urlList = []
|
||||
|
||||
sourcePath = './plugins/dotpy_source'
|
||||
with open(sourcePath, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for i in range(0, len(lines)):
|
||||
line = lines[i].strip('\n')
|
||||
item = line.split(',', 1)
|
||||
|
||||
print('Checking[' + str(i) + ']:' + str(item[0]))
|
||||
netstat = self.T.chkPlayable(item[1])
|
||||
|
||||
if netstat > 0 :
|
||||
info = self.T.fmtTitle(item[0])
|
||||
|
||||
data = {
|
||||
'title' : str(info['id']) if info['id'] != '' else str(info['title']),
|
||||
'url' : str(item[1]),
|
||||
'quality': str(info['quality']),
|
||||
'delay' : netstat,
|
||||
'level' : info['level'],
|
||||
'online' : 1,
|
||||
'udTime' : self.now,
|
||||
}
|
||||
urlList.append(data)
|
||||
else :
|
||||
pass # MAYBE later :P
|
||||
|
||||
|
||||
return urlList
|
File diff suppressed because it is too large
Load Diff
|
@ -28,9 +28,10 @@ class Source (object) :
|
|||
sourceList = pattern.findall(tmp[0])
|
||||
|
||||
for item in sourceList :
|
||||
print('Checking:' + str(item[0]))
|
||||
i = 1
|
||||
print('Checking[' + str(i) + ']:' + str(item[0]))
|
||||
netstat = self.T.chkPlayable(item[1])
|
||||
|
||||
i = i + 1
|
||||
if netstat > 0 :
|
||||
info = self.T.fmtTitle(item[0])
|
||||
|
||||
|
|
11
tools.py
11
tools.py
|
@ -12,7 +12,7 @@ import socket
|
|||
import time
|
||||
import area
|
||||
|
||||
socket.setdefaulttimeout(10.0)
|
||||
socket.setdefaulttimeout(5.0)
|
||||
|
||||
class Tools (object) :
|
||||
|
||||
|
@ -104,21 +104,22 @@ class Tools (object) :
|
|||
if result['id'] != '':
|
||||
pattern = re.compile(r"cctv[-|\s]*(\d*)", re.I)
|
||||
result['id'] = re.sub(pattern, "CCTV-\\1", result['id'])
|
||||
|
||||
|
||||
if '+' in result['title'] :
|
||||
result['id'] = result['id'] + str('+')
|
||||
|
||||
Area = area.Area()
|
||||
result['level'] = Area.classify(str(result['id']) + str(result['title']))
|
||||
|
||||
# Radio
|
||||
|
||||
return result
|
||||
|
||||
def chkPlayable (self, url) :
|
||||
try:
|
||||
startTime = int(round(time.time() * 1000))
|
||||
res = self.getPage(url)
|
||||
|
||||
if res['code'] == 200 :
|
||||
code = urllib.request.urlopen(url).getcode()
|
||||
if code == 200 :
|
||||
endTime = int(round(time.time() * 1000))
|
||||
useTime = endTime - startTime
|
||||
return int(useTime)
|
||||
|
|
Loading…
Reference in New Issue