android support in script.module.libtorrent

pull/1/head
DiMartinoXBMC 2015-07-11 12:58:33 +03:00
parent f464681cde
commit 818fe4606b
3 changed files with 39 additions and 21 deletions

21
Core.py
View File

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

View File

@ -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:

View File

@ -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.': 'Йде пошук сідів.',