Exemple #1
0
def searchHistory(name,url):

    searches = []
    mode,site = url.split('|SPLIT|')
    mode = int(mode)

    lst = [('New Search...',mode,'null','Search wankbank',True),('Clear History',15,'url',None,False), \
        ('Disable Search History',16,None,None,False),('################## Recent Searches #########################',999,'url',None,False)]

    conn = sqlite3.connect(searchdb)
    conn.text_factory = str
    c = conn.cursor()
    c.execute("SELECT * FROM terms ORDER BY ID DESC")

    for (id,got_term) in c.fetchall():
        lst += [(got_term,mode,'search_term='+got_term,got_term,True)]
    
    dirlst = []
    
    for i in lst:
        icon   = search_icon
        fanart = kodi.addonfanart
        dirlst.append({'name': kodi.giveColor(i[0],'white'), 'url': '%s|SPLIT|%s' % (i[2], site), 'mode': i[1], 'icon': icon, 'fanart': fanart, 'description': i[3], 'folder': i[4]})

    if dirlst: buildDirectory(dirlst)

    utils.setView('list')
 def get_next_page(self,
                   mode,
                   url,
                   pattern,
                   site='',
                   parse=None,
                   pictures=False):
     try:
         dirlst = []
         icon = translatePath(
             os.path.join('special://home/addons/script.xxxodus.artwork',
                          'resources/art/main/next.png'))
         fanart = translatePath(
             os.path.join('special://home/addons/script.xxxodus.artwork',
                          'resources/art/%s/fanart.jpg' % site))
         if '|GOT_URL' in url:
             url = url.split('|GOT_URL')[0]
             dirlst.append({
                 'name': kodi.giveColor('Next Page -->', 'white'),
                 'url': url,
                 'mode': mode,
                 'icon': icon,
                 'fanart': fanart,
                 'description': 'Load More......',
                 'folder': True
             })
         else:
             r = client.request(url)
             url2 = re.findall(r'%s' % pattern, r)[0]
             if parse:
                 url2 = urljoin(parse, url2)
             elif '&' in url2:
                 url2 = url2.replace('&', '&')
             elif 'mydirtyhobby' in url:
                 url2 = 'https://www.mydirtyhobby.com' + url2
             dirlst.append({
                 'name': kodi.giveColor('Next Page -->', 'white'),
                 'url': url2,
                 'mode': mode,
                 'icon': icon,
                 'fanart': fanart,
                 'description': 'Load More......',
                 'folder': True
             })
         if 'chaturbate' in url:
             if dirlst:
                 buildDirectory(dirlst, isVideo=True, chaturbate=True)
         elif pictures:
             if dirlst: buildDirectory(dirlst, pictures=True)
         else:
             if dirlst: buildDirectory(dirlst, isVideo=True)
     except Exception as e:
         log_utils.log(
             'Error getting next page for %s :: Error: %s' %
             (site.title(), str(e)), log_utils.LOGERROR)
         xbmcplugin.setContent(kodi.syshandle, 'movies')
         if 'chaturbate' in url: utils.setView('chaturbate')
         elif pictures: utils.setView('pictures')
         else: utils.setView('thumbs')
         xbmcplugin.endOfDirectory(kodi.syshandle, cacheToDisc=True)
Exemple #3
0
def mainSearch(url):
    
    if '|SPLIT|' in url: url,site = url.split('|SPLIT|')
    term = url
    if term == "null":  term = kodi.get_keyboard('Search %s' % kodi.get_name())

    if term:
        search_on_off  = kodi.get_setting("search_setting")
        if search_on_off == "true":
            delTerm(term)
            addTerm(term)

        display_term = term
        term = urllib.quote_plus(term)
        term = term.lower()

        if site=='all':
            sources = __all__ ; search_sources = []
            for i in sources:
                try:
                    if eval(i + ".search_tag") == 1: search_sources.append(i)
                except: pass

            if search_sources:
                i = 0
                source_num = 0
                failed_list = ''
                line1 = kodi.giveColor('Searching: ','white') + kodi.giveColor('%s','dodgerblue')
                line2 = kodi.giveColor('Found: %s videos','white')
                line3 = kodi.giveColor('Source: %s of ' + str(len(search_sources)),'white')

                kodi.dp.create(kodi.get_name(),'',line2,'')
                xbmc.executebuiltin('Dialog.Close(busydialog)')
                for u in sorted(search_sources):
                    if kodi.dp.iscanceled(): break
                    try:
                        i += 1
                        progress = 100 * int(i)/len(search_sources)
                        kodi.dp.update(progress, line1 % u.title(),line2 % str(source_num),line3 % str(i))
                        search_url = eval(u + ".search_base") % term
                        try: source_n = eval(u+".content('%s',True)" % search_url)
                        except: source_n = 0
                        try: source_n = int(source_n)
                        except: source_n = 0
                        if ( not source_n ): 
                            if failed_list == '': failed_list += str(u).title()
                            else: failed_list += ', %s' % str(u).title()
                        else: source_num += int(source_n)
                    except: pass
                kodi.dp.close()
                if failed_list != '': 
                    kodi.notify(msg='%s failed to return results.' % failed_list, duration=4000, sound=True)
                    log_utils.log('Scrapers failing to return search results are :: : %s' % failed_list, log_utils.LOGERROR)
                else: kodi.notify(msg='%s results found.' % str(source_num), duration=4000, sound=True)
                xbmcplugin.setContent(kodi.syshandle, 'movies')
                xbmcplugin.endOfDirectory(kodi.syshandle, cacheToDisc=True)
                utils.setView('search')
        else:
            search_url = eval(site + ".search_base") % term
            eval(site + ".content('%s')" % search_url)
    else:
        kodi.notify(msg='Blank searches are not allowed.')
        quit()