item[u'title'] = u' ' + item[u'title'] + u' '
            if item_rule.curr:
                reCurr = re.findall(item_rule.curr, data[point:], re.IGNORECASE + re.DOTALL + re.MULTILINE)
                if reCurr:
                    lock.append(item_rule.type)
                for infos_value in reCurr:
                    tmp = currBuilder(site, item_rule, lItem, site.start, infos_value = infos_value)
                    for item in rule_items:
                        if tmp[u'url'] == item[u'url']:
                            break
                    else:
                        rule_items.append(tmp)
            if rule_items:
                if item_rule.type.startswith(u'video'):
#                    start = time.clock()
                    addListItems(rule_items, item_rule.type, lItem)
#                    print('addListItems took = %s' % (time.clock() - start))
                else:
                    tmp_infos = lItem.copy()
                    tmp_infos[u'type'] = item_rule.type
                    for info in item_rule.info_list:
                        if info.name == u'title':
                            tmp_infos[u'title'] = info.build
                        elif info.name == u'icon':
                            tmp_infos[u'icon'] = info.build
                    items[item_rule.type] = (tmp_infos, [inheritInfos(item, lItem) for item in rule_items])
    return items

# Helper functions for loadRemote
def currBuilder(site, rule, lItem, url, match = None, infos_value = None):
    if infos_value == None:
 def run(self, lItem):
     #loadLocal
     start = time.clock()
     log(str(mode))
     if mode == u'START':
         localParser.load_links(lItem)
         totalItems = len(localParser.links)
         tmp = {
             u'title': u' All Sites',
             u'type': u'rss',
             u'director': u'VideoDevil',
             u'icon': os.path.join(imgDir, u'face_devil_grin.png'),
             u'url': u'sites.list'
         }
         addListItem(mode.selectLinkMode(inheritInfos(tmp, lItem)), totalItems)
         for link in localParser.links:
             addListItem(mode.selectLinkMode(link), totalItems)
     elif mode == u'VIEW_RSS' or mode == u'VIEW_SEARCH' or mode == u'VIEW_RSS_DIRECTORY':
         localParser.load_site(lItem)
         self.sort.extend(localParser.site.sort)
         remoteParser.main(((localParser.site, lItem),))
         type_dict = {}
         for type, infos, items in remoteParser.items.files():
             if type == u'next' or (mode == u'VIEW_RSS_DIRECTORY' and type == lItem[u'type']):
                 log('type added = %s(%d)' % (type,len(items)))
                 addListItems(items, type, lItem)
             else:
                 create_list_and_listItem(cacheDir, type, items, infos, lItem)
         for type, infos, items in localParser.site.links.files():
             if type not in remoteParser.items:
                 for item in items:
                     addListItem(mode.selectLinkMode(item), 0)
     elif mode == u'VIEW_DIRECTORY':
         localParser.load_links(lItem)
         totalItems = len(localParser.links)
         for link in localParser.links:
             addListItem(mode.selectLinkMode(link), totalItems)
     elif mode == u'VIEWALL_RSS' or mode == u'VIEWALL_SEARCH':
         localParser.load_links_and_sites_in_list(lItem)
         remoteParser.main(localParser.sites)
         for type, infos, items in remoteParser.items.files():
             if u'cfg' in infos:
                 del infos[u'cfg']
             if type == u'next':
                 create_list_and_listItem(cacheDir, type, items, infos, lItem)
                 infos[u'title'] = infos[u'title'].strip(u' ')
                 addListItem(infos, 0)
             elif not os.path.isfile(os.path.join(allsitesDir, type + u'.list')):
                 create_list_and_listItem(allsitesDir, type, items, infos, lItem)
             else:
                 create_listItem(allsitesDir, type, infos)
         if u'category' not in remoteParser.items:
             item = lItem.copy()
             item[u'title'] = u'  ' + __language__(30100) + u'  '
             item[u'type'] = u'category'
             item[u'director'] = u'VideoDevil'
             item[u'icon'] = os.path.join(imgDir, u'face_devil_grin.png')
             item[u'url'] = os.path.join(allsitesDir, u'category.list')
             addListItem(mode.selectLinkMode(item), 0)
         if not os.path.isfile(os.path.join(allsitesDir, u'search.list')):
             tmp_items = []
             for site, item in localParser.sites:
                 for type, infos, items in site.links.files():
                     if type == u'search':
                         tmp_items.extend(items)
             infos = tmp_items[0].copy()
             if u'cfg' in infos:
                 del infos[u'cfg']
             create_list_and_listItem(allsitesDir, u'search', tmp_items, infos, lItem)
         else:
             item = lItem.copy()
             item[u'title'] = u'  ' + __language__(30102) + u'  '
             item[u'type'] = u'search'
             item[u'director'] = u'VideoDevil'
             item[u'icon'] = os.path.join(imgDir, u'search.png')
             item[u'url'] = os.path.join(allsitesDir, u'search.list')
             addListItem(mode.selectLinkMode(item), 0)
     elif mode == u'VIEWALL_DIRECTORY':
         fileDir = os.path.join(allsitesDir, lItem[u'type'])
         if not os.path.isdir(fileDir):
             os.mkdir(fileDir)
         if not os.listdir(fileDir):
             localParser.load_links_and_sites_not_in_list(lItem)
             remoteParser.main(localParser.sites)
             for type, infos, items in remoteParser.items.files():
                 if u'cfg' in infos:
                     del infos[u'cfg']
                 if type == lItem[u'type']:
                     self.createDirs(items + localParser.links)
                     dir_items = create_lists_and_listItems(fileDir, self.links, lItem) 
                     if dir_items:
                         saveList(allsitesDir, lItem[u'type'] + u'.list', lItem[u'title'], dir_items)
             addon.setSetting(lItem[u'type'] + '_all_sites_cache', str(time.time()))
         else:
             localParser.load_links(lItem)
             totalItems = len(localParser.links)
             for link in localParser.links:
                 addListItem(mode.selectLinkMode(link), totalItems)
     for sort_method in self.sort:
         xbmcplugin.addSortMethod(handle = self.handle, sortMethod = sort_dict[sort_method])
     log('time elapsed = %s' % (time.clock() - start))
     return 0