Skip to content

Commit 67e7c48

Browse files
authored
加入第三个视频源
2 parents 7a97a5f + 7ae680b commit 67e7c48

File tree

4 files changed

+519
-424
lines changed

4 files changed

+519
-424
lines changed

main.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88
from plugins import base
99
from plugins import lista
10+
from plugins import listb
1011
from plugins import dotpy
1112

1213
class Iptv (object):
@@ -26,6 +27,11 @@ def run(self) :
2627
for item in urlList :
2728
self.addData(item)
2829

30+
listB = listb.Source()
31+
urlList = listB.getSource()
32+
for item in urlList :
33+
self.addData(item)
34+
2935
Dotpy = dotpy.Source()
3036
urlList = Dotpy.getSource()
3137
for item in urlList :
@@ -48,7 +54,7 @@ def addData (self, data) :
4854
def outPut (self) :
4955
sql = """SELECT * FROM
5056
(SELECT * FROM %s WHERE online = 1 ORDER BY delay DESC) AS delay
51-
GROUP BY delay.title
57+
GROUP BY LOWER(delay.title)
5258
HAVING delay.title != '' and delay.title != 'CCTV-' AND delay.delay < 500
5359
ORDER BY level ASC, length(title) ASC, title ASC
5460
""" % (self.DB.table)
@@ -64,14 +70,17 @@ def outPut (self) :
6470
className = '地方频道'
6571
elif item[4] == 3 :
6672
className = '地方频道'
73+
elif item[4] == 7 :
74+
className = '广播频道'
6775
else :
6876
className = '其他频道'
6977

7078
f.write("#EXTINF:-1, group-title=\"%s\", %s\n" % (className, item[1]))
7179
f.write("%s\n" % (item[3]))
7280

73-
obj = Iptv()
74-
obj.run()
81+
if __name__ == '__main__':
82+
obj = Iptv()
83+
obj.run()
7584

7685

7786

plugins/listb.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import tools
5+
import time
6+
import re
7+
8+
class Source (object) :
9+
10+
def __init__ (self):
11+
self.T = tools.Tools()
12+
self.now = int(time.time() * 1000)
13+
14+
def getSource (self) :
15+
urlList = []
16+
17+
url = 'https://www.sheng521.top/zyfx/zbyfx'
18+
req = [
19+
'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',
20+
]
21+
res = self.T.getPage(url, req)
22+
23+
if res['code'] == 200 :
24+
pattern = re.compile(r"<h2 class=\"entry-title\">.*?href=\"(.*?)\".*?<\/h2>", re.I|re.S)
25+
postList = pattern.findall(res['body'])
26+
27+
for post in postList :
28+
url = post
29+
req = [
30+
'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',
31+
]
32+
res = self.T.getPage(url, req)
33+
34+
if res['code'] == 200 :
35+
pattern = re.compile(r"<blockquote(.*?)</blockquote>", re.I|re.S)
36+
tmp = pattern.findall(res['body'])
37+
38+
pattern = re.compile(r"span .*?>(.*?),(.*?)<\/span>", re.I|re.S)
39+
40+
sourceList = pattern.findall(tmp[0])
41+
42+
i = 1
43+
total = len(sourceList)
44+
for item in sourceList :
45+
print('Checking[ %s / %s ]: %s' % (i, total, str(item[0])))
46+
i = i + 1
47+
netstat = self.T.chkPlayable(item[1])
48+
49+
if netstat > 0 :
50+
info = self.T.fmtTitle(item[0])
51+
52+
data = {
53+
'title' : str(info['id']) if info['id'] != '' else str(info['title']),
54+
'url' : str(item[1]),
55+
'quality': str(info['quality']),
56+
'delay' : netstat,
57+
'level' : str(info['level']),
58+
'online' : 1,
59+
'udTime' : self.now,
60+
}
61+
urlList.append(data)
62+
else :
63+
pass # MAYBE later :P
64+
else :
65+
pass # MAYBE later :P
66+
67+
return urlList

tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def fmtTitle (self, string) :
119119
if '+' in result['title'] :
120120
result['id'] = result['id'] + str('+')
121121

122+
pattern = re.compile(r"\[\d+\*\d+\]", re.I)
123+
result['title'] = re.sub(pattern, "", result['title'])
124+
122125
Area = area.Area()
123126
result['level'] = Area.classify(str(result['id']) + str(result['title']))
124127

0 commit comments

Comments
 (0)