diff --git a/iptv/downloadchannels.py b/iptv/downloadchannels.py index e2c0f98..d66e1cd 100644 --- a/iptv/downloadchannels.py +++ b/iptv/downloadchannels.py @@ -36,7 +36,7 @@ async def check_if_exists(url): return True return False -async def write_goodchannel(b): +async def write_badchannel(b): debug(f'write badchannels({b.url})') env = ServerEnv() dbname = env.get_module_dbname('iptv') @@ -62,6 +62,57 @@ async def write_goodchannel(b): ${url}$, ${media_type}$, ${download_date}$, + '1' + )""" + r = b.copy() + r['media_type'] = 'iptv' + r['id'] = getID() + if not r.get('tv_group'): + r['tv_group'] = r.get('group-title','')[:500] + if not r.get('tv_name'): + r['tv_name'] = r.get('name','')[:500] + if not r.get('logo_url'): + r['logo_url'] = r.get('tvg-logo',None) + if r['logo_url'] and len(r['logo_url']) > 1000: + r['logo_url'] = None + if len(r['url']) >= 1000: + return + dt = datetime.now() + r['download_date'] = '%d-%02d-%02d' % (dt.year,dt.month,dt.day) + await sor.sqlExe(sql,r) + await sor.C('badchannels', { + 'id': getID(), + 'channelid': r['id'] + }) + +async def write_goodchannel(b): + debug(f'write goodchannels({b.url})') + env = ServerEnv() + dbname = env.get_module_dbname('iptv') + db = DBPools() + async with db.sqlorContext(dbname) as sor: + sql = """insert into iptvchannels + ( + id, + tv_group, + tv_name, + logo_url, + url, + media_type, + channel_delay, + download_date, + del_flg + ) + values + ( + ${id}$, + ${tv_group}$, + ${tv_name}$, + ${logo_url}$, + ${url}$, + ${media_type}$, + ${channel_delay}$, + ${download_date}$, '0' )""" query = """select * from iptvchannels where url=${url}$""" @@ -95,7 +146,9 @@ async def load_url_iptv(url): if len(newchannels) > 0: debug('%d new channels' % len(newchannels)) - good, bad = await test_channels(newchannels, if_ok=write_goodchannel) + good, bad = await test_channels(newchannels, + if_failed=write_badchannel, + if_ok=write_goodchannel) debug(f'{len(good)} new channels add {len(bad)} channels exists') else: debug(f'{url} return None') diff --git a/wwwroot/channelinfo.ui b/wwwroot/channelinfo.ui deleted file mode 100644 index 8fa20e8..0000000 --- a/wwwroot/channelinfo.ui +++ /dev/null @@ -1,43 +0,0 @@ -{ - "widgettype":"HBox", - "options":{ - "cwidth":22, - "cheight":3 - }, - "subwidgets":[ - { - "widgettype":"Image", - "options":{ - "cwidth":1.5, - "cheight":1,5, - "url":"{{params_kw.logo_url}}", - "default_url":"{{entire_url('/imgs/tv.png')}}" - } - }, - { - "widgettype":"Title6", - "options":"{ - "css":"filler", - "text":"{{params_kw.tv_name}}", - "wrap":true, - "halign":"left" - } - } - ] - "binds":[ - { - "wid":"self", - "event":"click", - "actiontype":"urlwidgt", - "target":"PopupWindow", - "popup_options":{ - }, - "options":{ - "params":{ - "id":"{{params_kw.id}}" - }, - "url":"{{params_kw.click_url or entire_url('play.ui')}}" - } - } - ] -} diff --git a/wwwroot/channels.ui b/wwwroot/channels.ui deleted file mode 100644 index 2c08c29..0000000 --- a/wwwroot/channels.ui +++ /dev/null @@ -1,56 +0,0 @@ -{ - "id":"channel_list", - "widgettype":"Tabular", - "options":{ - "data_url":"{{entire_url('/api/channels.dspy')}}", - "noheader":true, - "row_options":{ - "fields":[ - { - "name":"logo_url", - "cwidth":2, - "cheight":2, - "uitype":"icon", - "label":"Icon", - "value":"${logo_url}" - }, - { - "name":"tv_name", - "uitype":"str", - "lable":"Channel", - "cwidth":50, - "value":"${tv_name}" - } - ], - "alters":{ - "logo_url":{ - "cwidth":2.5 - }, - "tv_name":{ - "cwidth":20 - } - }, - "cheight":2.5, - "width":"100%" - }, - "page_rows":80, - "cache_limit":5 - }, - "binds":[ - { - "wid":"self", - "event":"row_selected", - "actiontype":"urlwidget", - "target":"PopupWindow", - "popup_options":{ - "archor":"cc", - "width":"90%", - "height":"90%" - }, - "options":{ - "url":"{{entire_url('play.ui')}}", - "params":{} - } - } - ] -} diff --git a/wwwroot/index.dspy b/wwwroot/index.dspy deleted file mode 100644 index d5b7674..0000000 --- a/wwwroot/index.dspy +++ /dev/null @@ -1 +0,0 @@ -return "noting in here" diff --git a/wwwroot/index.old.ui b/wwwroot/index.old.ui deleted file mode 100644 index b84f7c3..0000000 --- a/wwwroot/index.old.ui +++ /dev/null @@ -1,34 +0,0 @@ -{ - "widgettype":"VBox", - "options":{ - "width":"100%", - "height":"100%" - }, - "subwidgets":[ - { - "widgettype":"urlwidget", - "options":{ - "url":"{{entire_url('header.ui')}}" - } - }, - { - "id":"center", - "widgettype":"Filler", - "options":{}, - "subwidgets":[ - { - "widgettype":"urlwidget", - "options":{ - "url":"{{entire_url('iptv.ui')}}" - } - } - ] - }, - { - "widgettype":"urlwidget", - "options":{ - "url":"{{entire_url('bottom.ui')}}" - } - } - ] -} diff --git a/wwwroot/newest/.index.ui.swp b/wwwroot/newest/.index.ui.swp deleted file mode 100644 index b01cbce..0000000 Binary files a/wwwroot/newest/.index.ui.swp and /dev/null differ diff --git a/wwwroot/play_with_channelid.ui b/wwwroot/play_with_channelid.ui deleted file mode 100644 index ba69348..0000000 --- a/wwwroot/play_with_channelid.ui +++ /dev/null @@ -1,11 +0,0 @@ -{% set d = get_channel_by_id(id) %} -{ - "id":"myplayer", - "widgettype":"Video", - "options":{ - "channel_id":"{{d.id}}", - "title":"{{d.tv_name}}" - "type":"application/x-mpegURL", - "url":"{{d.url}}" - } -} diff --git a/wwwroot/sysmenu.ui b/wwwroot/sysmenu.ui index 7dacc4d..a52f962 100644 --- a/wwwroot/sysmenu.ui +++ b/wwwroot/sysmenu.ui @@ -28,7 +28,7 @@ "label":"搜索频道", "url":"{{entire_url('iptvchannels.ui')}}" }, -{% if params_kw._is_mobile != '1' %} +{% if int(params_kw._is_mobile) == 0 %} { "name":"tv_mode", "label":"电视模式", diff --git a/wwwroot/tabs.ui b/wwwroot/tabs.ui new file mode 100644 index 0000000..e9de676 --- /dev/null +++ b/wwwroot/tabs.ui @@ -0,0 +1,46 @@ +{ + "widgettype":"IconbarPage", + "options":{ + "bar_at": "top", + "bar_opts":{ + "margin": "10px", + "rate":1.5, + "tools":[ + { + "name":"channelsearch", + "icon":"{{entire_url('/imgs/channelsearch.svg')}}", + "tip":"Search Channel by enter channel name", + "dynsize": true, + "content":{ + "widgettype":"urlwidget", + "options":{ + "url":"{{entire_url('searchchannels')}}" + } + } + },{ + "name":"newestchannels", + "icon":"{{entire_url('/imgs/newestchannels.svg')}}", + "tip":"show newest channels", + "dynsize": true, + "content":{ + "widgettype":"urlwidget", + "options":{ + "url":"{{entire_url('newest')}}" + } + } + }, { + "name":"declare", + "icon":"{{entire_url('/imgs/declare.svg')}}", + "tip":"show declaration", + "dynsize": true, + "content":{ + "widgettype":"urlwidget", + "options":{ + "url":"{{entire_url('declare.ui')}}" + } + } + } + ] + } + } +}