diff --git a/Core.py b/Core.py index 779ede6..38fcc71 100644 --- a/Core.py +++ b/Core.py @@ -32,6 +32,7 @@ from functions import * from resources.utorrent.net import * from resources.scrapers.scrapers import Scrapers from resources.skins.DialogXml import * +from platform_pulsar import get_platform class Core: @@ -40,6 +41,7 @@ class Core: ROOT = sys.modules["__main__"].__root__ #.decode('utf-8').encode(sys.getfilesystemencoding()) userStorageDirectory = file_encode(__settings__.getSetting("storage")) torrentFilesDirectory = 'torrents' + platform = get_platform() debug = __settings__.getSetting('debug') == 'true' torrent_player=__settings__.getSetting("torrent_player") history_bool = __settings__.getSetting('history') == 'true' @@ -68,17 +70,26 @@ class Core: def __init__(self): if 0 == len(self.userStorageDirectory): - try: - temp_dir = tempfile.gettempdir() - except: - temp_dir = tempdir() + try: + temp_dir = tempfile.gettempdir() + except: + if not self.platform['system']=='android': + temp_dir = tempdir() + else: + dialog=xbmcgui.Dialog() + dialog.ok(self.localize('Android Support'), + self.localize('Android has no temprorary folder'), + self.localize('Please specify storage folder in Settings!')) + self.__settings__.openSettings() + temp_dir = file_encode(self.__settings__.getSetting("storage")) + else: temp_dir = self.userStorageDirectory self.userStorageDirectory = os.path.join(temp_dir, 'Torrenter') def sectionMenu(self): if self.__settings__.getSetting('plugin_name')!=self.__plugin__: - if self.__plugin__ == 'Torrenter v.2.3.0': + if self.__plugin__ == 'Torrenter v.2.3.1': first_run_230(self.__settings__.getSetting('delete_russian')=='true') if self.__settings__.getSetting('delete_russian')!='false': not_russian=delete_russian(ok=self.__settings__.getSetting('delete_russian')=='true', action='delete') diff --git a/Libtorrent.py b/Libtorrent.py index 5642e99..89e4193 100644 --- a/Libtorrent.py +++ b/Libtorrent.py @@ -26,6 +26,7 @@ import hashlib import re from StringIO import StringIO import gzip +import imp import xbmc import xbmcgui @@ -33,6 +34,7 @@ import xbmcvfs import Localization from platform_pulsar import get_platform from functions import file_decode, file_encode, isSubtitle, DownloadDB +from ctypes import * class Libtorrent: @@ -49,27 +51,23 @@ class Libtorrent: lt = None def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'): - - ''' - #from ctypes import * - #cdll.LoadLibrary(dirname + '/libtorrent-rasterbar.so.7')''' - self.platform = get_platform() try: import libtorrent - print '[script.module.libtorrent]: Imported libtorrent v' + libtorrent.version + ' from system' + print '[Torrenter v2]: Imported libtorrent v' + libtorrent.version + ' from system' except Exception, e: - print '[script.module.libtorrent]: Error importing from system. Exception: ' + str(e) - import python_libtorrent as libtorrent + print '[Torrenter v2]: Error importing from system. Exception: ' + str(e) + from python_libtorrent import get_libtorrent + libtorrent=get_libtorrent() try: self.lt = libtorrent del libtorrent - print 'Imported libtorrent v' + self.lt.version + ' from python_libtorrent.' + self.platform[ + print '[Torrenter v2]: Imported libtorrent v' + self.lt.version + ' from python_libtorrent.' + self.platform[ 'system'] except Exception, e: - print 'Error importing python_libtorrent.' + self.platform['system'] + '. Exception: ' + str(e) + print '[Torrenter v2]: Error importing python_libtorrent.' + self.platform['system'] + '. Exception: ' + str(e) xbmcgui.Dialog().ok(Localization.localize('Python-Libtorrent Not Found'), Localization.localize(self.platform["message"][0]), Localization.localize(self.platform["message"][1])) @@ -335,12 +333,18 @@ class Libtorrent: def encryptSession(self): # Encryption settings - encryption_settings = self.lt.pe_settings() - encryption_settings.out_enc_policy = self.lt.enc_policy(self.lt.enc_policy.forced) - encryption_settings.in_enc_policy = self.lt.enc_policy(self.lt.enc_policy.forced) - encryption_settings.allowed_enc_level = self.lt.enc_level.both - encryption_settings.prefer_rc4 = True - self.session.set_pe_settings(encryption_settings) + print '[Torrenter v2]: Encryption enabling...' + try: + encryption_settings = self.lt.pe_settings() + encryption_settings.out_enc_policy = self.lt.enc_policy(self.lt.enc_policy.forced) + encryption_settings.in_enc_policy = self.lt.enc_policy(self.lt.enc_policy.forced) + encryption_settings.allowed_enc_level = self.lt.enc_level.both + encryption_settings.prefer_rc4 = True + self.session.set_pe_settings(encryption_settings) + print '[Torrenter v2]: Encryption on!' + except Exception, e: + print '[Torrenter v2]: Encryption failed! Exception: ' + str(e) + pass def startSession(self): if None == self.magnetLink: diff --git a/Localization.py b/Localization.py index b30d5b3..12ca2d1 100644 --- a/Localization.py +++ b/Localization.py @@ -254,6 +254,9 @@ def localize(text): 'Now you can use your login on trackers or write and install your own searcher!':'Теперь можно использовать свой логин или даже написать и установить свой серчер.', 'Would you like to install %s from "MyShows.me Kodi Repo" in Programs section?':'Хотите установить %s из "MyShows.me Kodi Repo" в Программах?', 'Open installation window?':'Открыть окно установки?', + 'Android Support':'Поддержка Android', + 'Android has no temprorary folder':'У Android отсутствует стандартная временная папка', + 'Please specify storage folder in Settings!':'Пожалуйста, укажите папку хранилища файлов!', }, 'uk': { 'Seeds searching.': 'Йде пошук сідів.',