choose hash auto
parent
81d4e22eed
commit
6f7e0548a8
38
Core.py
38
Core.py
|
@ -1793,11 +1793,15 @@ class Core:
|
||||||
f = open(url, 'rb')
|
f = open(url, 'rb')
|
||||||
torrent = f.read()
|
torrent = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
from python_libtorrent import get_libtorrent
|
||||||
|
libtorrent = get_libtorrent()
|
||||||
|
info = libtorrent.torrent_info(libtorrent.bdecode(torrent))
|
||||||
|
name = info.name()
|
||||||
success = Download().add(torrent, dirname)
|
success = Download().add(torrent, dirname)
|
||||||
if success:
|
if success:
|
||||||
showMessage(self.localize('Torrent-client Browser'), self.localize('Added!'), forced=True)
|
showMessage(self.localize('Torrent-client Browser'), self.localize('Added!'), forced=True)
|
||||||
if ind:
|
if ind:
|
||||||
id = self.chooseHASH(Download().list())[0]
|
id = self.chooseHASH(Download().list(), name)[0]
|
||||||
Download().setprio(id, ind)
|
Download().setprio(id, ind)
|
||||||
|
|
||||||
def downloadLibtorrent(self, params={}):
|
def downloadLibtorrent(self, params={}):
|
||||||
|
@ -1877,7 +1881,7 @@ class Core:
|
||||||
else:
|
else:
|
||||||
self.openSection(params)
|
self.openSection(params)
|
||||||
|
|
||||||
def chooseHASH(self, list):
|
def chooseHASH(self, list, name = None):
|
||||||
dialog_items, dialog_items_clean = [], []
|
dialog_items, dialog_items_clean = [], []
|
||||||
dialog_files = []
|
dialog_files = []
|
||||||
dat = list
|
dat = list
|
||||||
|
@ -1887,14 +1891,30 @@ class Core:
|
||||||
for data in dat:
|
for data in dat:
|
||||||
dialog_files.append((data['id'], data['dir'].encode('utf-8')))
|
dialog_files.append((data['id'], data['dir'].encode('utf-8')))
|
||||||
dialog_items.append('[' + str(data['progress']) + '%] ' + data['name'])
|
dialog_items.append('[' + str(data['progress']) + '%] ' + data['name'])
|
||||||
if len(dialog_items) > 1:
|
dialog_items_clean.append(data['name'])
|
||||||
ret = xbmcgui.Dialog().select(self.localize('Choose in torrent-client:'), dialog_items)
|
|
||||||
if ret > -1 and ret < len(dialog_files):
|
|
||||||
hash = dialog_files[ret]
|
log('[chooseHASH]: name %s ' % str(name))
|
||||||
|
for data in dat:
|
||||||
|
# Debug('[chooseHASH]: '+str((data['name'], data['id'], data['dir'].encode('utf-8'))))
|
||||||
|
dialog_files.append((data['id'], data['dir'].encode('utf-8')))
|
||||||
|
dialog_items.append('[' + str(data['progress']) + '%] ' + data['name'])
|
||||||
|
dialog_items_clean.append(data['name'])
|
||||||
|
|
||||||
|
if name:
|
||||||
|
if decode_str(name) in dialog_items_clean:
|
||||||
|
return dialog_files[dialog_items_clean.index(decode_str(name))]
|
||||||
|
elif name in dialog_items_clean:
|
||||||
|
return dialog_files[dialog_items_clean.index(name)]
|
||||||
|
else:
|
||||||
|
if len(dialog_items) > 1:
|
||||||
|
ret = xbmcgui.Dialog().select(self.localize('Choose in torrent-client:'), dialog_items)
|
||||||
|
if ret > -1 and ret < len(dialog_files):
|
||||||
|
hash = dialog_files[ret]
|
||||||
|
return hash
|
||||||
|
elif len(dialog_items) == 1:
|
||||||
|
hash = dialog_files[0]
|
||||||
return hash
|
return hash
|
||||||
elif len(dialog_items) == 1:
|
|
||||||
hash = dialog_files[0]
|
|
||||||
return hash
|
|
||||||
|
|
||||||
def localize(self, string):
|
def localize(self, string):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -2147,6 +2147,11 @@ def encode_msg(msg):
|
||||||
msg = ensure_str(msg)
|
msg = ensure_str(msg)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
def decode_str(string, encoding='utf-8'):
|
||||||
|
if not isinstance(string, unicode):
|
||||||
|
string = string.decode(encoding)
|
||||||
|
return string
|
||||||
|
|
||||||
def get_platform():
|
def get_platform():
|
||||||
ret = {
|
ret = {
|
||||||
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
|
"arch": sys.maxsize > 2 ** 32 and "x64" or "x86",
|
||||||
|
|
Loading…
Reference in New Issue