diff --git a/iptv/downloadchannels.py b/iptv/downloadchannels.py index cb7800e..544112f 100644 --- a/iptv/downloadchannels.py +++ b/iptv/downloadchannels.py @@ -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') diff --git a/iptv/m3u8test.py b/iptv/m3u8test.py index 7f6f509..4a10c3c 100644 --- a/iptv/m3u8test.py +++ b/iptv/m3u8test.py @@ -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 diff --git a/wwwroot/test_channels.dspy b/wwwroot/test_channels.dspy new file mode 100644 index 0000000..2c79713 --- /dev/null +++ b/wwwroot/test_channels.dspy @@ -0,0 +1,2 @@ +await kickout_badchannels() +return 'ok'