小幅调整频道标题匹配方法

This commit is contained in:
EvilCult 2019-05-28 19:02:53 +08:00
parent 321d476fd4
commit d59f4e688e
2 changed files with 26 additions and 8 deletions

13
main.py
View File

@ -28,10 +28,10 @@ class Iptv (object):
Dotpy = dotpy.Source()
urlList = Dotpy.getSource()
for item in urlList :
self.addData(item)
# for item in urlList :
# self.addData(item)
self.outPut()
# self.outPut()
print("DONE!!")
def addData (self, data) :
@ -70,6 +70,13 @@ class Iptv (object):
f.write("#EXTINF:-1, group-title=\"%s\", %s\n" % (className, item[1]))
f.write("%s\n" % (item[3]))
# def test (self) :
# line = 'SkyFolkTV,http://skyfolk.mk/live.m3u8'
# item = line.split(',', 1)
# info = self.T.fmtTitle(item[0])
# print(info)
obj = Iptv()
obj.run()

View File

@ -91,13 +91,24 @@ class Tools (object) :
return data
def fmtTitle (self, string) :
pattern = re.compile(r"(cctv[-|\s]*\d*)*\s*?([^fhd|^hd|^sd|^\.m3u8]*)\s*?(fhd|hd|sd)*", re.I)
tmp = pattern.findall(string)[0]
pattern = re.compile(r"(cctv[-|\s]*\d*)?(.*)", re.I)
tmp = pattern.findall(string)
channelId = tmp[0][0].strip('-').strip()
channeTitle = tmp[0][1]
channeTitle = channeTitle.replace('.m3u8', '')
pattern = re.compile(r"(fhd|hd|sd)", re.I)
tmp = pattern.findall(channeTitle)
quality = ''
if len(tmp) > 0 :
quality = tmp[0]
channeTitle = channeTitle.replace(tmp[0], '')
result = {
'id' : tmp[0].strip('-').strip(),
'title' : tmp[1].strip('-').strip(),
'quality': tmp[2].strip('-').strip(),
'id' : channelId,
'title' : channeTitle.strip('-').strip(),
'quality': quality.strip('-').strip(),
'level' : 4,
}