Exemplo n.º 1
0
    def search(self, keyword, external, transpar=None, strong=None):
        print "*** search for keyword %s " % keyword

        keyword_ = keyword if keyword else self.getUserInput()
        if keyword_:
            keyword_ = self.USTranslit(
                keyword_, transpar) if (external == 'unified') else keyword_
            keyword_ = keyword_ if isinstance(keyword_,
                                              unicode) else unicode(keyword_)
        else:
            return

        unified_search_results = []

        if keyword_:
            if self.new_search_method and (self.new_search_method == "true"):
                self.newSearchMethod(keyword_, external,
                                     unified_search_results, strong)
            else:
                url = self.url + '/autocomplete.php?query=' + keyword_
                response = common.fetchPage({"link": url})
                count = 1
                s = json.loads(response["content"])
                count = len(s['suggestions'])
                if count < 1: return False

                for i in range(0, count):
                    title = s['suggestions'][i].encode('utf-8')
                    surl = s['data'][i]
                    if surl.find('.html') > -1:
                        url = self.url + '/' + s['data'][i]
                        if (external == 'unified'):
                            self.log(
                                "Perform unified search and return results")
                            unified_search_results.append({
                                'title': title,
                                'url': url,
                                'image': self.icon,
                                'plugin': self.id
                            })
                        else:
                            uri = sys.argv[0] + '?mode=show&url=%s&wm=1' % url
                            item = xbmcgui.ListItem(title,
                                                    thumbnailImage=self.icon)
                            xbmcplugin.addDirectoryItem(
                                self.handle, uri, item, True)

            if (external == 'unified'):
                UnifiedSearch().collect(unified_search_results)
            else:
                xbmcplugin.setContent(self.handle, 'tvshows')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 2
0
    def __init__(self):
        self.id = 'plugin.video.unified.search'
        self.addon = xbmcaddon.Addon(self.id)
        self.icon = self.addon.getAddonInfo('icon')
        self.path = self.addon.getAddonInfo('path')
        self.profile = self.addon.getAddonInfo('profile')
        self.language = self.addon.getLocalizedString

        self.xpath = sys.argv[0]
        self.handle = int(sys.argv[1])
        self.params = sys.argv[2]

        self.supported_addons = UnifiedSearch().get_supported_addons()
        self.result_db = ResultDB()
        self.search_db = SearchDB()

        self.latest_search_id = self.search_db.get_latest_search_id()
        self.search_id = self.latest_search_id if self.latest_search_id else 0
        self.debug = self.addon.getSetting("debug") == 'true'

        # Custom icons
        self.search_icon = os.path.join(self.path, 'resources/icons/search.png')
        self.folder_icon = os.path.join(self.path, 'resources/icons/folder.png')
        self.warning_icon = os.path.join(self.path, 'resources/icons/warning.png')
Exemplo n.º 3
0
    def search(self, keyword, external):
        keyword = keyword if (external != None) else self.getUserInput()
        keyword = translit.rus(keyword) if (
            external == 'unified') else urllib.unquote_plus(keyword)
        unified_search_results = []

        if keyword:
            url = self.url + '/index.php?do=search'

            # Advanced search: titles only
            values = {
                "beforeafter": "after",
                "catlist[]": 0,
                "do": "search",
                "full_search": 0,
                "replyless": 0,
                "replylimit": 0,
                "resorder": "desc",
                "result_from": 1,
                "search_start": 1,
                "searchdate": 0,
                "searchuser": "",
                "showposts": 0,
                "sortby": "date",
                "story": self.decode(keyword),
                "subaction": "search",
                "titleonly": 0
            }

            headers = {
                "Host":
                self.domain,
                "Origin":
                self.domain,
                "Referer":
                self.url + '/',
                "User-Agent":
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:35.0) Gecko/20100101 Firefox/35.0"
            }

            # Send request to server
            request = urllib2.Request(url, urllib.urlencode(values), headers)
            response = urllib2.urlopen(request).read()

            content = common.parseDOM(response,
                                      "div",
                                      attrs={"id": "container"})
            items = common.parseDOM(content, "div", attrs={"class": "item"})

            link_container = common.parseDOM(
                items, "div", attrs={"class": "main-sliders-title"})
            titles = common.parseDOM(link_container, "a")
            links = common.parseDOM(link_container, "a", ret="href")
            images = common.parseDOM(items, "img", ret="src")

            descs = common.parseDOM(items, "i")

            if (external == 'unified'):
                self.log("Perform unified search and return results")

                for i, title in enumerate(titles):
                    image = images[i] if 'http' in images[
                        i] else self.url + images[i]
                    unified_search_results.append({
                        'title':
                        self.encode(self.strip(title)),
                        'url':
                        links[i],
                        'image':
                        image,
                        'plugin':
                        self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                for i, title in enumerate(titles):
                    uri = sys.argv[0] + '?mode=show&url=%s' % links[i]
                    image = images[i] if 'http' in images[
                        i] else self.url + images[i]
                    item = xbmcgui.ListItem(self.encode(self.strip(title)),
                                            thumbnailImage=image)
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                xbmcplugin.setContent(self.handle, 'movies')
                xbmcplugin.endOfDirectory(self.handle, True)
        else:
            self.menu()
Exemplo n.º 4
0
Arquivo: default.py Projeto: serbra/ru
def NKN_start(url, page, cook):
    dbg_log('-NKN_start:' + '\n')
    dbg_log('- url:' + url + '\n')
    dbg_log('- page:' + page + '\n')
    dbg_log('- cook:' + cook + '\n')
    ext_ls = [('<КАТАЛОГ>', '?mode=ctlg'), ('<ПОИСК>', '?mode=find')]
    unis_res = []
    unis_en = False

    if cook == "unis":
        cook = ""
        unis_en = True

    if url.find(find_pg) != -1:
        n_url = url + search_start + page
    else:
        n_url = url + page_pg + page + '/'

    dbg_log('- n_url:' + n_url + '\n')
    horg = get_url(n_url, cookie=cook, save_cookie=True)
    if cook == '':
        cook = re.search('<cookie>(.+?)</cookie>', horg).group(1)
    i = 0

    if unis_en == False:
        for ctTitle, ctMode in ext_ls:
            item = xbmcgui.ListItem(ctTitle)
            uri = sys.argv[0] + ctMode + '&cook=' + urllib.quote_plus(cook)
            xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)
            dbg_log('- uri:' + uri + '\n')

    http = re.sub('<br />', '', horg)
    hrefs = re.compile('<a href="(.*?)(#|">|" >)(.*?)</a></h4>').findall(http)

    if len(hrefs):
        news_id = re.compile("news-id-[0-9]")
        news = BeautifulSoup(http).findAll('div', {"id": news_id})

        if (len(hrefs) == len(news)):
            for sa in news:

                href = hrefs[i][0]
                dbg_log('-HREF %s' % href)
                #                infos = re.compile('<img src="/(.*?)" alt="(.*?)" title="(.*?)" />(</a><!--TEnd--></div>|<!--dle_image_end-->)(.*?)<').findall(str(sa))
                infos = re.compile(
                    '<img src="/(.*?)" alt="(.*?)" title="(.*?)" />').findall(
                        str(sa))
                print infos
                #                 for logo, alt, title, plot in infos:
                for logo, alt, title in infos:
                    img = start_pg + logo
                    dbg_log('-TITLE %s' % title)
                    dbg_log('-IMG %s' % img)
                    #                   dbg_log('-PLOT %s'%plot)

                    if unis_en == False:
                        item = xbmcgui.ListItem(title,
                                                iconImage=img,
                                                thumbnailImage=img)
                        #                     item.setInfo( type='video', infoLabels={'title': title, 'plot': plot})
                        item.setInfo(type='video', infoLabels={'title': title})
                        uri = sys.argv[0] + '?mode=view' \
                        + '&url=' + urllib.quote_plus(href) + '&img=' + urllib.quote_plus(img) \
                         + '&name=' + urllib.quote_plus(title)+ '&cook=' + urllib.quote_plus(cook)
                        xbmcplugin.addDirectoryItem(pluginhandle, uri, item,
                                                    True)
                        dbg_log('- uri:' + uri + '\n')
                        i = i + 1
                    else:
                        try:
                            unis_res.append({
                                'title':
                                title,
                                'url':
                                href,
                                'image':
                                img,
                                'plugin':
                                'plugin.video.new-kino.net'
                            })
                        except:
                            pass

    if unis_en == True:
        try:
            UnifiedSearch().collect(unis_res)
        except:
            pass
    else:
        if i:
            item = xbmcgui.ListItem('<NEXT PAGE>')
            uri = sys.argv[0] + '?page=' + str(
                int(page) + 1) + '&url=' + urllib.quote_plus(
                    url) + '&cook=' + urllib.quote_plus(cook)
            xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)
            dbg_log('- uri:' + uri + '\n')
            item = xbmcgui.ListItem('<NEXT PAGE +10>')
            uri = sys.argv[0] + '?page=' + str(
                int(page) + 10) + '&url=' + urllib.quote_plus(
                    url) + '&cook=' + urllib.quote_plus(cook)
            xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)
            dbg_log('- uri:' + uri + '\n')

        xbmcplugin.endOfDirectory(pluginhandle)
Exemplo n.º 5
0
def ListCat(params):
    pq = int(Addon.getSetting('ipp')) + 1
    mode = params['mode'] if 'mode' in params else None
    if unified:
        params['url'] = '/board'
        params['post'] = 'query=%s&a=2' % params['keyword']
        unified_search_results = []
    blink = 'http://cinema-hd.ru' + params['url']  # base
    post = params['post'] if 'post' in params else None
    if mode == 'search':
        searchmode = True
        pq = 1
    else:
        searchmode = False
    innerpage = int(params['page']) if 'page' in params else 1

    if '/load/' in blink and innerpage == 1 and not searchmode:
        li = xbmcgui.ListItem('<Поиск клипов>', thumbnailImage=addon_icon)
        uri = construct_request({'func': 'Search', 'mode': 'clips'})
        xbmcplugin.addDirectoryItem(hos, uri, li, True)

    for page in range((innerpage - 1) * pq + 1, innerpage * pq + 1):
        if page > 1:
            if re.search('board/0-1', blink):
                url = blink.replace('1', str(page))  # "Новое"
            elif re.search('/load/', blink):
                url = blink + '0-' + str(page)  # Клипы
            else:
                url = blink + '-' + str(page) + '-2'
        else:
            url = blink
        http = GET(url, post=post)
        if not http: break
        http = clean_html(http)
        soup = bs(http, 'html.parser', from_encoding='utf-8')
        content = soup.find_all('div',
                                attrs={'id': re.compile('entryID[0-9]+')})
        for item in content:
            #sdata = item.find('a', href=re.compile('http://cinema-hd.ru/board/.+'))
            data = item.find('a')
            #print data
            link = data['href']
            #title = data.find('h2').string.encode('utf-8')
            title = data.string.encode('utf-8')
            #print title
            #img = item.find('img', width='250')['src']
            img = item.find('img')['src']
            #data1 = item.find_all('span', style = "font-family:'Georgia'")
            data1 = item.find('div', class_='item-info inline')
            #print [i for i in data1]
            try:
                genredata = data1.p
                plotdata = data1.div
                genre = ' '.join(genredata.stripped_strings).encode('utf-8')
                plot = ' '.join(plotdata.stripped_strings).encode('utf-8')
            except:
                genre = plot = ''
            uri = construct_request({
                'func': 'ListSeries',
                'url': link,
                'title': title,
                'image': img
            })
            if unified:
                print addon_id, uri
                usurl = re.compile(addon_id + '(.+)$').findall(uri)[0]
                uspath = {
                    'title': title,
                    'url': urllib.quote_plus(usurl),
                    'image': img,
                    'plugin': addon_id
                }
                unified_search_results.append(uspath)
            else:
                li = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
                li.setInfo(type="video",
                           infoLabels={
                               "title": title,
                               "plot": plot,
                               "genre": genre
                           })
                #listitem.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(hos, uri, li, True)

    if not searchmode:
        linp = xbmcgui.ListItem('< Следующая страница >',
                                iconImage=addon_icon,
                                thumbnailImage=addon_icon)
        uri = construct_request({
            'func': 'ListCat',
            'page': innerpage + 1,
            'url': params['url']
        })
        xbmcplugin.addDirectoryItem(hos, uri, linp, True)
    if unified:
        UnifiedSearch().collect(unified_search_results)
        return True
    xbmcplugin.setContent(hos, 'movies')
    xbmcplugin.endOfDirectory(hos, cacheToDisc=True)
Exemplo n.º 6
0
def KNX_list(url, page, type, fdata):
    dbg_log('-KNX_list:' + '\n')
    dbg_log('- url:'+  url + '\n')
    dbg_log('- page:'+  page + '\n')
    dbg_log('- type:'+  type + '\n')
    dbg_log('- fdata:'+  fdata + '\n')
    
    if type == 'ctlg':
        n_url = url + 'page/' + page + '/'
        pdata = ''
    elif fdata != '':
        n_url = url
        pdata = find_dt + page + find_str + fdata
    else:
        n_url = url + page + '/'
        pdata = ''

                
        
    dbg_log('- n_url:'+  n_url + '\n')
    dbg_log('- pdata:'+  pdata + '\n')
    
    if type != 'unis':
        xbmcplugin.setContent(int(sys.argv[1]), 'episodes')#movies episodes tvshows
    
#     try:
    http = get_url(n_url, data=pdata)
#     except:
#         return
    
    i = 0
    
    
    if type == '':
        ext_ls = [('<КАТАЛОГ>', '?mode=ctlg'),
                  ('<ПОИСК>', '?mode=find')]
        for ctTitle, ctMode  in ext_ls:
            item = xbmcgui.ListItem(ctTitle)
            uri = sys.argv[0] + ctMode
            xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)  
            dbg_log('- uri:'+  uri + '\n')    


        
    entrys = BeautifulSoup(http).findAll('div',{"class":"eTitle"})
    msgs = BeautifulSoup(http).findAll('div',{"class":"eMessage"}) 

    for eid in entrys:

#             print eid
#            print msgs[i]

            href = re.compile('<a href="(.*?)">').findall(str(eid))[0]
            plots = BeautifulSoup(str(msgs[i])).findAll('div',{"class":"block-text"})
#            print plots            
            try:
                plot = re.compile('<div class="block-text">(.*?)</div>').findall(re.sub('[\n\r\t]', ' ',str(msgs[i])))[0]
            except:
                plot = ''
            try:
                img = start_pg + re.compile('<img.*?src="(.*?)"').findall(str(msgs[i]))[0]
            except:
                img = ''
            try:
                title = re.compile('<div class="title-short">(.*?)</div>').findall(str(eid))[0]
            except:
                title = re.compile('<a href=".*?">(.*?)</a>').findall(str(eid))[0]
                


            dbg_log('-HREF %s'%href)
            dbg_log('-TITLE %s'%title)
            dbg_log('-IMG %s'%img)
            dbg_log('-PLOT %s'%plot)

            if type != 'unis':
                item = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
                item.setInfo( type='video', infoLabels={'title': title, 'plot': plot})
                uri = sys.argv[0] + '?mode=play' \
                + '&url=' + urllib.quote_plus(href)
                item.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(pluginhandle, uri, item, False)  
                dbg_log('- uri:'+  uri + '\n')
                i = i + 1
            else:
              try:
                unis_res.append({'title':  title, 'url': href, 'image': img, 'plugin': 'plugin.video.kinoxa-x.ru'})
              except: pass

    if type == 'unis':
      try: UnifiedSearch().collect(unis_res)
      except:  pass
    else:
      if i :
          item = xbmcgui.ListItem('<NEXT PAGE>')
          uri = sys.argv[0] + '?page=' + str(int(page) + 1) + '&url=' + urllib.quote_plus(url) + '&type=' + type + '&find=' + urllib.quote_plus(fdata)
          xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)
          dbg_log('- uri:'+  uri + '\n')
          if type != 'find':
              item = xbmcgui.ListItem('<NEXT PAGE +5>')
              uri = sys.argv[0] + '?page=' + str(int(page) + 5) + '&url=' + urllib.quote_plus(url) + '&type=' + type + '&find=' + urllib.quote_plus(fdata)
              xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)
              dbg_log('- uri:'+  uri + '\n')        
     
      xbmcplugin.endOfDirectory(pluginhandle) 
Exemplo n.º 7
0
    def search(self, keyword, unified):
        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            search_url = "http://kinosolo.ru/load/"

            # Advanced search: titles only
            values = {
                "a": 2,
                "do.x": 0,
                "do.y": 0,
                "query": keyword,
            }

            # Send request to server
            request = urllib2.Request(search_url, urllib.urlencode(values))
            response = urllib2.urlopen(request)

            movie = common.parseDOM(response.read(),
                                    "div",
                                    attrs={"class": "post"})

            movie_header = common.parseDOM(movie,
                                           "div",
                                           attrs={"class": "post-title"})
            movie_body = common.parseDOM(movie,
                                         "div",
                                         attrs={"class": "post-story"})
            movie_footer = common.parseDOM(movie,
                                           "div",
                                           attrs={"class": "post-data"})

            titles = common.parseDOM(movie_header, "a")
            links = common.parseDOM(movie_header, "a", ret="href")
            images = common.parseDOM(movie_body, "img", ret="src")

            if unified:
                self.log("Perform unified search and return results")

                for i, title in enumerate(titles):
                    title = title.replace(self.language(5002), '')
                    unified_search_results.append({
                        'title': title,
                        'url': links[i],
                        'image': images[i],
                        'plugin': self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                for i, title in enumerate(titles):
                    title = title.replace(self.language(5002), '')

                    uri = sys.argv[0] + '?mode=show&url=%s' % links[i]
                    item = xbmcgui.ListItem(title, thumbnailImage=images[i])
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                xbmc.executebuiltin('Container.SetViewMode(50)')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 8
0
    def search(self, keyword, external):
        print "*** Search"

        keyword = keyword if (external != None) else self.getUserInput()
        keyword = translit.rus(keyword) if (
            external == 'unified') else urllib.unquote_plus(keyword)
        unified_search_results = []

        if keyword:
            print keyword

            headers = {
                'Host':
                self.domain,
                'Referer':
                self.url,
                'Upgrade-Insecure-Requests':
                '1',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
            }

            values = {
                "do": "search",
                "subaction": "search",
                "q": unicode(keyword)
            }

            form = urllib.urlencode(values)
            encoded_kwargs = urllib.urlencode(values.items())
            argStr = "/?%s" % (encoded_kwargs)
            request = urllib2.Request(self.url + argStr, "", headers)
            request.get_method = lambda: 'GET'
            response = urllib2.urlopen(request).read()

            content = common.parseDOM(
                response, "div", attrs={"class": "b-content__inline_items"})
            videos = common.parseDOM(content,
                                     "div",
                                     attrs={"class": "b-content__inline_item"})

            for i, videoitem in enumerate(videos):
                link = common.parseDOM(videoitem, "a", ret='href')[0]
                title = common.parseDOM(videoitem, "a")[1]

                image = common.parseDOM(videoitem, "img", ret='src')[0]
                descriptiondiv = common.parseDOM(
                    videoitem,
                    "div",
                    attrs={"class": "b-content__inline_item-link"})[0]
                description = common.parseDOM(descriptiondiv, "div")[0]

                if (external == 'unified'):
                    print "Perform unified search and return results"
                    unified_search_results.append({
                        'title': title,
                        'url': link,
                        'image': image,
                        'plugin': self.id
                    })
                else:
                    uri = sys.argv[0] + '?mode=show&url=%s' % urllib.quote(
                        link)
                    item = xbmcgui.ListItem("%s [COLOR=55FFFFFF][%s][/COLOR]" %
                                            (title, description),
                                            iconImage=image,
                                            thumbnailImage=image)
                    item.setInfo(type='Video', infoLabels={'title': title})
                    if (self.quality != 'select') and (not (
                            '/series/' in link)) and (not ('/show/' in link)):
                        item.setProperty('IsPlayable', 'true')
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    False)
                    else:
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    True)

            if (external == 'unified'):
                UnifiedSearch().collect(unified_search_results)
            else:
                xbmcplugin.setContent(self.handle, 'movies')
                xbmcplugin.endOfDirectory(self.handle, True)
        else:
            self.menu()
Exemplo n.º 9
0
    def search(self, keyword, unified, page):
        print "*** Search: unified %s" % unified

        if not keyword:
            keyword = self.getUserInput()

        if keyword:

            url = self.url + '/search/' + str(page) + '/?q=%s' % (keyword)
            request = urllib2.Request(url)
            request.add_header(
                'User-agent',
                'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'
            )
            response = urllib2.urlopen(request)
            resp = response.read()

            links = common.parseDOM(resp,
                                    "a",
                                    attrs={"itemprop": "url"},
                                    ret='href')
            titles = common.parseDOM(resp,
                                     "span",
                                     attrs={"class": "item-title"})
            images = common.parseDOM(resp,
                                     "img",
                                     attrs={"class": "thumb"},
                                     ret='src')

            durations = common.parseDOM(resp,
                                        "span",
                                        attrs={"class": "item-time"})

            pages = common.parseDOM(resp,
                                    "div",
                                    attrs={"class": "pagination navigation"})
            pages = common.parseDOM(pages,
                                    "div",
                                    attrs={"class": "block_content"})
            pages = common.parseDOM(pages, "a", ret='href')

            if unified:
                print "Perform unified search and return results"

                for i, title in enumerate(titles):
                    # title = self.encode(title)
                    unified_search_results.append({
                        'title': title,
                        'url': links[i],
                        'image': self.url + images[i],
                        'plugin': self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                for i, title in enumerate(titles):
                    duration = durations[i].split(':')[0]

                    uri = sys.argv[0] + '?mode=show&url=%s' % urllib.quote(
                        links[i])
                    item = xbmcgui.ListItem("%s [COLOR=55FFFFFF](%s)[/COLOR]" %
                                            (title, durations[i]),
                                            iconImage=images[i])
                    item.setInfo(type='Video',
                                 infoLabels={
                                     'title': title,
                                     'genre': durations[i],
                                     'duration': duration
                                 })
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                if int(page) <= len(pages):
                    uri = sys.argv[0] + '?mode=%s&keyword=%s&page=%s' % (
                        "search", keyword, str(int(page) + 1))
                    item = xbmcgui.ListItem("следующая страница...",
                                            iconImage=self.icon,
                                            thumbnailImage=self.icon)
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                xbmc.executebuiltin('Container.SetViewMode(52)')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 10
0
    def search(self, keyword, unified):
        self.log("*** Search: unified %s" % unified)

        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            url = 'http://go.mail.ru/search_site?fr=main&p=1&aux=Abd67k&q=%s&x=0&y=0' % keyword
            request = urllib2.Request(url)
            request.add_header('Host', 'go.mail.ru')
            request.add_header('Referer', 'http://www.online-life.me/')
            request.add_header(
                'User-Agent',
                'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:35.0) Gecko/20100101 Firefox/35.0'
            )

            response = urllib2.urlopen(request).read()

            container = common.parseDOM(response,
                                        "ul",
                                        attrs={"class": "result js-result"})
            posts = common.parseDOM(container,
                                    "li",
                                    attrs={"class": "result__li js-kb-wrap"})
            results = common.parseDOM(posts,
                                      "div",
                                      attrs={"class": "result__img"})
            titles = common.parseDOM(posts, "a", attrs={"class": "light-link"})
            links = common.parseDOM(results, "a", ret="href")
            images = common.parseDOM(results, "img", ret="src")

            if unified:
                self.log("Perform unified search and return results")

                for i, title in enumerate(titles):
                    title = titles[i].encode('utf-8')
                    link = links[i]
                    image = images[i]

                    unified_search_results.append({
                        'title': title,
                        'url': link,
                        'image': image,
                        'plugin': self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                if results:
                    for i, title in enumerate(titles):
                        title = titles[i].encode('utf-8')
                        link = links[i]
                        image = images[i]

                        uri = sys.argv[0] + '?mode=show&url=%s' % link
                        item = xbmcgui.ListItem(title, thumbnailImage=image)

                        self.favorites.addContextMenuItem(
                            item, {
                                'title': title,
                                'url': link,
                                'image': image,
                                'playable': False,
                                'action': 'add',
                                'plugin': self.id
                            })

                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    True)

                    xbmc.executebuiltin('Container.SetViewMode(52)')
                else:
                    item = xbmcgui.ListItem(self.language(2001),
                                            iconImage=self.icon,
                                            thumbnailImage=self.icon)
                    xbmcplugin.addDirectoryItem(self.handle, '', item, True)

                xbmcplugin.endOfDirectory(self.handle, True)
        else:
            self.menu()
Exemplo n.º 11
0
    def search(self, keyword, unified):
        self.log("*** Search: unified %s" % unified)

        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            url = 'http://www.online-life.ru/index.php?do=search'

            # Advanced search: titles only
            values = {
                "beforeafter": "after",
                "catlist[]": "0",
                "do": "search",
                "full_search": "1",
                "replyless": "0",
                "replylimit": "0",
                "resorder": "desc",
                "result_from": "1",
                "search_start": "1",
                "searchdate": "0",
                "searchuser": "",
                "showposts": "0",
                "sortby": "date",
                "story": keyword,
                "subaction": "search",
                "titleonly": "3"
            }

            data = urllib.urlencode(values)
            request = urllib2.Request(url, data)
            response = urllib2.urlopen(request).read()

            container = common.parseDOM(response,
                                        "div",
                                        attrs={"id": "container"})
            posts = common.parseDOM(container,
                                    "div",
                                    attrs={"class": "custom-post"})

            if unified:
                self.log("Perform unified search and return results")

                for i, post in enumerate(posts):
                    poster = common.parseDOM(post,
                                             "div",
                                             attrs={"class": "custom-poster"})
                    title = self.encode(
                        common.stripTags(common.parseDOM(post, "a")[0]))
                    link = common.parseDOM(post, "a", ret="href")[0]
                    image = common.parseDOM(post, "img", ret="src")[0]

                    unified_search_results.append({
                        'title': title,
                        'url': link,
                        'image': image,
                        'plugin': self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                if posts:
                    for i, post in enumerate(posts):
                        poster = common.parseDOM(
                            post, "div", attrs={"class": "custom-poster"})
                        title = self.encode(
                            common.stripTags(common.parseDOM(post, "a")[0]))
                        link = common.parseDOM(post, "a", ret="href")[0]
                        image = common.parseDOM(post, "img", ret="src")[0]

                        uri = sys.argv[0] + '?mode=show&url=%s' % link
                        item = xbmcgui.ListItem(title, thumbnailImage=image)

                        self.favorites.addContextMenuItem(
                            item, {
                                'title': title,
                                'url': link,
                                'image': image,
                                'playable': False,
                                'action': 'add',
                                'plugin': self.id
                            })

                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    True)

                    xbmc.executebuiltin('Container.SetViewMode(52)')
                else:
                    item = xbmcgui.ListItem(self.language(2001),
                                            iconImage=self.icon,
                                            thumbnailImage=self.icon)
                    xbmcplugin.addDirectoryItem(self.handle, '', item, True)

                xbmcplugin.endOfDirectory(self.handle, True)
        else:
            self.menu()
Exemplo n.º 12
0
    def search(self, keyword, unified):
        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            self.log("You are looking for: %s" %
                     keyword.decode('cp1251').encode('utf-8'))

            # Simple search
            # values = {
            #     "do":           "search",
            #     "story":        keyword,
            #     "subaction":    "search",
            #     "x":            0,
            #     "y":            0
            # }

            # headers = {
            #     "Host" : "filmodrom.net",
            #     "Referer" : 'http://filmodrom.net/index.php',
            #     "User-Agent" : "Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0"
            # }

            # request = urllib2.Request(url, urllib.urlencode(values), headers)
            # response = urllib2.urlopen(request)

            # Advanced search: titles only
            url = 'http://filmodrom.net/index.php?do=search'

            headers = {
                "Host":
                "filmodrom.net",
                "Referer":
                'http://filmodrom.net/index.php',
                "User-Agent":
                "Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0"
            }

            values = {
                "beforeafter": "after",
                "catlist[]": "0",
                "do": "search",
                "full_search": "1",
                "replyless": "0",
                "replylimit": "0",
                "resorder": "desc",
                "result_from": "1",
                "result_num": "20",
                "search_start": "1",
                "searchdate": "0",
                "searchuser": "",
                "showposts": "0",
                "sortby": "date",
                "story": keyword,
                "subaction": "search",
                "titleonly": 3
            }

            request = urllib2.Request(url, urllib.urlencode(values), headers)
            # request = urllib2.Request(url, urllib.urlencode(values))
            response = urllib2.urlopen(request)

            content = common.parseDOM(response.read(),
                                      "div",
                                      attrs={"id": "dle-content"})
            table = common.parseDOM(content, "table")

            header = common.parseDOM(table, "strong")
            links = common.parseDOM(header, "a", ret="href")
            titles = common.parseDOM(header, "a")

            if titles:
                if unified:
                    self.log("Perform unified search and return results")

                    for i, title in enumerate(titles):
                        unified_search_results.append({
                            'title':
                            self.encode(title),
                            'url':
                            links[i],
                            'image':
                            None,
                            'plugin':
                            self.id
                        })
                else:
                    for i, title in enumerate(titles):
                        uri = sys.argv[0] + '?mode=show&url=%s' % links[i]
                        item = xbmcgui.ListItem(self.encode(title),
                                                iconImage=self.icon,
                                                thumbnailImage=self.icon)
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    True)
            else:
                item = xbmcgui.ListItem(self.language(2001).encode('utf-8'),
                                        iconImage=self.icon,
                                        thumbnailImage=self.icon)
                xbmcplugin.addDirectoryItem(self.handle, '', item, True)

            UnifiedSearch().collect(unified_search_results)

        else:
            self.menu()

        xbmc.executebuiltin('Container.SetViewMode(52)')
        xbmcplugin.endOfDirectory(self.handle, True)
Exemplo n.º 13
0
    def search(self, keyword, unified):
        print "*** Search: unified %s" % unified

        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            keyword = self.encode(keyword)

            url = 'http://www.videokub.me/search/?q=%s' % (keyword)
            response = urllib2.urlopen(url)
            content = common.parseDOM(response.read(),
                                      "div",
                                      attrs={"class": "list_videos"})
            videos = common.parseDOM(content, "div", attrs={"class": "short"})

            links = common.parseDOM(videos,
                                    "a",
                                    attrs={"class": "kt_imgrc"},
                                    ret='href')
            titles = common.parseDOM(videos,
                                     "a",
                                     attrs={"class": "kt_imgrc"},
                                     ret='title')
            images = common.parseDOM(videos,
                                     "img",
                                     attrs={"class": "thumb"},
                                     ret='src')

            durations = common.parseDOM(videos,
                                        "span",
                                        attrs={"class": "time"})

            if unified:
                print "Perform unified search and return results"

                for i, title in enumerate(titles):
                    # title = self.encode(title)
                    unified_search_results.append({
                        'title': title,
                        'url': links[i],
                        'image': self.url + images[i],
                        'plugin': self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                for i, title in enumerate(titles):
                    duration = durations[i].split(':')[0]

                    uri = sys.argv[0] + '?mode=show&url=%s' % urllib.quote(
                        links[i])
                    item = xbmcgui.ListItem("%s [COLOR=55FFFFFF](%s)[/COLOR]" %
                                            (title, durations[i]),
                                            iconImage=images[i])
                    item.setInfo(type='Video',
                                 infoLabels={
                                     'title': title,
                                     'genre': durations[i],
                                     'duration': duration
                                 })
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                # TODO: Fix search pagination
                # http://www.videokub.me/search/2/?q=%D0%B1%D0%B0%D1%80%D0%B1%D0%BE%D1%81%D0%BA&search=%D0%9D%D0%B0%D0%B9%D1%82%D0%B8
                #uri = sys.argv[0] + '?mode=%s&url=%s' % ("show", url)
                #item = xbmcgui.ListItem(self.language(1004), iconImage=self.inext)
                #xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                xbmc.executebuiltin('Container.SetViewMode(52)')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 14
0
    def search(self, keyword, external):
        keyword = keyword if (external != None) else self.getUserInput()
        keyword = translit.rus(keyword) if (external == 'unified') else urllib.unquote_plus(keyword)

        unified_search_results = []

        if keyword:
            url =  self.url + '/index.php?do=search'

            # Advanced search: titles only
            values = {
                "beforeafter": "after",
                "catlist[]": 0,
                "do": "search",
                "full_search": "1",
                "replyless": "0",
                "replylimit": "0",
                "resorder": "desc",
                "result_from": "1",
                "result_num": "50",
                "search_start": "1",
                "searchdate": "0",
                "searchuser": "",
                "showposts": "0",
                "sortby": "date",
                "story": self.decode(keyword),
                "subaction": "search",
                "titleonly": "3"
            }

            headers = {
                "Referer" : self.url + '/index.php?do=search',
                "User-Agent" : "Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0"
            }

            data = urllib.urlencode(values)
            request = urllib2.Request(url, data, headers)
            response = urllib2.urlopen(request)

            containers = common.parseDOM(response.read(), "div", attrs={"class": "search_item clearfix"})
            search_item_prev = common.parseDOM(containers, "div", attrs={"class": "search_item_prev"})
            search_item_inner = common.parseDOM(containers, "div", attrs={"class": "search_item_inner"})

            descriptions = common.parseDOM(search_item_inner, "div")

            header = common.parseDOM(search_item_inner, "h3")
            gcont = common.parseDOM(search_item_inner, "span")

            titles = common.parseDOM(header, "a")
            links = common.parseDOM(header, "a", ret="href")
            images = common.parseDOM(search_item_prev, "img", ret="src")

            if (external == 'unified'):
                self.log("Perform unified search and return results")
                for i, title in enumerate(titles):
                    image = self.url + images[i]
                    unified_search_results.append({'title': self.encode(title), 'url': links[i], 'image': image, 'plugin': self.id})

                UnifiedSearch().collect(unified_search_results)

            else:
                for i, title in enumerate(titles):
                    image = self.url + images[i]
                    print image
                    genres = self.encode(', '.join(common.parseDOM(gcont[i], "a")))
                    desc = self.encode(common.stripTags(descriptions[i]))
                    uri = sys.argv[0] + '?mode=show&url=%s' % links[i]
                    item = xbmcgui.ListItem(self.encode(title), iconImage=self.icon, thumbnailImage=image)
                    item.setInfo(type='Video', infoLabels={'title': self.encode(title), 'genre': genres, 'plot': desc})

                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                xbmcplugin.setContent(self.handle, 'movies')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 15
0
    def search(self, keyword, unified):
        self.log("*** Search: unified %s" % unified)

        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            url = 'http://fepcom.net/index.php?do=search'

            # Advanced search: titles only
            values = {
                "beforeafter": "after",
                "catlist[]": 30,
                "do": "search",
                "full_search": 1,
                "replyless": 0,
                "replylimit": 0,
                "resorder": "desc",
                "result_from": 1,
                "search_start": 1,
                "searchdate": 0,
                "searchuser": "",
                "showposts": 0,
                "sortby": "date",
                "story": keyword,
                "subaction": "search",
                "titleonly": "3"
            }

            headers = {
                "Host":
                "fepcom.net",
                "Referer":
                'http://fepcom.net/index.php?do=search',
                "User-Agent":
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:23.0) Gecko/20100101 Firefox/23.0"
            }

            # Send request to server
            request = urllib2.Request(url, urllib.urlencode(values), headers)
            response = urllib2.urlopen(request)
            content = response.read()

            posts = common.parseDOM(content, "div", attrs={"class": "post"})
            headers = common.parseDOM(content, "h2")

            titles = common.parseDOM(headers, "a")
            links = common.parseDOM(headers, "a", ret="href")
            images = common.parseDOM(posts, "img", ret="src")

            if unified:
                self.log("Perform unified search and return results")

                for i, title in enumerate(titles):
                    unified_search_results.append({
                        'title': self.encode(title),
                        'url': links[i],
                        'image': self.url + images[i],
                        'plugin': self.id
                    })

                UnifiedSearch().collect(unified_search_results)

            else:
                for i, title in enumerate(titles):
                    uri = sys.argv[0] + '?mode=show&url=%s' % links[i]
                    item = xbmcgui.ListItem(self.encode(title),
                                            thumbnailImage=self.url +
                                            images[i])
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

                xbmc.executebuiltin('Container.SetViewMode(50)')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 16
0
    def search(self, keyword, unified):
        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            keyword = self.encode(keyword)

            url = 'http://uakino.net/search_result.php'

            headers = {
                "Accept":
                "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                "Accept-Encoding":
                "gzip,deflate",
                "Accept-Language":
                "en-US,en;q=0.5",
                "Connection":
                "keep-alive",
                "Content-Type":
                "application/x-www-form-urlencoded",
                "Host":
                "	uakino.net",
                "Referer":
                url,
                "User-Agent":
                "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0"
            }

            values = {
                "search_id": keyword,
                "send": "%D0%9F%D0%BE%D0%B8%D1%81%D0%BA"
            }

            data = urllib.urlencode(values)
            req = urllib2.Request(url, data, headers)
            html = None

            try:
                response = urllib2.urlopen(req)
                html = response.read()
            except Exception:
                if unified:
                    UnifiedSearch().collect(unified_search_results)
                pass

            self.log(keyword)

            us_titles = []
            us_links = []
            us_images = []

            if html:
                media_line = common.parseDOM(html,
                                             "div",
                                             attrs={"class": "media_line"})

                titlesA = common.parseDOM(media_line, "a", ret="title")
                pathsA = common.parseDOM(media_line,
                                         "a",
                                         attrs={"class": "fleft thumb"},
                                         ret="href")

                titlesB = common.parseDOM(media_line,
                                          "a",
                                          attrs={"class": "heading"})
                pathsB = common.parseDOM(media_line,
                                         "a",
                                         attrs={"class": "heading"},
                                         ret="href")

                images = common.parseDOM(media_line, "img", ret="src")

                items_counter = 0

                # print "Found A: %d"%len(pathsA)
                # print "Found B: %d"%len(pathsB)
                # print "Found images %d"%len(images)

                if titlesA and titlesB:
                    print "*** This is a mix of seasons and movies"

                    for i, title in enumerate(titlesA):
                        items_counter += 1

                        link = "%s/%s" % (self.url, pathsA[i])
                        image = self.url + images[i] if not 'http' in images[
                            i] else images[i]

                        # INFO: Collect search results
                        us_titles.append(title)
                        us_links.append(link)
                        us_images.append(image)

                        uri = sys.argv[0] + '?mode=subcategory&url=%s' % link
                        item = xbmcgui.ListItem(title,
                                                thumbnailImage=image,
                                                iconImage=self.icon)
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    True)

                    for i, title in enumerate(titlesB):
                        items_counter += 1

                        link = "%s/%s" % (self.url, pathsB[i])
                        image = self.url + images[
                            len(pathsB) + i] if not 'http' in images[
                                len(pathsB) + i] else images[len(pathsB) + i]

                        # INFO: Collect search results
                        us_titles.append(title)
                        us_links.append(link)
                        us_images.append(image)

                        uri = sys.argv[0] + '?mode=movie&url=%s' % link
                        item = xbmcgui.ListItem(title,
                                                thumbnailImage=image,
                                                iconImage=self.icon)
                        item.setProperty('IsPlayable', 'true')
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    False)

                elif titlesA:
                    print "*** This is a season"

                    for i, title in enumerate(titlesA):
                        items_counter += 1

                        link = "%s/%s" % (self.url, pathsA[i])
                        image = self.url + images[i] if not 'http' in images[
                            i] else images[i]

                        # INFO: Collect search results
                        us_titles.append(title)
                        us_links.append(link)
                        us_images.append(image)

                        uri = sys.argv[0] + '?mode=subcategory&url=%s' % link
                        item = xbmcgui.ListItem(title,
                                                thumbnailImage=image,
                                                iconImage=self.icon)
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    True)

                elif titlesB:
                    print "*** This is a movie"

                    ul = common.parseDOM(media_line, "ul")

                    for i, title in enumerate(titlesB):
                        genres = common.stripTags(
                            common.parseDOM(ul[i], "li")[0])

                        try:
                            description = common.stripTags(
                                common.parseDOM(ul[i], "li")[2])
                        except IndexError:
                            description = common.stripTags(
                                common.parseDOM(ul[i], "li")[1])

                        items_counter += 1

                        link = "%s/%s" % (self.url, pathsA[i])
                        image = self.url + images[i] if not 'http' in images[
                            i] else images[i]
                        info = {
                            'title': title,
                            'genre': genres,
                            'plot': description
                        }

                        # INFO: Collect search results
                        us_titles.append(title)
                        us_links.append(link)
                        us_images.append(image)

                        uri = sys.argv[0] + '?mode=movie&url=%s' % link
                        item = xbmcgui.ListItem(title,
                                                thumbnailImage=image,
                                                iconImage=self.icon)

                        item.setInfo(type='Video', infoLabels=info)
                        item.setProperty('IsPlayable', 'true')
                        xbmcplugin.addDirectoryItem(self.handle, uri, item,
                                                    False)
                else:
                    item = xbmcgui.ListItem(self.language(9001),
                                            thumbnailImage=self.icon)
                    xbmcplugin.addDirectoryItem(self.handle, "", item, False)
            else:
                self.showErrorMessage("%s: Request timeout" % self.id)

            # INFO: Convert and send unified search results
            if unified:
                self.log("Perform unified search and return results")
                for i, title in enumerate(us_titles):
                    unified_search_results.append({
                        'title': title,
                        'url': us_links[i],
                        'image': us_images[i],
                        'plugin': self.id,
                        'is_playable': True
                    })

                UnifiedSearch().collect(unified_search_results)
            else:
                xbmc.executebuiltin('Container.SetViewMode(50)')
                xbmcplugin.endOfDirectory(self.handle, True)

        else:
            self.menu()
Exemplo n.º 17
0
                    script = "special://home/addons/plugin.video.filin.tv/contextmenuactions.py"
                    params = "add|%s" % links[i] + "|%s" % title
                    runner = "XBMC.RunScript(" + str(
                        script) + ", " + params + ")"
                    item.addContextMenuItems([(localize(language(3001)),
                                               runner)])

                    xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)

        if (lines == 0) and (external == None):
            item = xbmcgui.ListItem(colorize(language(2004), 'FFFF4000'))
            item.setProperty('IsPlayable', 'false')
            xbmcplugin.addDirectoryItem(pluginhandle, '', item, False)

        if (external == 'unified'):
            UnifiedSearch().collect(unified_search_results)
        else:
            xbmcplugin.setContent(pluginhandle, 'movies')
            xbmcplugin.endOfDirectory(pluginhandle, True)


def getCategories(url):
    result = common.fetchPage({"link": url})

    if result["status"] == 200:
        content = common.parseDOM(result["content"],
                                  "div",
                                  attrs={"class": "mcont"})
        categories = common.parseDOM(content, "a", ret="href")
        descriptions = common.parseDOM(content, "a")
Exemplo n.º 18
0
    def search(self, keyword, external, page=1):
        if page == 1:
            keyword = keyword if (
                external != None) or keyword else self.getUserInput()
            keyword = translit.rus(keyword) if (
                external == 'unified') else urllib.unquote_plus(keyword)
        else:
            keyword = urllib.unquote_plus(keyword)

        unified_search_results = []

        if keyword:
            url = "https://rutube.ru/api/search/video/"

            values = {
                "order_by": "rank",
                "duration": "",
                "created": "",
                "only_hd": "false",
                "no_adult": "false",
                "query": encode2(keyword),
                "page": str(page),
                "perPage": "10"
            }

            headers = {
                "Host": "rutube.ru",
                "Connection": "keep-alive",
                "User-Agent":
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
                "Accept": "application/json, text/javascript, */*; q=0.01",
                "X-Requested-With": "XMLHttpRequest",
                "X-Ally": "1",
                "X-CSRFToken": "4qb8a9ysuvpxudljpz3o6ngljciy8pl2",
                "Referer":
                "https://rutube.ru/search/?query=" + encode2(keyword),
                "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4",
            }

            form = urllib.urlencode(values)
            encoded_kwargs = urllib.urlencode(values.items())
            argStr = "?%s" % (encoded_kwargs)
            request = urllib2.Request(url + argStr, "", headers)
            request.get_method = lambda: 'GET'
            response = urllib2.urlopen(request)
            data = json.loads(response.read())

            for i, result in enumerate(data['results']):
                image = result['thumbnail_url']
                if (external == 'unified'):
                    unified_search_results.append({
                        'title':
                        result['title'],
                        'url':
                        'https://rutube.ru/video/%s/?ref=search' %
                        result['id'],
                        'image':
                        image,
                        'plugin':
                        self.id
                    })
                else:
                    uri = sys.argv[
                        0] + '?mode=play&url=https://rutube.ru/video/%s/?ref=search' % result[
                            'id']
                    item = xbmcgui.ListItem(result['title'],
                                            iconImage=image,
                                            thumbnailImage=image)
                    item.setProperty('IsPlayable', 'true')
                    item.setInfo(type='Video',
                                 infoLabels={'title': result['title']})
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, False)

            if (external == None) and (data['has_next'] == True):
                uri = sys.argv[0] + '?mode=%s&keyword=%s&page=%s' % (
                    'search', keyword, str(page + 1))
                item = xbmcgui.ListItem('[COLOR=FFFFD700]' +
                                        self.language(2000) % (str(page + 1)) +
                                        '[/COLOR]',
                                        thumbnailImage=self.inext,
                                        iconImage=self.inext)
                item.setInfo(type='Video', infoLabels={'title': '<NEXT PAGE>'})
                xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

            if (external == 'unified'):
                UnifiedSearch().collect(unified_search_results)
            else:
                xbmcplugin.setContent(self.handle, 'movies')
                xbmcplugin.endOfDirectory(self.handle, True)
Exemplo n.º 19
0
    def search(self, keyword, unified):
        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            url = 'http://kino-v-online.tv/index.php?do=search'

            values = {
                "do": "search",
                "full_search": "0",
                "result_from": "1",
                "result_num": "22",
                "search_start": "a",
                "story": keyword,
                "subaction": "search"
            }

            data = urllib.urlencode(values)
            req = urllib2.Request(url, data)

            response = urllib2.urlopen(req)
            html = response.read()
            content = common.parseDOM(html, "div", attrs={"id": "dle-content"})

            if response.geturl() == url:
                links = common.parseDOM(content, "a", ret="href")
                titles = common.parseDOM(content, "b")
            else:
                links = [response.geturl().replace(self.url, '')]
                titles = common.parseDOM(content, "h1")

            images = common.parseDOM(content,
                                     "img",
                                     attrs={"class": "top"},
                                     ret="src")

            if unified:
                for i, title in enumerate(titles):
                    if images:
                        unified_search_results.append({
                            'title':
                            self.encode(title),
                            'url':
                            self.url + '/' + links[i],
                            'image':
                            images[i],
                            'plugin':
                            self.id
                        })
                    else:
                        unified_search_results.append({
                            'title':
                            self.encode(title),
                            'url':
                            self.url + '/' + links[i],
                            'image':
                            '',
                            'plugin':
                            self.id
                        })

                UnifiedSearch().collect(unified_search_results)

            else:
                if links:
                    for i, link in enumerate(links):
                        if not link == "#":
                            if images:
                                uri = sys.argv[0] + '?mode=%s&url=%s' % (
                                    "show", self.url + '/' + link)
                                item = xbmcgui.ListItem(
                                    self.encode(titles[i]),
                                    thumbnailImage=images[i])
                                xbmcplugin.addDirectoryItem(
                                    self.handle, uri, item, True)
                            else:
                                uri = sys.argv[0] + '?mode=%s&url=%s' % (
                                    "show", self.url + '/' + link)
                                item = xbmcgui.ListItem(
                                    self.encode(titles[i]),
                                    thumbnailImage=self.icon)
                                xbmcplugin.addDirectoryItem(
                                    self.handle, uri, item, True)
                else:
                    item = xbmcgui.ListItem(self.language(2001),
                                            thumbnailImage=self.icon)
                    xbmcplugin.addDirectoryItem(self.handle, "", item, False)

        else:
            self.menu()

        xbmc.executebuiltin('Container.SetViewMode(50)')
        xbmcplugin.endOfDirectory(self.handle, True)