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


Python Localization类代码示例

本文整理汇总了Python中Localization的典型用法代码示例。如果您正苦于以下问题:Python Localization类的具体用法?Python Localization怎么用?Python Localization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getMagnetInfo

 def getMagnetInfo(self):
     magnetSettings = {
         'url': self.magnetLink,
         'save_path': self.storageDirectory,
         'storage_mode': self.lt.storage_mode_t(0),
         'paused': True,
         #'auto_managed': True,
         #'duplicate_is_error': True
     }
     progressBar = xbmcgui.DialogProgress()
     progressBar.create(Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting'))
     #try:
     self.torrentHandle = self.session.add_torrent(magnetSettings)
     #except:
     #    self.torrentHandle = self.lt.add_magnet_uri(self.session, self.magnetLink, magnetSettings)
     iterator = 0
     while iterator < 100:
         xbmc.sleep(500)
         progressBar.update(iterator, Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting')+'.' * (iterator % 4), ' ')
         iterator += 1
         if progressBar.iscanceled():
             progressBar.update(0)
             progressBar.close()
             return
         if self.torrentHandle.status().has_metadata:
             iterator = 100
     progressBar.update(0)
     progressBar.close()
     if self.torrentHandle.status().has_metadata:
         try:
             info = self.torrentHandle.torrent_file()
         except:
             info = self.torrentHandle.get_torrent_info()
         return info
开发者ID:right21,项目名称:plugin.video.torrenterIL,代码行数:34,代码来源:Libtorrent.py

示例2: registerUser

    def registerUser(self, params = {}):
        if self.__settings__.getSetting("auth"):
            xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Auth'), Localization.localize('Already logged in')))
            return

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=False)
        keyboardUser = xbmc.Keyboard("", Localization.localize("Input Email (for password recovery):"))
        keyboardUser.doModal()
        email = keyboardUser.getText()
        if not email:
            return

        keyboardPass = xbmc.Keyboard("", Localization.localize("Input Password (6+ symbols):"))
        keyboardPass.setHiddenInput(True)
        keyboardPass.doModal()
        password = keyboardPass.getText()
        keyboardPass.setHiddenInput(False)
        if not password:
            return
        try:
            cookieJar = cookielib.CookieJar()
            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))
            value = json.loads(opener.open(self.URL + "/register?email=%s&password=%s" % (email, password)).read().encode('utf-8'))
            if 'logged' == value:
                xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Auth'), Localization.localize('Login successfull')))
                for cookie in cookieJar:
                    if cookie.name == 'PHPSESSID':
                        self.__settings__.setSetting("auth", 'PHPSESSID=' + cookie.value)
            else:
                xbmc.executebuiltin("Notification(%s, %s [%s], 2500)" % (Localization.localize('Auth'), Localization.localize('Login failed'), value))
                self.loginUser()
        except urllib2.HTTPError, e:
            print self.__plugin__ + " registerUser() exception: " + str(e)
开发者ID:DiMartinoX,项目名称:plugin.video.kinopoisk.ru,代码行数:33,代码来源:Core.py

示例3: getContentList

    def getContentList(self):
        self.setup_engine()
        files = []
        filelist = []
        with closing(self.engine):
            self.engine.start()
            #media_types=[MediaType.VIDEO, MediaType.AUDIO, MediaType.SUBTITLES, MediaType.UNKNOWN]

            iterator = 0
            text = Localization.localize('Magnet-link is converting') if self.magnetLink\
                else Localization.localize('Opening torrent file')
            while not files and not xbmc.abortRequested and iterator < 100:
                files = self.engine.list()
                self.engine.check_torrent_error()
                if iterator==4:
                    progressBar = xbmcgui.DialogProgress()
                    progressBar.create(Localization.localize('Please Wait'),
                               Localization.localize('Magnet-link is converting'))
                elif iterator>4:
                    progressBar.update(iterator, Localization.localize('Please Wait'),text+'.' * (iterator % 4), ' ')
                    if progressBar.iscanceled():
                        progressBar.update(0)
                        progressBar.close()
                        return []
                xbmc.sleep(500)
                iterator += 1

            for fs in files:
                stringdata = {"title": fs.name, "size": fs.size, "ind": fs.index,
                              'offset': fs.offset}
                filelist.append(stringdata)
        return filelist
开发者ID:sonics007,项目名称:plugin.video.torrenter,代码行数:32,代码来源:Anteoloader.py

示例4: setup_subs

 def setup_subs(self, label, path):
     iterator = 0
     subs = self.torrent.getSubsIds(label)
     # print str(subs)
     if len(subs) > 0:
         showMessage(Localization.localize('Information'),
                     Localization.localize('Downloading and copy subtitles. Please wait.'), forced=True)
         for ind, title in subs:
             self.torrent.continueSession(ind)
         while iterator < 100:
             xbmc.sleep(1000)
             self.torrent.debug()
             status = self.torrent.torrentHandle.status()
             iterator = int(status.progress * 100)
         # xbmc.sleep(2000)
         for ind, title in subs:
             folder = title.split(os.sep)[0]
             temp = os.path.basename(title)
             addition = os.path.dirname(title).lstrip(folder + os.sep).replace(os.sep, '.').replace(' ', '_').strip()
             ext = temp.split('.')[-1]
             temp = temp[:len(temp) - len(ext) - 1] + '.' + addition + '.' + ext
             newFileName = os.path.join(os.path.dirname(path), temp)
             # print str((os.path.join(os.path.dirname(os.path.dirname(path)),title),newFileName))
             if not xbmcvfs.exists(newFileName):
                 xbmcvfs.copy(os.path.join(os.path.dirname(os.path.dirname(path)), title), newFileName)
开发者ID:kharts,项目名称:plugin.video.torrenter,代码行数:25,代码来源:Player.py

示例5: loop

 def loop(self):
     with closing(
             OverlayText(w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y)) as overlay:
         with nested(self.attach(overlay.show, self.on_playback_paused),
                     self.attach(overlay.hide, self.on_playback_resumed, self.on_playback_stopped)):
             while not xbmc.abortRequested and self.isPlaying() and not self.torrent.threadComplete:
                 self.torrent.checkThread()
                 self.torrent.debug()
                 status = self.torrent.torrentHandle.status()
                 overlay.text = "\n".join(self._get_status_lines(status))
                 # downloadedSize = torrent.torrentHandle.file_progress()[contentId]
                 self.iterator = int(status.progress * 100)
                 xbmc.sleep(1000)
                 if self.iterator == 100 and self.next_dl:
                     next_contentId_index = self.ids_video.index(str(self.contentId)) + 1
                     if len(self.ids_video) > next_contentId_index:
                         self.next_contentId = int(self.ids_video[next_contentId_index])
                     else:
                         self.next_contentId = False
                         # print str(self.next_contentId)+'xxxxxx23'
                 if not self.seeding_run and self.iterator == 100 and self.seeding:
                     self.seeding_run = True
                     self.seed(self.contentId)
                     self.seeding_status = True
                     # xbmc.sleep(7000)
                 if self.iterator == 100 and self.next_dl and not self.next_dling and isinstance(self.next_contentId,
                                                                                                 int) and self.next_contentId != False:
                     showMessage(Localization.localize('Torrent Downloading'),
                                 Localization.localize('Starting download next episode!'), forced=True)
                     self.torrent.stopSession()
                     # xbmc.sleep(1000)
                     path = self.torrent.getFilePath(self.next_contentId)
                     self.basename = self.display_name = os.path.basename(path)
                     self.torrent.continueSession(self.next_contentId)
                     self.next_dling = True
开发者ID:kharts,项目名称:plugin.video.torrenter,代码行数:35,代码来源:Player.py

示例6: getMagnetInfo

 def getMagnetInfo(self):
     magnetSettings = {
         'save_path': self.storageDirectory,
         'storage_mode': self.lt.storage_mode_t(2),
         'paused': True,
         'auto_managed': True,
         'duplicate_is_error': True
     }
     progressBar = xbmcgui.DialogProgress()
     progressBar.create(Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting.'))
     self.torrentHandle = self.lt.add_magnet_uri(self.session, self.magnetLink, magnetSettings)
     iterator = 0
     while not self.torrentHandle.has_metadata():
         time.sleep(0.1)
         progressBar.update(iterator)
         iterator += 1
         if iterator == 100:
             iterator = 0
         if progressBar.iscanceled():
             progressBar.update(0)
             progressBar.close()
             return
     progressBar.update(0)
     progressBar.close()
     return self.torrentHandle.get_torrent_info()
开发者ID:DiMartinoX,项目名称:plugin.video.kinopoisk.ru,代码行数:25,代码来源:Downloader.py

示例7: openSection

 def openSection(self, params = {}):
     get = params.get
     url = urllib.unquote_plus(get("url"))
     try: external=urllib.unquote_plus(get("external"))
     except: external=None
     filesList = []
     if None == get('isApi'):
         progressBar = xbmcgui.DialogProgress()
         progressBar.create(Localization.localize('Please Wait'), Localization.localize('Materials are loading now.'))
         iterator = 0
     searchersList = []
     dirList = os.listdir(self.ROOT + os.sep + 'resources' + os.sep + 'searchers')
     if not external or external=='torrenterall':
         for searcherFile in dirList:
             if re.match('^(\w+)\.py$', searcherFile):
                 searchersList.append(searcherFile)
     else: searchersList.append(external+'.py')
     for searcherFile in searchersList:
         searcher = re.search('^(\w+)\.py$', searcherFile).group(1)
         if searcher:
             if None == get('isApi'):
                 progressBar.update(int(iterator), searcher)
                 iterator += 100 / len(searchersList)
             filesList += self.searchWithSearcher(url, searcher)
         if None == get('isApi') and progressBar.iscanceled():
             progressBar.update(0)
             progressBar.close()
             return
     if None == get('isApi'):
         progressBar.update(0)
         progressBar.close()
     filesList = sorted(filesList, key=lambda x: x[0], reverse=True)
     self.showFilesList(filesList, params)
开发者ID:DiMartinoX,项目名称:plugin.video.kinopoisk.ru,代码行数:33,代码来源:Core.py

示例8: _get_status_lines

 def _get_status_lines(self, s):
     return [
         self.display_name.decode('utf-8'),
         "%.2f%% %s" % (s.progress * 100, Localization.localize(STATE_STRS[s.state]).decode('utf-8')),
         "D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate / 1000, Localization.localize('kb/s').decode('utf-8'),
                                          s.upload_rate / 1000, Localization.localize('kb/s').decode('utf-8'),
                                          s.num_seeds, s.num_peers)
     ]
开发者ID:kharts,项目名称:plugin.video.torrenter,代码行数:8,代码来源:Player.py

示例9: buffer

 def buffer(self):
     iterator = 0
     progressBar = xbmcgui.DialogProgress()
     progressBar.create(
         Localization.localize("Please Wait") + str(" [%s]" % str(self.torrent.lt.version)),
         Localization.localize("Seeds searching."),
     )
     if self.subs_dl:
         subs = self.torrent.getSubsIds(os.path.basename(self.torrent.getFilePath(self.contentId)))
         if len(subs) > 0:
             for ind, title in subs:
                 self.torrent.continueSession(ind)
     num_pieces = int(self.torrent.torrentFileInfo.num_pieces())
     while iterator < 100:
         xbmc.sleep(1000)
         self.torrent.debug()
         downloadedSize = self.torrent.torrentHandle.file_progress()[self.contentId]
         status = self.torrent.torrentHandle.status()
         iterator = int(status.progress * 100)
         if status.state == 0 or (status.progress == 0 and status.num_pieces > 0):
             iterator = int(status.num_pieces * 100 / num_pieces)
             if iterator > 99:
                 iterator = 99
             progressBar.update(iterator, Localization.localize("Checking preloaded files..."), " ", " ")
         elif status.state == 3:
             dialogText = (
                 Localization.localize("Preloaded: ")
                 + str(downloadedSize / 1024 / 1024)
                 + " MB / "
                 + str(self.fullSize / 1024 / 1024)
                 + " MB"
             )
             peersText = " [%s: %s; %s: %s]" % (
                 Localization.localize("Seeds"),
                 str(self.torrent.getSeeds()),
                 Localization.localize("Peers"),
                 str(self.torrent.getPeers()),
             )
             speedsText = "%s: %s Mbit/s; %s: %s Mbit/s" % (
                 Localization.localize("Downloading"),
                 str(self.torrent.getDownloadRate() * 8 / 1000000),
                 Localization.localize("Uploading"),
                 str(self.torrent.getUploadRate() * 8 / 1000000),
             )
             progressBar.update(
                 iterator, Localization.localize("Seeds searching.") + peersText, dialogText, speedsText
             )
         else:
             progressBar.update(iterator, Localization.localize("UNKNOWN STATUS"), " ", " ")
         if progressBar.iscanceled():
             progressBar.update(0)
             progressBar.close()
             self.torrent.threadComplete = True
             self.torrent.checkThread()
             return
     progressBar.update(0)
     progressBar.close()
     return True
开发者ID:Inter95,项目名称:tutvguia,代码行数:58,代码来源:Player.py

示例10: logoutUser

 def logoutUser(self, params = {}):
     if not self.__settings__.getSetting("auth"):
         xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Auth'), Localization.localize('User not logged in')))
         return
     self.__settings__.setSetting("auth", '')
     cookieJar = cookielib.CookieJar()
     opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))
     opener.open(self.URL + "/logout").read()
     xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Auth'), Localization.localize('User successfully logged out')))
     xbmc.executebuiltin("Container.Refresh()")
开发者ID:DiMartinoX,项目名称:plugin.video.kinopoisk.ru,代码行数:10,代码来源:Core.py

示例11: addBookmark

 def addBookmark(self, params = {}):
     get = params.get
     if 0 < len(self.__settings__.getSetting("auth")):
         response = json.loads(self.fetchData(self.URL + '/bookmarks/add?link=%s&name=%s&seeds=%s&image=%s' % (get("url"), get('name'), get('seeds'), get('image'))).encode('utf-8'))
         if not self.checkForAuth(response):
             return
         if 'added' == response:
             xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Bookmark'), Localization.localize('Item successfully added to Bookmarks')))
         else:
             xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Bookmark'), Localization.localize('Bookmark not added')))
开发者ID:DiMartinoX,项目名称:plugin.video.kinopoisk.ru,代码行数:10,代码来源:Core.py

示例12: first_time

 def first_time(self):
     scrapers = {'tvdb': 'TheTVDB.com', 'tmdb': 'TheMovieDB.org', 'kinopoisk': 'KinoPoisk.ru'}
     ok = xbmcgui.Dialog().yesno(Localization.localize('Content Lists'),
                                 Localization.localize('Do you want to preload full metadata?') + ' (%s)' % (
                                     scrapers[os.path.basename(self.filename).split('.')[0]]),
                                 Localization.localize('It is highly recommended!'))
     if ok:
         return self.download()
     else:
         return False
开发者ID:Stevie-Bs,项目名称:repository.xvbmc,代码行数:10,代码来源:cache.py

示例13: removeBookmark

 def removeBookmark(self, params = {}):
     get = params.get
     if 0 < len(self.__settings__.getSetting("auth")):
         response = json.loads(self.fetchData(self.URL + '/bookmarks/remove?id=%s' % (get("id"))).encode('utf-8'))
         if not self.checkForAuth(response):
             return
         if 'removed' == response:
             xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Bookmark'), Localization.localize('Item successfully removed from Bookmarks')))
             xbmc.executebuiltin("Container.Refresh()")
         else:
             xbmc.executebuiltin("Notification(%s, %s, 2500)" % (Localization.localize('Bookmark'), Localization.localize('Bookmark not removed')))
开发者ID:DiMartinoX,项目名称:plugin.video.kinopoisk.ru,代码行数:11,代码来源:Core.py

示例14: __init__

    def __init__(self, userStorageDirectory, torrentUrl, params={}):
        self.userStorageDirectory = userStorageDirectory
        self.torrentUrl = torrentUrl
        xbmc.Player.__init__(self)
        print ("[TorrentPlayer] Initalized")
        self.params = params
        self.get = self.params.get
        self.contentId = int(self.get("url"))
        self.torrent = Downloader.Torrent(self.userStorageDirectory, self.torrentUrl, self.torrentFilesDirectory).player
        try:
            if self.get("url2"):
                self.ids_video = urllib.unquote_plus(self.get("url2")).split(",")
            else:
                self.ids_video = self.get_ids()
        except:
            pass
        self.init()
        self.setup_torrent()
        if self.buffer():
            while True:
                if self.setup_play():
                    # print '************************************* GOING LOOP'
                    self.torrent.continueSession(self.contentId)
                    self.loop()
                else:
                    break
                # print '************************************* GO NEXT?'
                if self.next_dl and self.next_dling and isinstance(self.next_contentId, int) and self.iterator == 100:
                    self.contentId = self.next_contentId
                    continue
                # print '************************************* NO! break'
                break

        self.torrent.stopSession()
        self.torrent.threadComplete = True
        self.torrent.checkThread()
        if "false" == self.__settings__.getSetting("keep_files"):
            clearStorage(self.userStorageDirectory)
        else:
            if self.seeding_status:
                showMessage(
                    Localization.localize("Information"),
                    Localization.localize("Torrent is seeding. To stop it use Download Status."),
                    forced=True,
                )
            else:
                if self.seeding:
                    self.db_delete()
                showMessage(
                    Localization.localize("Information"),
                    Localization.localize("Torrent downloading is stopped."),
                    forced=True,
                )
开发者ID:Inter95,项目名称:tutvguia,代码行数:53,代码来源:Player.py

示例15: getContentList

 def getContentList(self):
     filelist = []
     try:
         for contentId, contentFile in enumerate(self.torrentFileInfo.files()):
             stringdata = {"title": contentFile.path, "size": contentFile.size, "ind": int(contentId),
                           'offset': contentFile.offset}
             filelist.append(stringdata)
         return filelist
     except:
         xbmcgui.Dialog().ok(Localization.localize('Python-Libtorrent Not Found'),
                             Localization.localize(self.platform["message"][0]),
                             Localization.localize(self.platform["message"][1]))
         return
开发者ID:kharts,项目名称:plugin.video.torrenter,代码行数:13,代码来源:Libtorrent.py


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