加入第三个视频源 & 优化入库标题规范
This commit is contained in:
parent
463c6f7c9c
commit
135dd57c2f
9
main.py
9
main.py
|
@ -7,6 +7,7 @@ import time
|
|||
import re
|
||||
from plugins import base
|
||||
from plugins import lista
|
||||
from plugins import listb
|
||||
from plugins import dotpy
|
||||
|
||||
class Iptv (object):
|
||||
|
@ -26,6 +27,11 @@ class Iptv (object):
|
|||
for item in urlList :
|
||||
self.addData(item)
|
||||
|
||||
listB = listb.Source()
|
||||
urlList = listB.getSource()
|
||||
for item in urlList :
|
||||
self.addData(item)
|
||||
|
||||
Dotpy = dotpy.Source()
|
||||
urlList = Dotpy.getSource()
|
||||
for item in urlList :
|
||||
|
@ -64,12 +70,15 @@ class Iptv (object):
|
|||
className = '地方频道'
|
||||
elif item[4] == 3 :
|
||||
className = '地方频道'
|
||||
elif item[4] == 7 :
|
||||
className = '广播频道'
|
||||
else :
|
||||
className = '其他频道'
|
||||
|
||||
f.write("#EXTINF:-1, group-title=\"%s\", %s\n" % (className, item[1]))
|
||||
f.write("%s\n" % (item[3]))
|
||||
|
||||
|
||||
obj = Iptv()
|
||||
obj.run()
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
#!/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 = []
|
||||
|
||||
url = 'https://www.sheng521.top/zyfx/zbyfx'
|
||||
req = [
|
||||
'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Mobile Safari/537.36',
|
||||
]
|
||||
res = self.T.getPage(url, req)
|
||||
|
||||
if res['code'] == 200 :
|
||||
pattern = re.compile(r"<h2 class=\"entry-title\">.*?href=\"(.*?)\".*?<\/h2>", re.I|re.S)
|
||||
postList = pattern.findall(res['body'])
|
||||
|
||||
for post in postList :
|
||||
url = post
|
||||
req = [
|
||||
'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Mobile Safari/537.36',
|
||||
]
|
||||
res = self.T.getPage(url, req)
|
||||
|
||||
if res['code'] == 200 :
|
||||
pattern = re.compile(r"<blockquote(.*?)</blockquote>", re.I|re.S)
|
||||
tmp = pattern.findall(res['body'])
|
||||
|
||||
pattern = re.compile(r"span .*?>(.*?),(.*?)<\/span>", re.I|re.S)
|
||||
|
||||
sourceList = pattern.findall(tmp[0])
|
||||
|
||||
i = 1
|
||||
total = len(sourceList)
|
||||
for item in sourceList :
|
||||
print('Checking[ %s / %s ]: %s' % (i, total, str(item[0])))
|
||||
i = i + 1
|
||||
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' : str(info['level']),
|
||||
'online' : 1,
|
||||
'udTime' : self.now,
|
||||
}
|
||||
urlList.append(data)
|
||||
else :
|
||||
pass # MAYBE later :P
|
||||
else :
|
||||
pass # MAYBE later :P
|
||||
|
||||
return urlList
|
4
tools.py
4
tools.py
|
@ -119,6 +119,10 @@ class Tools (object) :
|
|||
if '+' in result['title'] :
|
||||
result['id'] = result['id'] + str('+')
|
||||
|
||||
pattern = re.compile(r"\[\d+\*\d+\]", re.I)
|
||||
result['title'] = re.sub(pattern, "", result['title'])
|
||||
result['title'] = result['title'].title()
|
||||
|
||||
Area = area.Area()
|
||||
result['level'] = Area.classify(str(result['id']) + str(result['title']))
|
||||
|
||||
|
|
Loading…
Reference in New Issue