Best Python code snippet using fMBT_python
hostlaola1tv.py
Source:hostlaola1tv.py  
1# -*- coding: utf-8 -*-2###################################################3# LOCAL import4###################################################5from Plugins.Extensions.IPTVPlayer.components.iptvplayerinit import TranslateTXT as _, SetIPTVPlayerLastHostError6from Plugins.Extensions.IPTVPlayer.components.ihost import CHostBase, CBaseHostClass, CDisplayListItem, RetHost, CUrlItem, ArticleContent7from Plugins.Extensions.IPTVPlayer.tools.iptvtools import printDBG, printExc, CSearchHistoryHelper, remove_html_markup, GetLogoDir, GetCookieDir, byteify, CSelOneLink8from Plugins.Extensions.IPTVPlayer.libs.pCommon import common, CParsingHelper9import Plugins.Extensions.IPTVPlayer.libs.urlparser as urlparser10from Plugins.Extensions.IPTVPlayer.tools.iptvtypes import strwithmeta11from Plugins.Extensions.IPTVPlayer.libs.urlparserhelper import getDirectM3U8Playlist, getF4MLinksWithMeta12###################################################13###################################################14# FOREIGN import15###################################################16import datetime17import random18import time19import re20import urllib21import base6422try:    import json23except Exception: import simplejson as json24from Components.config import config, ConfigSelection, ConfigYesNo, ConfigText, getConfigListEntry25###################################################26###################################################27# E2 GUI COMMPONENTS 28###################################################29from Plugins.Extensions.IPTVPlayer.components.asynccall import MainSessionWrapper30from Screens.MessageBox import MessageBox31###################################################32###################################################33# Config options for HOST34###################################################35config.plugins.iptvplayer.laola1tv_defquality  = ConfigSelection(default = "1000000", choices = [("0", _("The worst")), ("500000", _("Low")), ("1000000", _("Mid")), ("1500000", _("High")), ("9000000", _("The best"))]) 36config.plugins.iptvplayer.laola1tv_onelink     = ConfigYesNo(default = False)37config.plugins.iptvplayer.laola1tv_portal      = ConfigSelection(default = "int", choices = [("at", "AT"), ("de", "DE"), ("int", "INT")]) 38config.plugins.iptvplayer.laola1tv_language    = ConfigSelection(default = "en", choices = [("en", _("English")), ("de", _("Deutsch"))]) 39config.plugins.iptvplayer.laola1tv_myip1       = ConfigText(default = "146.0.32.8", fixed_size = False)40config.plugins.iptvplayer.laola1tv_myip2       = ConfigText(default = "85.128.142.29", fixed_size = False)41def GetConfigList():42    optionList = []43    optionList.append(getConfigListEntry(_("Video default quality:"), config.plugins.iptvplayer.laola1tv_defquality))44    optionList.append(getConfigListEntry(_("Use default quality:"), config.plugins.iptvplayer.laola1tv_onelink))45    optionList.append(getConfigListEntry(_("Portal:"), config.plugins.iptvplayer.laola1tv_portal))46    optionList.append(getConfigListEntry(_("Language:"), config.plugins.iptvplayer.laola1tv_language))47    optionList.append(getConfigListEntry(_("Alternative geolocation IP 1:"), config.plugins.iptvplayer.laola1tv_myip1))48    optionList.append(getConfigListEntry(_("Alternative geolocation IP 2:"), config.plugins.iptvplayer.laola1tv_myip2))49    return optionList50###################################################51def gettytul():52    return 'laola1.tv'53class Laola1TV(CBaseHostClass):54    HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'}55    MAIN_URL    = 'http://laola1.tv/'56    57    #'http://www.laola1.tv/img/laola1_logo.png'58    MAIN_CAT_TAB = [{'category':'search',             'title': _('Search'), 'search_item':True},59                    {'category':'search_history',     'title': _('Search history')} ]60    61    def __init__(self):62        CBaseHostClass.__init__(self, {'history':'Laola1TV', 'cookie':'Laola1TV.cookie'})63        self.mainCache = {}64        65    def _getFullUrl(self, url, baseUrl=None):66        if baseUrl == None:67            baseUrl = self.MAIN_URL68        if url.startswith('//'):69            url = 'http:' + url70        elif 0 < len(url) and not url.startswith('http'):71            if url.startswith('/'):72                url = url[1:]73            url =  baseUrl + url74        75        if baseUrl.startswith('https://'):76            url = url.replace('https://', 'http://')77        return url78    def getPage(self, url, params={}, post_data=None):79        return self.cm.getPage(url, params, post_data)80        81    def getMainUrl(self):82        return (self.MAIN_URL + '{language}-{portal}/').format(language=config.plugins.iptvplayer.laola1tv_language.value, portal=config.plugins.iptvplayer.laola1tv_portal.value)83    def listsTab(self, tab, cItem, type=''):84        printDBG("Laola1TV.listsTab")85        for item in tab:86            params = dict(cItem)87            params.update(item)88            params['name']  = 'category'89            if type == '':90                type = item['category']91            if type == 'video':92                self.addVideo(params)93            else: 94                self.addDir(params)95                96    def listFromCache(self, cItem, key=None):97        if 'cache_key' in cItem:98            key = cItem['cache_key']99        printDBG('Laola1TV.listFromCache key[%s]' % key)100        101        tab = self.mainCache.get(key, [])102        for item in tab:103            params = dict(cItem)104            params.update(item)105            self.addDir(params)106            107    def listMainMenu(self, cItem):108        printDBG('Laola1TV.listMainMenu')109        sts, data = self.getPage( self.getMainUrl() + 'home/' )110        if not sts: return111        112        # live113        liveUrl = self.cm.ph.getSearchGroups(data, '<a href="([^"]+?)" class="live">')[0]114        liveTitle = self.cm.ph.getDataBeetwenMarkers(data, 'class="live">', '</a>', False)[1]115        params = dict(cItem)116        params.update({'category':'calendar', 'title':self.cleanHtmlStr(liveTitle), 'url':self._getFullUrl( liveUrl )})117        self.addDir(params)118        119        data = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="level1">', '</div>', False)[1]120        data = data.split('<li class="active">')121        if len(data): del data[0]122        123        def _getLastItems(data, baseItem):124            retTab = []125            data = data.split('</a>')126            if len(data): del data[-1]127            for item in data:128                params = dict(baseItem)129                url   = self.cm.ph.getSearchGroups(item, 'href="([^"]+?)"')[0]130                title = self.cleanHtmlStr(item)131                params.update({'url':self._getFullUrl( url ), 'title':title})132                retTab.append(params)133            return retTab134                135        self.mainCache = {}136        self.mainCache['level_1'] = []137        for itemL1 in data:138            dataL2 = itemL1.split('<ul class="level2">')139            if 1 == len(dataL2):140                subItems = _getLastItems(itemL1, {'category':'explore_page', 'level':'1'})141                self.mainCache['level_1'].extend( subItems )142            elif 1 < len(dataL2):143                titleL2 = self.cleanHtmlStr(dataL2[0])144                cacheKey2 = 'level_2_%s' % titleL2145                self.mainCache[cacheKey2] = []146                            147                del dataL2[0]148                for itemL2 in dataL2:149                    if '<ul class="level3">' in itemL2:150                        dataL3 = itemL2.split('<span class="level2point">') #'<ul class="level3">')151                    else:152                        dataL3 = [itemL2]153                    if 1 == len(dataL3):154                        subItems = _getLastItems(itemL2, {'category':'explore_page', 'level':'2'})155                        self.mainCache[cacheKey2].extend( subItems )156                        self.mainCache['level_1'].append({'title':titleL2, 'category':'list_cache_cat', 'cache_key':cacheKey2, 'level':'2'})157                    elif 1 < len(dataL3):158                        for itemL3 in dataL3:159                            tmp = itemL3.split('<ul class="level3">')160                            if 2 != len(tmp): continue161                            titleL3 = self.cleanHtmlStr(tmp[0])162                            cacheKey3 = 'level_3_%s_%s' % (titleL2, titleL3)163                            subItems = _getLastItems(tmp[1], {'category':'explore_page', 'level':'3'})164                            self.mainCache[cacheKey2].append({'title':titleL3, 'category':'list_cache_cat', 'cache_key':cacheKey3, 'level':'3'})165                            self.mainCache[cacheKey3] = subItems166                        self.mainCache['level_1'].append({'title':titleL2, 'category':'list_cache_cat', 'cache_key':cacheKey2, 'level':'2'})167        168        self.listFromCache(cItem, 'level_1')169        170    def explorePage(self, cItem):171        printDBG("Laola1TV.explorePage")172        sts, data = self.getPage( cItem['url'] )173        if not sts: return174        175        m1 = '<div class="teaser-title'176        data = self.cm.ph.getDataBeetwenMarkers(data, m1, '</section>', False)[1]177        data = data.split(m1)178        179        for item in data:180            tmp = item.split('<div class="teaser-list"')181            if 2 != len(tmp): continue182            url   = self.cm.ph.getSearchGroups(tmp[0], 'href="([^"]+?)"')[0]183            icon  = self.cm.ph.getSearchGroups(tmp[0], 'src="([^"]+?)"')[0]184            title = self.cm.ph.getDataBeetwenMarkers(tmp[0], '<h2>', '</h2>', False)[1]185            desc  = self.cm.ph.getDataBeetwenMarkers(tmp[0], '<p>', '</p>', False)[1]186            if url != '':187                params = dict(cItem)188                params.update({'category':'videos_list', 'url':self._getFullUrl( url ), 'title':self.cleanHtmlStr( title ), 'icon':self._getFullUrl( icon ), 'desc':self.cleanHtmlStr( desc )})189                self.addDir( params )190        191    def listCalendary(self, cItem):192        printDBG("Laola1TV.listCalendary")193        sts, data = self.getPage(cItem['url'])194        if not sts: return 195        196        data = self.cm.ph.getDataBeetwenReMarkers(data, re.compile('<ul class="list list-day day-[^"]+?" style="display:none;">'), re.compile('<ul class="list list-day day-[^"]+?" style="display:none;">'))[1]197        data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<li class="item list-sport', '</li>')198        for item in data:199            tmp   = item.split('<div class="badge">')200            title = self.cleanHtmlStr( tmp[0] )201            icon  = self._getFullUrl( self.cm.ph.getSearchGroups(tmp[0], 'src="([^"]+?)"')[0] )202            url   = self._getFullUrl( self.cm.ph.getSearchGroups(tmp[0], 'href="([^"]+?)"')[0] )203            desc  = self.cleanHtmlStr( tmp[1] )204            params = dict(cItem)205            params.update({'title':title, 'url':url, 'desc': desc, 'icon':icon})206            self.addVideo(params)207    def listVideos(self, cItem):208        printDBG("Laola1TV.listVideos")209        page = cItem.get('page', 1)210        url  = cItem['url']211        if url.startswith('/'):212            url = url[1:]213        if page > 1:214            url += '/%s' % page215        216        sts, data = self.getPage(url)217        if not sts: return 218        219        nextPage = self.cm.ph.getDataBeetwenMarkers(data, 'class="paging"', '<p>', False)[1]220        if ('/%s"' % (page +1)) in nextPage:221            nextPage = True222        else: nextPage = False223        224        data = self.cm.ph.getDataBeetwenMarkers(data, '<div class="teaser-list">', '</section>', False)[1]225        data = data.split('</a>')226        if len(data): del data[-1]227        for item in data:228            if '"ico-play"' not in item: continue229            url   = self.cm.ph.getSearchGroups(item, 'href="([^"]+?)"')[0]230            icon  = self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0]231            title = self.cm.ph.getDataBeetwenMarkers(item, '<p>', '</p>', False)[1]232            desc  = item.split('</p>')[-1]233            if url != '':234                params = {'category':'videos_list', 'url':self._getFullUrl( url ), 'title':self.cleanHtmlStr( title ), 'icon':self._getFullUrl( icon ), 'desc':self.cleanHtmlStr( desc )}235                self.addVideo( params )236        237        if nextPage:238            params = dict(cItem)239            params.update({'title':_("Next page"), 'page':page+1})240            self.addDir(params)241        242    def listSearchResult(self, cItem, searchPattern, searchType):243        printDBG("Laola1TV.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]" % (cItem, searchPattern, searchType))244        245        # this looks strange but live attrib is returned for not live stream 246        # for me this is server bug247        searchLive = '1'248        if searchType == 'live':249            searchLive = ''250        251        page = cItem.get('page', 1)252        url = 'http://search-api.laola1.at/?callback=ret&q=%s&p=%d&i=laola1tv-2015-int&include=[]&_=%s' % (urllib.quote_plus(searchPattern), page, str(time.time()))253        sts, data = self.getPage(url)254        if not sts: return255        try:256            data = data.strip()[4:-2]257            data = byteify(json.loads(data))['result']258            259            pagesize = int(self.cm.ph.getSearchGroups(data, 'pagesize="([0-9]+?)"')[0])260            total = int(self.cm.ph.getSearchGroups(data, 'total="([0-9]+?)"')[0])261            data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<result id=', '</result>')262            263            def _getText(data, name):264                return self.cm.ph.getDataBeetwenMarkers(data, '<%s>' % name, '</%s>' % name, False)[1]265            266            for item in data:267                def _getText(name):268                    return self.cm.ph.getDataBeetwenMarkers(item, '<%s>' % name, '</%s>' % name, False)[1]269                live     = _getText('live')270                if searchLive != live: continue271                title    = self.cleanHtmlStr( _getText('title') )272                icon     = self._getFullUrl( _getText('pic') )273                url      = self._getFullUrl( _getText('url') )274                text     = self.cleanHtmlStr( _getText('text') )275                rubric   = self.cleanHtmlStr( _getText('rubric') )276                datetime = self.cleanHtmlStr( _getText('datetime') )277                278                desc  = ' \n'.join( [datetime, rubric, text] )279                params = dict(cItem)280                params.update({'title':title, 'url':url, 'desc': desc, 'icon':icon})281                self.addVideo(params)282            283            if (page * pagesize) < total:284                params = dict(cItem)285                params.update({'title':_("Next page"), 'page':page+1})286                self.addDir(params) 287        except Exception:288            printExc()289        290    def getLinksForVideo(self, cItem):291        printDBG("Laola1TV.getLinksForVideo [%s]" % cItem)292        urlTab = []293        baseUrl = cItem['url']294        try:295            sts, response = self.cm.getPage(baseUrl, {'return_data':False})296            baseUrl = response.geturl()297            data = response.read().strip()298            response.close()299        except Exception:300            printExc()301            return []302        303        vidUrl = self.cm.ph.getSearchGroups(data, '<iframe[^>]+?src="([^"]+?)"')[0]304        305        if '' == vidUrl:306            error = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(data, '<div class="videoplayer-overlay">', '</p>', False)[1] )307            if '' != error: SetIPTVPlayerLastHostError(error)308            return []309        310        baseUrl = baseUrl[baseUrl.find('://')+3:]311        baseUrl = 'http://' + baseUrl[0:baseUrl.find('/')] + '/'312        313        314        vidUrl = self._getFullUrl( vidUrl, baseUrl )315        316        sts, data = self.getPage(vidUrl)317        if not sts: return []318        319        mainAuth = self.cm.ph.getSearchGroups(data, '[ .]auth = "([^"]+?)"')[0]320        mainTimestamp = self.cm.ph.getSearchGroups(data, '[ .]timestamp = "([^"]+?)"')[0]321        vs_target = self.cm.ph.getSearchGroups(data, 'var vs_target = ([0-9]+?);')[0]322        data = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(data, 'var flashvars', '};', False)[1] )323        def _getParamValue(paramName, data):324            return self.cm.ph.getSearchGroups(data, '%s: "([^"]+?)"' % paramName)[0]325            326        streamid  = _getParamValue('streamid', data)327        partnerid = _getParamValue('partnerid', data)328        portalid  = _getParamValue('portalid', data)329        sprache   = _getParamValue('sprache', data)330        vidUrl = "http://www.laola1.tv/server/hd_video.php?play=%s&partner=%s&portal=%s&v5ident&lang=%s&v=1" % (streamid, partnerid, portalid, sprache)331        332        sts, data = self.getPage(vidUrl)333        if not sts: return []334        335        vidUrl = self.cm.ph.getDataBeetwenMarkers(data, '<url>', '</url>', False)[1].replace('&', '&')336        fallbackVidUrl = self.cm.ph.getDataBeetwenMarkers(data, '<fallbackurl>', '</fallbackurl>', False)[1].replace('&', '&')337        id      = self.cm.ph.getDataBeetwenMarkers(data, '<id>', '</id>', False)[1]338        area    = self.cm.ph.getDataBeetwenMarkers(data, '<area>', '</area>', False)[1]339        label   = self.cm.ph.getDataBeetwenMarkers(data, '<label>', '</label>', False)[1]340        req_abo = self.cm.ph.getDataBeetwenMarkers(data, '<req_liga_abos>', '</req_liga_abos>', False)[1].split(',')341        live    = self.cm.ph.getDataBeetwenMarkers(data, '<live>', '</live>', False)[1]342        if live == 'false': isLive = False343        else: isLive = True344        ######################################################345        streamaccessTab = []346        url = 'https://club.laola1.tv/sp/laola1/api/v3/user/session/premium/player/stream-access?videoId=' + id + '&target=' + vs_target + '&label=' + label + '&area=' + area + '&format=iphone'347        post_data = {}348        for idx in range(len(req_abo)):349            post_data[idx] = req_abo[idx]350        sts, data = self.getPage(url, {}, post_data)351        try:352            data = byteify(json.loads(data))353            for item in data['data']['stream-access']:354                streamaccessTab.append(item)355        except Exception:356            printExc()357        358        if 0 == len(streamaccessTab):359            def addZ(n):360                if n < 10: return '0%d' % n361                return str(n)362            363            def getTimestamp():364                date = datetime.datetime.now()365                year  = date.year366                month = date.month367                datum = date.day368                hour  = date.hour369                min   = date.minute370                sec   = date.second371                timestamp = addZ(year) + addZ(month) + addZ(datum) + addZ(hour) + addZ(min) + addZ(sec)372                return timestamp373            randomNumber = str(random.randint(10000000, 99999999))374            htmlTimestamp = str(time.time()).split('.')[0]375            ident = randomNumber + htmlTimestamp376            timestamp = mainTimestamp377            if '' == timestamp:378                timestamp = getTimestamp()379            380            for baseUrl in [vidUrl, fallbackVidUrl]:381                streamaccessTab.append(baseUrl + '&ident=' + ident + '&klub=0&unikey=0×tamp=' + timestamp + '&auth=' + mainAuth + '&format=iphone');382        383        for streamaccess in streamaccessTab:384            for myip in ['', config.plugins.iptvplayer.laola1tv_myip1.value, config.plugins.iptvplayer.laola1tv_myip2.value]:385                if '' != myip: header = {'X-Forwarded-For':myip}386                else: header = {}387                sts, data = self.getPage(streamaccess, {'header':header})388                if not sts: return urlTab389                data = self.cm.ph.getDataBeetwenMarkers(data, '<data>', '</data>', False)[1]390                printDBG(data)391                comment = self.cm.ph.getSearchGroups(data, 'comment="([^"]+?)"')[0]392                auth = self.cm.ph.getSearchGroups(data, 'auth="([^"]+?)"')[0]393                if auth in ['restricted', 'blocked']: continue394                url  = self.cm.ph.getSearchGroups(data, 'url="([^"]+?)"')[0]395                url = url + '?hdnea=' + auth396                397                if myip != '':398                    url = strwithmeta(url, {'X-Forwarded-For':myip})399                tmp = getDirectM3U8Playlist(url, checkExt=False)400                for item in tmp:401                    item['need_resolve'] = 0402                    urlTab.append(item)403                break404            if 0 < len(urlTab):405                break406            407        if 0 < len(urlTab):408            max_bitrate = int(config.plugins.iptvplayer.laola1tv_defquality.value)409            def __getLinkQuality( itemLink ):410                try:411                    value = itemLink['bitrate']412                    return int(value)413                except Exception:414                    printExc()415                    return 0416            urlTab = CSelOneLink(urlTab, __getLinkQuality, max_bitrate).getSortedLinks()417            if config.plugins.iptvplayer.laola1tv_onelink.value:418                urlTab = [urlTab[0]] 419        else:420            SetIPTVPlayerLastHostError(comment)421                422        return urlTab423    424    def getVideoLinks(self, baseUrl):425        printDBG("Movie4kTO.getVideoLinks [%s]" % baseUrl)426        urlTab = []427        if '' != baseUrl: 428            videoUrl = baseUrl429            urlTab = self.up.getVideoLinkExt(videoUrl)430        return urlTab431        432    def getFavouriteData(self, cItem):433        return cItem['url']434        435    def getLinksForFavourite(self, fav_data):436        return self.getLinksForVideo({'url':fav_data})437    def handleService(self, index, refresh = 0, searchPattern = '', searchType = ''):438        printDBG('handleService start')439        440        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)441        name     = self.currItem.get("name", '')442        category = self.currItem.get("category", '')443        printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category) )444        self.currList = []445        446    #MAIN MENU447        if name == None:448            self.listMainMenu({'name':'category'})449            self.listsTab(self.MAIN_CAT_TAB, {'name':'category'}, 'dir')450        elif category == 'list_cache_cat':451            self.listFromCache(self.currItem)452        elif category == 'explore_page':453            self.explorePage(self.currItem)454        elif category == 'videos_list':455            self.listVideos(self.currItem)456        elif category == 'calendar':    457            self.listCalendary(self.currItem)458    #SEARCH459        elif category in ["search", "search_next_page"]:460            cItem = dict(self.currItem)461            cItem.update({'search_item':False, 'name':'category'}) 462            self.listSearchResult(cItem, searchPattern, searchType)463    #HISTORIA SEARCH464        elif category == "search_history":465            self.listsHistory({'name':'history', 'category': 'search'}, 'desc', _("Type: "))466        else:467            printExc()468        469        CBaseHostClass.endHandleService(self, index, refresh)470class IPTVHost(CHostBase):471    def __init__(self):472        CHostBase.__init__(self, Laola1TV(), True, [CDisplayListItem.TYPE_VIDEO, CDisplayListItem.TYPE_AUDIO])473    def getLogoPath(self):474        return RetHost(RetHost.OK, value = [GetLogoDir('laola1tvlogo.png')])475    476    def getLinksForVideo(self, Index = 0, selItem = None):477        retCode = RetHost.ERROR478        retlist = []479        if not self.isValidIndex(Index): return RetHost(retCode, value=retlist)480        481        urlList = self.host.getLinksForVideo(self.host.currList[Index])482        for item in urlList:483            retlist.append(CUrlItem(item["name"], item["url"], item["need_resolve"]))484        return RetHost(RetHost.OK, value = retlist)485    # end getLinksForVideo486    487    def getResolvedURL(self, url):488        # resolve url to get direct url to video file489        retlist = []490        urlList = self.host.getVideoLinks(url)491        for item in urlList:492            need_resolve = 0493            retlist.append(CUrlItem(item["name"], item["url"], need_resolve))494        return RetHost(RetHost.OK, value = retlist)495    496    def converItem(self, cItem):497        hostList = []498        searchTypesOptions = [] # ustawione alfabetycznie499        searchTypesOptions.append((_("Live-streams"), "live"))500        searchTypesOptions.append((_("Videos"), "videos"))501    502        hostLinks = []503        type = CDisplayListItem.TYPE_UNKNOWN504        possibleTypesOfSearch = None505        if 'category' == cItem['type']:506            if cItem.get('search_item', False):507                type = CDisplayListItem.TYPE_SEARCH508                possibleTypesOfSearch = searchTypesOptions509            else:510                type = CDisplayListItem.TYPE_CATEGORY511        elif cItem['type'] == 'video':512            type = CDisplayListItem.TYPE_VIDEO513        elif 'more' == cItem['type']:514            type = CDisplayListItem.TYPE_MORE515        elif 'audio' == cItem['type']:516            type = CDisplayListItem.TYPE_AUDIO517            518        if type in [CDisplayListItem.TYPE_AUDIO, CDisplayListItem.TYPE_VIDEO]:519            url = cItem.get('url', '')520            if '' != url:521                hostLinks.append(CUrlItem("Link", url, 1))522            523        title       =  cItem.get('title', '')524        description =  cItem.get('desc', '')525        icon        =  cItem.get('icon', '')526        527        return CDisplayListItem(name = title,528                                    description = description,529                                    type = type,530                                    urlItems = hostLinks,531                                    urlSeparateRequest = 1,532                                    iconimage = icon,533                                    possibleTypesOfSearch = possibleTypesOfSearch)534    # end converItem535    def getSearchItemInx(self):536        try:537            list = self.host.getCurrList()538            for i in range( len(list) ):539                if list[i]['category'] == 'search':540                    return i541        except Exception:542            printDBG('getSearchItemInx EXCEPTION')543            return -1544    def setSearchPattern(self):545        try:546            list = self.host.getCurrList()547            if 'history' == list[self.currIndex]['name']:548                pattern = list[self.currIndex]['title']549                search_type = list[self.currIndex]['search_type']550                self.host.history.addHistoryItem( pattern, search_type)551                self.searchPattern = pattern552                self.searchType = search_type553        except Exception:554            printDBG('setSearchPattern EXCEPTION')555            self.searchPattern = ''556            self.searchType = ''...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
