当前位置: 首页>>代码示例>>Python>>正文


Python Translit.rus方法代码示例

本文整理汇总了Python中Translit.rus方法的典型用法代码示例。如果您正苦于以下问题:Python Translit.rus方法的具体用法?Python Translit.rus怎么用?Python Translit.rus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translit的用法示例。


在下文中一共展示了Translit.rus方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    def search(self):
        query = common.getUserInput(self.language(1000), "")

        if query:
            if self.addon.getSetting('translit') == 'true':
                print "Module translit enabled"
            try:
                keyword = translit.rus(query)
            except Exception:
                keyword = translit.rus(query)
            else:
                keyword = query

        url = self.url + "/q/" + keyword + '/'
        self.getPlaylist(url)
开发者ID:Sitronik,项目名称:xbmc-plugins,代码行数:17,代码来源:default.py

示例2: getUserInput

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    def getUserInput(self):
        kbd = xbmc.Keyboard()
        kbd.setDefault('')
        kbd.setHeading(self.language(1000))
        kbd.doModal()
        keyword = None
        s = None

        if kbd.isConfirmed():
            s = kbd.getText()
            if self.addon.getSetting('translit') == 'true':
                try:
                	keyword = translit.rus(s)	
                except:pass
                try:
                	keyword = self.encode(keyword)	
                except:keyword = s      
            else:
                keyword = s
        words = []
        history = self.addon.getSetting('history')
        if history:
        	words = history.split(",")
        if keyword and keyword not in words:
        	words.append(keyword)
        	self.addon.setSetting('history', ','.join(words))
        return keyword
开发者ID:mrstealth,项目名称:xbmc-gotham,代码行数:29,代码来源:default.py

示例3: search

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
def search():
    kbd = xbmc.Keyboard()
    kbd.setDefault('')
    kbd.setHeading(language(2002))
    kbd.doModal()
    keyword=''

    if kbd.isConfirmed():
      keyword = kbd.getText()

    if Addon.getSetting('translit') == 'true':
      keyword = translit.rus(kbd.getText())

    path = "/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' : '30',
      'search_start' : '1',
      'searchdate' : '0',
      'searchuser' : '',
      'showposts' : '0',
      'sortby' : 'date',
      'subaction' : 'search',
      'titleonly' : '3'
    }
    try:
        # Apple TV
        values['story'] = keyword

        data = urllib.urlencode(values)
        req = Request(BASE_URL+path, data)
    except UnicodeEncodeError:
        # Desktop
        values['story'] = keyword.encode('cp1251')

        data = urllib.urlencode(values)
        req = Request(BASE_URL+path, data)

    try:
        response = urlopen(req)
    except URLError, e:
        if hasattr(e, 'reason'):
            print 'We failed to reach a server.'
            print 'Reason: ', e.reason
        elif hasattr(e, 'code'):
            print 'The server couldn\'t fulfill the request.'
            print 'Error code: ', e.code
开发者ID:mrstealth,项目名称:kodi-isengard,代码行数:58,代码来源:default.py

示例4: search

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    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)

            print keyword

            url = 'http://www.videokub.com/search/?q=%s' % (keyword)

            response = urllib2.urlopen(url)

            #response = common.fetchPage({"link": 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.com/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()
开发者ID:arayyani,项目名称:xbmc-plugins,代码行数:56,代码来源:default.py

示例5: getUserInput

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    def getUserInput(self):
        kbd = xbmc.Keyboard()
        kbd.setDefault('')
        kbd.setHeading(self.language(4000))
        kbd.doModal()
        keyword = None

        if kbd.isConfirmed():
            if self.addon.getSetting('translit') == 'true':
                keyword = translit.rus(kbd.getText())
            else:
                keyword = kbd.getText()
        return keyword
开发者ID:faisalz2015,项目名称:xbmc-gotham,代码行数:15,代码来源:default.py

示例6: previous_results

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    def previous_results(self):
        self.log("Show search result")
        search_results = self.search_db.all()

        if search_results:
            for i, result in enumerate(search_results):
                uri = "%s?mode=show&search_id=%d" % (self.xpath, result["id"])
                item = xbmcgui.ListItem(
                    "%02d. %s [%d]" % (result["id"], translit.rus(result["keyword"]), result["counter"]),
                    thumbnailImage=self.icon,
                )
                xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        else:
            item = xbmcgui.ListItem("[COLOR=FFFF4000]%s[/COLOR]" % self.language(2001))
            item.setProperty("IsPlayable", "false")
            xbmcplugin.addDirectoryItem(self.handle, "", item, False)

        xbmc.executebuiltin("Container.SetViewMode(50)")
        xbmcplugin.endOfDirectory(self.handle, True)
开发者ID:Sitronik,项目名称:xbmc-plugins,代码行数:22,代码来源:default.py

示例7: Search

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
def Search(params):
	mode = params['mode'] if 'mode' in params else None
	kbd = xbmc.Keyboard()
	if mode == 'clips': kbd.setHeading("Поиск по клипам")
	else: kbd.setHeading("Поиск")
	kbd.doModal()
	uri = {}
	if kbd.isConfirmed():
		query = kbd.getText()
		if use_translit:
			try:
				query = translit.rus(query)
				print 'detransified search query: ' + query
			except: pass
		query = urllib.quote_plus(query)
	else: return True
	if mode == 'clips': uri['url'] = '/load/'
	else: uri['url'] = '/board'
	uri['post'] = 'query=%s&a=2' % query
	uri['mode'] = 'search'
	ListCat(uri)
开发者ID:serbra,项目名称:ru,代码行数:23,代码来源:default.py

示例8: search

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    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()
开发者ID:alex19pov31,项目名称:xbmc-gotham,代码行数:68,代码来源:default.py

示例9: gettranslit

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
def gettranslit(msg):
    if use_translit == 'true': 
        try: return translit.rus(msg)
        except: return msg
    else: return msg
开发者ID:19pvv52,项目名称:seppius-xbmc-repo,代码行数:7,代码来源:default.py

示例10: search

# 需要导入模块: import Translit [as 别名]
# 或者: from Translit import rus [as 别名]
    def search(self, keyword, unified):
        keyword = translit.rus(keyword) if unified else self.getUserInput()
        unified_search_results = []

        if keyword:
            url = 'http://kinoprosmotr.net/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": keyword,
                "subaction": "search",
                "titleonly": "3"
            }

            headers = {
                "Referer" : 'http://kinoprosmotr.net/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"})

            print containers

            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 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)

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

        else:
            self.menu()
开发者ID:faisalz2015,项目名称:xbmc-gotham,代码行数:79,代码来源:default.py


注:本文中的Translit.rus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。