This commit is contained in:
yumoqing 2025-09-20 11:57:23 +08:00
parent 4d149360a2
commit 09802bbbf9
3 changed files with 12 additions and 7 deletions

View File

@ -11,6 +11,7 @@ from appPublic.uniqueID import getID
from appPublic.log import debug
from sqlor.dbpools import DBPools
from iptv import m3u
from iptv.m3u8test import test_channels
async def download(url):
client = StreamHttpClient()
@ -46,6 +47,7 @@ values
${download_date}$,
'0'
)"""
dup = 0
query = """select * from iptvchannels where url=${url}$"""
async with pool.sqlorContext(dbname) as sor:
@ -70,9 +72,10 @@ values
async def load_url_iptv(media_type,url, dbname):
clist = await download(url)
if clist:
debug('%d channels' % len(clist))
await saveChannels(media_type,clist, dbname)
goodchannels, badchannels = test_channels(clist)
if goodchannels:
debug('%d channels' % len(goodchannels))
await saveChannels(media_type,goodchannels, dbname)
else:
debug(f'{url} return None')

View File

@ -1,5 +1,8 @@
from appPublic.log import debug, exception
from aiohttp import client, ClientConnectionError
from aiohttp import (
client
)
from ahserver.serverenv import ServerEnv
from sqlor.dbpools import DBPools
@ -11,9 +14,6 @@ async def test_channels(channels):
x = await client.get(c.url)
x.close()
goodchannels.append(c)
except ClientConnectionError as e:
c.error_code = 499
badchannels.append(c)
except Exception as e:
debug(f'{c.url}, {e}')
c.errorcode = x.status_code

View File

@ -0,0 +1,2 @@
await kickout_badchannels()
return 'ok'