From 344030d01f7d09d5bd4f2f596a23862d5d27c445 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sun, 19 Jul 2015 00:44:38 +0300 Subject: [PATCH] trans fix --- Core.py | 14 ++++++++++---- Libtorrent.py | 10 ++++++---- Localization.py | 2 +- SearcherABC.py | 12 +++++++++++- functions.py | 1 + 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Core.py b/Core.py index 98c5e37..c86339f 100644 --- a/Core.py +++ b/Core.py @@ -904,10 +904,10 @@ class Core: contextMenu = [ (self.localize('Download via T-client'), 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % ( - sys.argv[0], 'downloadFilesList', urllib.quote_plus('%s::%s' % (provider, info.get('link'))))), + sys.argv[0], 'downloadFilesList', urllib.quote_plus(link['url']))), (self.localize('Download via Libtorrent'), 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % ( - sys.argv[0], 'downloadLibtorrent', urllib.quote_plus('%s::%s' % (provider, info.get('link'))))) + sys.argv[0], 'downloadLibtorrent', urllib.quote_plus(link['url']))) ] if isinstance(info, dict) and info.get('infolink'): @@ -1623,11 +1623,16 @@ class Core: dirname = keyboard.getText() if not keyboard.isConfirmed(): return - if not dirname and len(clean)>0: + if dirname in ['',None,0] and len(clean)>0: dirname = clean[0] else: dirname = self.__settings__.getSetting("torrent_dir") + if dirname=='': + log('[downloadFilesList] dirname: \'\'') + else: + log('[downloadFilesList] dirname:'+str(dirname)) + get = params.get url = unquote(get("url"), self.__settings__.getSetting("lastTorrent").decode('utf-8')) ind = get("ind") @@ -1635,6 +1640,7 @@ class Core: self.__settings__.setSetting("lastTorrentUrl", url) classMatch = re.search('(\w+)::(.+)', url) if classMatch: + debug('[downloadFilesList] classMatch:'+str(classMatch.group(1))+' '+str(classMatch.group(2))) if re.match("^magnet\:.+$", classMatch.group(2)) and dirname: url=classMatch.group(2) else: @@ -1645,7 +1651,7 @@ class Core: torrentFilesDirectory=self.torrentFilesDirectory) if re.match("^magnet\:.+$", url): - if not dirname: + if dirname in [None,0]: torrent.magnetToTorrent(url) url = torrent.torrentFile else: diff --git a/Libtorrent.py b/Libtorrent.py index 9143aa5..3659b61 100644 --- a/Libtorrent.py +++ b/Libtorrent.py @@ -146,17 +146,19 @@ class Libtorrent: 'duplicate_is_error': True } progressBar = xbmcgui.DialogProgress() - progressBar.create(Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting.')) + 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() and iterator != 100: - progressBar.update(iterator) + 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 - xbmc.sleep(500) + if self.torrentHandle.has_metadata(): + iterator = 100 progressBar.update(0) progressBar.close() if self.torrentHandle.has_metadata(): diff --git a/Localization.py b/Localization.py index f2639b0..cfc04b6 100644 --- a/Localization.py +++ b/Localization.py @@ -41,7 +41,7 @@ def localize(text): 'Peers': 'Пиры', 'Materials are loading now.': 'Идёт загрузка материалов.', 'Search Phrase': 'Фраза для поиска', - 'Magnet-link is converting.': 'Идёт преобразование magnet-ссылки.', + 'Magnet-link is converting': 'Идёт преобразование magnet-ссылки', 'Error': 'Ошибка', 'Your library out of date and can\'t save magnet-links.': 'Ваша библиотека устарела и не может сохранять магнет-ссылки.', 'Bookmarks': 'Закладки', diff --git a/SearcherABC.py b/SearcherABC.py index 760b000..ba929cf 100644 --- a/SearcherABC.py +++ b/SearcherABC.py @@ -225,4 +225,14 @@ class SearcherABC: log(msg) def debug(self, msg): - debug(msg) \ No newline at end of file + debug(msg) + + def open2(self, url=''): + import httplib + conn = httplib.HTTPConnection(self.baseurl) + conn.request("GET", str(url)) + r1 = conn.getresponse() + status = str(r1.status) + " " + r1.reason + content = r1.read() + self.debug('[open2] status:'+str(status)) + return content \ No newline at end of file diff --git a/functions.py b/functions.py index 22fb750..9c997c8 100644 --- a/functions.py +++ b/functions.py @@ -123,6 +123,7 @@ def debug(msg): def showMessage(heading, message, times=10000, forced=False): xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s, "%s")' % ( heading.replace('"', "'"), message.replace('"', "'"), times, icon)) + debug(str((heading.replace('"', "'"), message.replace('"', "'"), times, icon))) def magnet_alert():