Torrent Aggiustamenti e pulizia
This commit is contained in:
@@ -32,38 +32,27 @@ from .functions import *
|
||||
import xbmc, xbmcaddon
|
||||
import sys
|
||||
import os
|
||||
import traceback ### Alfa
|
||||
import traceback
|
||||
|
||||
|
||||
#__settings__ = xbmcaddon.Addon(id='script.module.libtorrent') ### Alfa
|
||||
#__version__ = __settings__.getAddonInfo('version') ### Alfa
|
||||
#__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__ ### Alfa
|
||||
#__settings__ = xbmcaddon.Addon(id='plugin.video.kod') ### Alfa
|
||||
__version__ = '1.1.17' ### Alfa
|
||||
__plugin__ = "python-libtorrent v.1.1.7" ### Alfa
|
||||
#__language__ = __settings__.getLocalizedString ### Alfa
|
||||
__version__ = '1.1.17'
|
||||
__plugin__ = "python-libtorrent v.1.1.7"
|
||||
__root__ = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
libtorrent=None
|
||||
platform = get_platform()
|
||||
#set_dirname=__settings__.getSetting('dirname') ### Alfa
|
||||
#set_dirname=os.path.join(__settings__.getAddonInfo('Path'),'lib', 'python_libtorrent') ### Alfa
|
||||
set_dirname=__root__ ### Alfa
|
||||
set_dirname=__root__
|
||||
if getSettingAsBool('custom_dirname') and set_dirname:
|
||||
log('set_dirname:' +str(set_dirname))
|
||||
dirname=set_dirname
|
||||
else:
|
||||
#dirname = os.path.join(xbmc.translatePath('special://temp'), 'xbmcup', 'script.module.libtorrent',
|
||||
# 'python_libtorrent')
|
||||
dirname=set_dirname ### Alfa
|
||||
dirname=set_dirname
|
||||
|
||||
log('dirname: ' +str(dirname))
|
||||
|
||||
#versions = ['0.16.19', '1.0.6', '1.0.7', '1.0.8', '1.0.9', '1.0.11', '1.1.0', '1.1.1', '1.1.6', '1.1.7', '1.2.2', '1.2.3'] ### Alfa
|
||||
versions = ['0.16.19', '1.0.6', '1.0.7', '1.0.8', '1.0.9', '1.0.11', '1.1.0', '1.1.1', '1.1.6', '1.1.7', '1.2.2'] ### Alfa
|
||||
#versions = ['0.16.19', '1.0.6', '1.0.7', '1.0.8', '1.0.9', '1.0.11', '1.1.0', '1.1.1', '1.1.6', '1.1.7', '1.2.2', '1.2.3']
|
||||
versions = ['0.16.19', '1.0.6', '1.0.7', '1.0.8', '1.0.9', '1.0.11', '1.1.0', '1.1.1', '1.1.6', '1.1.7', '1.2.2']
|
||||
default_path = versions[-1]
|
||||
#set_version = int(__settings__.getSetting('set_version')) ### Alfa
|
||||
set_version = 0 ### Alfa
|
||||
set_version = 0
|
||||
if getSettingAsBool('custom_version'):
|
||||
log('set_version:' +str(set_version)+' '+versions[set_version])
|
||||
platform['version'] = versions[set_version]
|
||||
@@ -101,12 +90,8 @@ if not lm.check_exist():
|
||||
xbmc.sleep(2000)
|
||||
|
||||
|
||||
#if __settings__.getSetting('plugin_name')!=__plugin__: ### Alfa
|
||||
# __settings__.setSetting('plugin_name', __plugin__) ### Alfa
|
||||
# lm.update() ### Alfa
|
||||
|
||||
log('platform: ' + str(platform))
|
||||
if platform['system'] not in ['windows', 'windows_x64']: ### Alfa
|
||||
if platform['system'] not in ['windows', 'windows_x64']:
|
||||
log('os: '+str(os.uname()))
|
||||
log_text = 'ucs4' if sys.maxunicode > 65536 else 'ucs2'
|
||||
log_text += ' x64' if sys.maxsize > 2147483647 else ' x86'
|
||||
@@ -118,18 +103,18 @@ try:
|
||||
description = ''
|
||||
libtorrent = ''
|
||||
from platformcode import config
|
||||
|
||||
|
||||
if platform['system'] in ['linux_x86', 'windows', 'windows_x64', 'linux_armv6', 'linux_armv7',
|
||||
'linux_x86_64', 'linux_mipsel_ucs2', 'linux_mipsel_ucs4',
|
||||
'linux_aarch64_ucs2', 'linux_aarch64_ucs4']: ### Alfa
|
||||
'linux_aarch64_ucs2', 'linux_aarch64_ucs4']:
|
||||
import libtorrent
|
||||
|
||||
|
||||
elif PY3 and platform['system'] not in ['android_armv7', 'android_x86']:
|
||||
import libtorrent ### Alfa
|
||||
|
||||
import libtorrent
|
||||
|
||||
elif platform['system'] in ['darwin', 'ios_arm']:
|
||||
import imp
|
||||
|
||||
|
||||
path_list = [dest_path]
|
||||
log('path_list = ' + str(path_list))
|
||||
fp, pathname, description = imp.find_module('libtorrent', path_list)
|
||||
@@ -140,12 +125,12 @@ try:
|
||||
libtorrent = imp.load_module('libtorrent', fp, pathname, description)
|
||||
finally:
|
||||
if fp: fp.close()
|
||||
|
||||
|
||||
elif platform['system'] in ['android_armv7', 'android_x86']:
|
||||
try:
|
||||
import imp
|
||||
from ctypes import CDLL
|
||||
|
||||
|
||||
dest_path=lm.android_workaround(os.path.join(xbmc.translatePath('special://xbmc/'), 'files').replace('/cache/apk/assets', ''))
|
||||
dll_path=os.path.join(dest_path, 'liblibtorrent.so')
|
||||
log('CDLL path = ' + dll_path)
|
||||
@@ -164,8 +149,8 @@ try:
|
||||
except Exception as e:
|
||||
if not PY3:
|
||||
e = unicode(str(e), "utf8", errors="replace").encode("utf8")
|
||||
config.set_setting("libtorrent_path", "", server="torrent") ### Alfa
|
||||
config.set_setting("libtorrent_error", str(e), server="torrent") ### Alfa
|
||||
config.set_setting("libtorrent_path", "", server="torrent")
|
||||
config.set_setting("libtorrent_error", str(e), server="torrent")
|
||||
log(traceback.format_exc(1))
|
||||
log('fp = ' + str(fp))
|
||||
log('pathname = ' + str(pathname))
|
||||
@@ -174,7 +159,7 @@ try:
|
||||
if fp: fp.close()
|
||||
|
||||
# If no permission in dest_path we need to go deeper on root!
|
||||
try: ### Alfa START
|
||||
try:
|
||||
sys_path = '/data/app/'
|
||||
fp = ''
|
||||
pathname = sys_path
|
||||
@@ -186,7 +171,7 @@ try:
|
||||
dialog = xbmcgui.Dialog()
|
||||
dialog.notification('KoD: '+ config.get_localizad_string(70766), config.get_localizad_string(70767), time=15000)
|
||||
config.set_setting("libtorrent_msg", 'OK', server="torrent")
|
||||
|
||||
|
||||
from core import scrapertools
|
||||
kodi_app = xbmc.translatePath('special://xbmc')
|
||||
kodi_app = scrapertools.find_single_match(kodi_app, '\/\w+\/\w+\/.*?\/(.*?)\/')
|
||||
@@ -201,10 +186,10 @@ try:
|
||||
output_cmd, error_cmd = p.communicate()
|
||||
log('Comando ROOT: %s' % str(command))
|
||||
dir_list = output_cmd.split()
|
||||
|
||||
|
||||
if not dir_list:
|
||||
raise
|
||||
|
||||
|
||||
for file in dir_list:
|
||||
if kodi_app in file:
|
||||
kodi_dir = file
|
||||
@@ -228,12 +213,12 @@ try:
|
||||
if fp: fp.close()
|
||||
else:
|
||||
import libtorrent
|
||||
|
||||
|
||||
except Exception as e:
|
||||
log('ERROR Comando ROOT: %s, %s' % (str(command), str(dest_path)))
|
||||
if not PY3:
|
||||
e = unicode(str(e), "utf8", errors="replace").encode("utf8")
|
||||
log(traceback.format_exc(1)) ### Alfa
|
||||
log(traceback.format_exc(1))
|
||||
log('fp = ' + str(fp))
|
||||
log('pathname = ' + str(pathname))
|
||||
log('description = ' + str(description))
|
||||
@@ -241,15 +226,15 @@ try:
|
||||
if fp: fp.close()
|
||||
|
||||
if libtorrent:
|
||||
config.set_setting("libtorrent_path", dest_path, server="torrent") ### Alfa
|
||||
config.set_setting("libtorrent_error", "", server="torrent") ### Alfa
|
||||
config.set_setting("libtorrent_path", dest_path, server="torrent")
|
||||
config.set_setting("libtorrent_error", "", server="torrent")
|
||||
log('Imported libtorrent v' + libtorrent.version + ' from "' + dest_path + '"')
|
||||
|
||||
except Exception as e:
|
||||
if not PY3:
|
||||
e = unicode(str(e), "utf8", errors="replace").encode("utf8")
|
||||
config.set_setting("libtorrent_path", "", server="torrent") ### Alfa
|
||||
config.set_setting("libtorrent_error", str(e), server="torrent") ### Alfa
|
||||
config.set_setting("libtorrent_path", "", server="torrent")
|
||||
config.set_setting("libtorrent_error", str(e), server="torrent")
|
||||
log('Error importing libtorrent from "' + dest_path + '". Exception: ' + str(e))
|
||||
if fp: fp.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user