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

View File

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

View File

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