def _channelitem(x, category, channel, res, chan_current, room_id=False, device_id=False, user=False): # html = '' # try: channo = channel[res]['devicekeys'][get_cfg_device_type(room_id, device_id)] except: channo = False # # If current channel, create element class text for highlighting if bool(chan_current) and channo == chan_current: chan_highlight = 'chan-highlight' else: chan_highlight = '' # # Create element id, including user name if required (user name prevents duplication of id names within page) chan_id = str(user).lower()+'_' if user else '' chan_id += category.replace(' ', '').lower() chan_id += channel['name'].replace(' ', '').lower() # if x > 1 and x % 6 == 0: html += '</div><div class="row">' # html += urlopen('web/html/html_tvguide/tvguide-grid_item.html').read().encode('utf-8').format(id=('chan' + str(channo)), chan_id=chan_id, cls_highlight=chan_highlight, imgchan=channel[res]['logo'], channame=channel['name'], room_id=room_id, device_id=device_id, channo=channo) # return html
def html_menu_lhs(): # html = '' # t = 0 # a_list = get_cfg_idlist_accounts() a_num = 0 # while a_num < len(a_list): # html += '<span class="sidebar_divider box-shadow"></span>' # label = get_cfg_account_name(a_list[a_num]) img = get_device_logo(get_cfg_account_type(a_list[a_num])) # html += urlopen('web/html/html_menu/menu_sidebar_item.html').read().encode('utf-8').format(href=('/web/account/{account_id}').format(account_id=a_list[a_num]), id='{account_id}'.format(account_id=a_list[a_num]), cls='', name=label, img=img) # t += 1 a_num += 1 # r_list = get_cfg_idlist_rooms() r_num = 0 # while r_num < len(r_list): d_list = get_cfg_idlist_devices(r_list[r_num]) d_num = 0 # html += '<span class="sidebar_divider box-shadow"></span>' # html += urlopen('web/html/html_menu/menu_sidebar_title.html').read().encode('utf-8').\ format(name=get_cfg_room_name(r_list[r_num])) # while d_num < len(d_list): # label = get_cfg_device_name(r_list[r_num], d_list[d_num]) img = get_device_logo(get_cfg_device_type(r_list[r_num], d_list[d_num])) # html += urlopen('web/html/html_menu/menu_sidebar_item.html').read().encode('utf-8').format(href=('/web/device/{room_id}/{device_id}').format(room_id=r_list[r_num], device_id=d_list[d_num]), id='{room_id}_{device_id}'.format(room_id=r_list[r_num], device_id=d_list[d_num]), cls='', name=label, img=img) d_num += 1 # r_num += 1 # return urlopen('web/html/html_menu/menu_lhs.html').read().encode('utf-8').format(menu=html)
def _create_device(room_id, device_id, q_dvc, queues): device_type = get_cfg_device_type(room_id, device_id) # if device_type=="tv_lg_netcast": device_tv_lg_netcast(room_id=room_id, device_id=device_id, q_dvc=q_dvc, queues=queues) elif device_type=="tivo": device_tivo(room_id=room_id, device_id=device_id, q_dvc=q_dvc, queues=queues)
def create_device_threads(q_devices, q_accounts, queues): # t = 0 thread = [] # r_list = get_cfg_idlist_rooms() r_num = 0 # while r_num < len(r_list): d_list = get_cfg_idlist_devices(r_list[r_num]) d_num = 0 # while d_num < len(d_list): # thread.append(threading.Thread(target=_create_device, args=(r_list[r_num], d_list[d_num], q_devices[r_num][d_num], queues))) thread[t].daemon = True thread[t].start() # print_msg('Thread created: {type}'.format(type=get_cfg_device_type(r_list[r_num], d_list[d_num])), dvc_or_acc_id=r_list[r_num]+':'+d_list[d_num]) # t += 1 d_num += 1 r_num += 1 # # a_list = get_cfg_idlist_accounts() a_num = 0 # while a_num < len(a_list): # thread.append(threading.Thread(target=_create_account, args=(a_list[a_num], q_accounts[a_num], queues))) thread[t].daemon = True thread[t].start() # print_msg('Thread created: {type}'.format(type=get_cfg_account_type(a_list[a_num])), dvc_or_acc_id=a_list[a_num]) # t += 1 a_num += 1 # x = 0 while x < t: thread[x].join()
def _listingsrow(x, channelitem, chan_current, room_id=False, device_id=False, res=False, user=False, last=False): # try: channo = channelitem.devicekeys(res, get_cfg_device_type(room_id, device_id)) except Exception as e: channo = False # now = '-' next = '-' blurb = '' chan_id = '' # try: if channelitem and channelitem.getListings(): for k, v in channelitem.getListings().items(): nownext = returnnownext(k, v) if nownext: now = '{} {}'.format(nownext[0]['starttime'], nownext[0]['title']) next = '{} {}'.format(nownext[1]['starttime'], nownext[1]['title']) for a in range(0, 5): if a > 0: blurb += '<br>' blurb += '<b>{start}-{end} {title}</b><br>{desc}<br>'.format(start=nownext[a]['starttime'], end=nownext[a]['endtime'], title=nownext[a]['title'], desc=nownext[a]['desc']) break except: now = '-' next = '-' # Create alternating row colours if x % 2 == 0: color = '#e8e8e8' else: color = '#ffffff' # If current channel, create element class text for highlighting if bool(chan_current) and channo == chan_current: chan_highlight = ' highlight' else: chan_highlight = '' # If last item, add class text to add bottom border to row if last: item_last = ' tbl_border' else: item_last = '' # If device can change channel, add 'go' button if room_id and device_id and channo: go = urlopen('web/html/html_tvguide/tvguide-row_go.html').read().encode('utf-8').format(room_id=room_id, device_id=device_id, channo=channo) else: go = '' # Create element id, including user name if required (user name prevents duplication of id names within page) if user: chan_id = str(user).lower()+'_' chan_id += channelitem.category().replace(' ', '').lower() chan_id += channelitem.name().replace(' ', '').lower() # if bool(res): logo = channelitem.logo(res) else: logo = channelitem.logo('hd') if not logo: logo = channelitem.logo('sd') # return urlopen('web/html/html_tvguide/tvguide-row.html').read().encode('utf-8').format(id=('chan' + str(channo)), chan_id=chan_id, cls_highlight=chan_highlight, cls_lastitem=item_last, color=color, imgtype=channelitem.type(), imgchan=logo, channame=channelitem.name(), now=now, next=next, blurb=blurb, go=go)