This commit is contained in:
yumoqing 2025-10-15 18:30:54 +08:00
parent 1a53694f75
commit 7863dd6465

View File

@ -6,9 +6,11 @@ import os
import asyncio import asyncio
from datetime import datetime from datetime import datetime
from appPublic.jsonConfig import getConfig from appPublic.jsonConfig import getConfig
from appPublic.dictObject import DictObject
from appPublic.streamhttpclient import StreamHttpClient from appPublic.streamhttpclient import StreamHttpClient
from appPublic.uniqueID import getID from appPublic.uniqueID import getID
from appPublic.log import debug from appPublic.log import debug
from ahserver.serverenv import ServerEnv
from sqlor.dbpools import DBPools from sqlor.dbpools import DBPools
from iptv import m3u from iptv import m3u
from iptv.m3u8test import test_channels, write_goodchannel from iptv.m3u8test import test_channels, write_goodchannel
@ -28,7 +30,7 @@ async def check_if_exists(url):
dbname = env.get_module_dbname('iptv') dbname = env.get_module_dbname('iptv')
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
sql = "select * from iptvchannles where url = ${url}$" sql = "select * from iptvchannels where url = ${url}$"
recs = await sor.sqlExe(sql, {'url': url}) recs = await sor.sqlExe(sql, {'url': url})
if len(recs) > 0: if len(recs) > 0:
return True return True
@ -63,7 +65,7 @@ async def write_goodchannel(b):
'0' '0'
)""" )"""
query = """select * from iptvchannels where url=${url}$""" query = """select * from iptvchannels where url=${url}$"""
q = await sor.sqlExe(query,{'url', b['url']}) q = await sor.sqlExe(query,{'url': b['url']})
if len(q) == 0: if len(q) == 0:
r = copy(b) r = copy(b)
r['media_type'] = 'iptv' r['media_type'] = 'iptv'
@ -84,9 +86,9 @@ async def write_goodchannel(b):
async def load_url_iptv(url): async def load_url_iptv(url):
clist = await download(url) clist = await download(url)
debug(f'clist={clist}')
newchannels = [] newchannels = []
for c in clist: for c in clist:
c = DictObject(**c)
b = await check_if_exists(c.url) b = await check_if_exists(c.url)
if not b: if not b:
newchannels.append(c) newchannels.append(c)