save
parent
d985d5e2ca
commit
32afdf2afa
|
@ -184,6 +184,10 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
def navi_back(self):
|
def navi_back(self):
|
||||||
log('navi_back init')
|
log('navi_back init')
|
||||||
self.navi['route'].pop(-1)
|
self.navi['route'].pop(-1)
|
||||||
|
self.navi_restore()
|
||||||
|
|
||||||
|
def navi_restore(self):
|
||||||
|
log('navi_restore init')
|
||||||
route = self.navi['route'][-1]
|
route = self.navi['route'][-1]
|
||||||
action = getattr(self, route['mode'])
|
action = getattr(self, route['mode'])
|
||||||
if route['params']:
|
if route['params']:
|
||||||
|
@ -227,7 +231,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
self.navi['last_right_button'] = self.navi['right_menu'].index(focused_control) + 1
|
self.navi['last_right_button'] = self.navi['right_menu'].index(focused_control) + 1
|
||||||
self.update_navigation()
|
self.update_navigation()
|
||||||
|
|
||||||
def navi_route(self, mode, params = {}, last_listing_item = 0):
|
def navi_route(self, mode, params = {}, right_menu = None):
|
||||||
log('navi_route init')
|
log('navi_route init')
|
||||||
try:
|
try:
|
||||||
focused_control = self.getFocus()
|
focused_control = self.getFocus()
|
||||||
|
@ -235,10 +239,11 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
focused_control = None
|
focused_control = None
|
||||||
|
|
||||||
if focused_control in self.navi['top_menu']:
|
if focused_control in self.navi['top_menu']:
|
||||||
|
log('focused_control in self.navi[\'top_menu\']')
|
||||||
self.navi['route'] = [self.navi['route'][0]]
|
self.navi['route'] = [self.navi['route'][0]]
|
||||||
|
|
||||||
elif not params or not params.get('back'):
|
if not params or not params.get('back'):
|
||||||
log('***** self.navi[\'route\'].append *****' + str(mode) + str(params) + str(last_listing_item))
|
log('***** self.navi[\'route\'].append *****' + str(mode) + str(params))
|
||||||
if not params:
|
if not params:
|
||||||
params = {'back': True}
|
params = {'back': True}
|
||||||
else:
|
else:
|
||||||
|
@ -246,8 +251,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
|
|
||||||
self.navi['route'].append({'mode': mode,
|
self.navi['route'].append({'mode': mode,
|
||||||
'params': params,
|
'params': params,
|
||||||
'last_listing_item': last_listing_item})
|
'last_listing_item': 0})
|
||||||
self.right_menu(mode)
|
self.right_menu(mode if not right_menu else right_menu)
|
||||||
self.listing.reset()
|
self.listing.reset()
|
||||||
|
|
||||||
def search(self, params = {}):
|
def search(self, params = {}):
|
||||||
|
@ -337,9 +342,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
|
|
||||||
self.history()
|
self.history()
|
||||||
|
|
||||||
def watched(self):
|
def watched(self, params = {}):
|
||||||
self.right_menu('watched')
|
self.navi_route('watched', params)
|
||||||
self.listing.reset()
|
|
||||||
|
|
||||||
db = WatchedHistoryDB()
|
db = WatchedHistoryDB()
|
||||||
|
|
||||||
|
@ -401,19 +405,21 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
showMessage(self.localize('Watched History'), self.localize('Clear!'))
|
showMessage(self.localize('Watched History'), self.localize('Clear!'))
|
||||||
self.watched()
|
self.watched()
|
||||||
|
|
||||||
def browser(self, hash = None, tdir = None):
|
def browser(self, params = {}):
|
||||||
from resources.utorrent.net import Download
|
from resources.utorrent.net import Download
|
||||||
self.listing.reset()
|
|
||||||
menu, dirs = [], []
|
menu, dirs = [], []
|
||||||
|
|
||||||
|
get = params.get
|
||||||
|
hash = get('hash')
|
||||||
|
tdir = get('tdir')
|
||||||
|
|
||||||
DownloadList = Download().list()
|
DownloadList = Download().list()
|
||||||
if DownloadList == False:
|
if DownloadList == False:
|
||||||
showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True)
|
showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not hash:
|
if not hash:
|
||||||
self.right_menu('browser')
|
self.navi_route('browser')
|
||||||
#self.reconnect(pyxbmct.ACTION_NAV_BACK, self.history)
|
|
||||||
for data in DownloadList:
|
for data in DownloadList:
|
||||||
status = " "
|
status = " "
|
||||||
img = ''
|
img = ''
|
||||||
|
@ -431,12 +437,11 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
img = os.path.join(__root__, 'icons', 'download-icon.png')
|
img = os.path.join(__root__, 'icons', 'download-icon.png')
|
||||||
|
|
||||||
title = '[%s%%]%s%s [%s]' % (str(data['progress']), status, data['name'], str(data['ratio']))
|
title = '[%s%%]%s%s [%s]' % (str(data['progress']), status, data['name'], str(data['ratio']))
|
||||||
# title = '[' + str(data['progress']) + '%]' + status + data['name'] + ' [' + str(data['ratio']) + ']'
|
|
||||||
menu.append(
|
menu.append(
|
||||||
{"title": title, "image": img, "argv": {'mode': 'browser_item', 'hash': str(data['id'])}})
|
{"title": title, "image": img, "argv": {'mode': 'browser_item', 'hash': str(data['id'])}})
|
||||||
|
|
||||||
elif not tdir:
|
elif not tdir:
|
||||||
self.right_menu('browser_subfolder')
|
self.navi_route('browser', params, 'browser_subfolder')
|
||||||
#self.reconnect(pyxbmct.ACTION_NAV_BACK, self.browser)
|
|
||||||
self.drawItem('..', {'mode': 'browser_moveup'}, image = 'DefaultFolderBack.png', isFolder = True)
|
self.drawItem('..', {'mode': 'browser_moveup'}, image = 'DefaultFolderBack.png', isFolder = True)
|
||||||
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
|
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
|
||||||
for name, percent, ind, size in dllist:
|
for name, percent, ind, size in dllist:
|
||||||
|
@ -448,9 +453,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
newtdir = name.split('/')[0]
|
newtdir = name.split('/')[0]
|
||||||
if newtdir not in dirs: dirs.append(newtdir)
|
if newtdir not in dirs: dirs.append(newtdir)
|
||||||
elif tdir:
|
elif tdir:
|
||||||
self.right_menu('browser_subfolder')
|
self.navi_route('browser', params, 'browser_subfolder')
|
||||||
tdir_up = tdir[:len(tdir)-len(tdir.split('/')[-1])-1] if '/' in tdir else None
|
self.drawItem('..', {'mode': 'browser_moveup'}, isFolder=True)
|
||||||
self.drawItem('..', {'mode': 'browser_subfolder', 'hash': hash, 'tdir': tdir_up}, isFolder=True)
|
|
||||||
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
|
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
|
||||||
for name, percent, ind, size in dllist:
|
for name, percent, ind, size in dllist:
|
||||||
|
|
||||||
|
@ -493,7 +497,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
DownloadList = Download().list()
|
DownloadList = Download().list()
|
||||||
if DownloadList == False:
|
if DownloadList == False:
|
||||||
showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True)
|
showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True)
|
||||||
return
|
return False
|
||||||
|
|
||||||
if (ind or ind == 0) and action in ('0', '3'):
|
if (ind or ind == 0) and action in ('0', '3'):
|
||||||
Download().setprio_simple(hash, action, ind)
|
Download().setprio_simple(hash, action, ind)
|
||||||
|
@ -546,7 +550,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
xbmcvfs.copy(os.path.join(path, file), os.path.join(folder, file))
|
xbmcvfs.copy(os.path.join(path, file), os.path.join(folder, file))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
showMessage(self.localize('Torrent-client Browser'), self.localize('Copied %d files!') % i, forced=True)
|
showMessage(self.localize('Torrent-client Browser'), self.localize('Copied %d files!') % i, forced=True)
|
||||||
return
|
return True
|
||||||
elif not tdir and action not in ('0', '3'):
|
elif not tdir and action not in ('0', '3'):
|
||||||
if action == 'removedata':
|
if action == 'removedata':
|
||||||
ok = xbmcgui.Dialog().yesno(self.localize('Torrent-client Browser'),
|
ok = xbmcgui.Dialog().yesno(self.localize('Torrent-client Browser'),
|
||||||
|
@ -562,8 +566,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
else:
|
else:
|
||||||
menu.append((hash, action, str(ind)))
|
menu.append((hash, action, str(ind)))
|
||||||
Download().setprio_simple_multi(menu)
|
Download().setprio_simple_multi(menu)
|
||||||
return
|
return True
|
||||||
return
|
return True
|
||||||
|
|
||||||
def downloadstatus(self, params = {}):
|
def downloadstatus(self, params = {}):
|
||||||
self.listing.reset()
|
self.listing.reset()
|
||||||
|
@ -688,12 +692,18 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
self.downloadstatus()
|
self.downloadstatus()
|
||||||
|
|
||||||
def file_browser(self, mode, path, tdir):
|
def file_browser(self, params):
|
||||||
|
|
||||||
|
self.navi_route('browser', params)
|
||||||
|
|
||||||
|
get = params.get
|
||||||
|
mode = get('mode')
|
||||||
|
path = get('path')
|
||||||
|
tdir = get('tdir')
|
||||||
|
|
||||||
path = encode_msg(path)
|
path = encode_msg(path)
|
||||||
tdir = encode_msg(tdir)
|
tdir = encode_msg(tdir)
|
||||||
|
|
||||||
self.listing.reset()
|
|
||||||
if tdir == os.path.dirname(path):
|
if tdir == os.path.dirname(path):
|
||||||
self.downloadstatus()
|
self.downloadstatus()
|
||||||
elif mode == 'file':
|
elif mode == 'file':
|
||||||
|
@ -962,10 +972,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
infoW = InfoWindow(ttl, yr)
|
infoW = InfoWindow(ttl, yr)
|
||||||
infoW.doModal()
|
infoW.doModal()
|
||||||
del infoW
|
del infoW
|
||||||
elif mode == 'torrent_moveup':
|
elif mode in ['torrent_moveup', 'browser_moveup', 'moveup']:
|
||||||
if index == 1:
|
self.navi_back()
|
||||||
self.search()
|
|
||||||
self.setFocus(self.listing)
|
|
||||||
elif mode == 'torrent_play':
|
elif mode == 'torrent_play':
|
||||||
if index == 1:
|
if index == 1:
|
||||||
url = self.form_link('playTorrent', params)
|
url = self.form_link('playTorrent', params)
|
||||||
|
@ -998,9 +1006,9 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
if index == 4: action = 'fav'
|
if index == 4: action = 'fav'
|
||||||
elif index == 5: action = 'delete'
|
elif index == 5: action = 'delete'
|
||||||
self.history_action(action, addtime, fav)
|
self.history_action(action, addtime, fav)
|
||||||
elif mode in ['browser_item', 'browser_subfolder', 'browser_moveup']:
|
elif mode in ['browser_item', 'browser_subfolder']:
|
||||||
if index == 1:
|
if index == 1:
|
||||||
self.browser(hash, tdir)
|
self.browser(params)
|
||||||
elif index in [2, 3, 4] and mode =='browser_subfolder':
|
elif index in [2, 3, 4] and mode =='browser_subfolder':
|
||||||
if index == 2: action = '3'
|
if index == 2: action = '3'
|
||||||
elif index == 3: action = '0'
|
elif index == 3: action = '0'
|
||||||
|
@ -1015,10 +1023,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
elif index == 6: action = '0'
|
elif index == 6: action = '0'
|
||||||
elif index == 7: action = 'removedata'
|
elif index == 7: action = 'removedata'
|
||||||
|
|
||||||
self.browser_action(hash, action)
|
if self.browser_action(hash, action):
|
||||||
|
self.navi_restore()
|
||||||
if index in [4, 7]:
|
|
||||||
self.browser()
|
|
||||||
elif mode == 'browser_file':
|
elif mode == 'browser_file':
|
||||||
if index == 1: action = 'play'
|
if index == 1: action = 'play'
|
||||||
elif index == 2: action = '3'
|
elif index == 2: action = '3'
|
||||||
|
@ -1037,8 +1043,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
elif index == 6: action = 'masscontrol'
|
elif index == 6: action = 'masscontrol'
|
||||||
self.downloadstatus_action(action, params.get('addtime'), params.get('path'),
|
self.downloadstatus_action(action, params.get('addtime'), params.get('path'),
|
||||||
params.get('type'), params.get('progress'), params.get('storage'))
|
params.get('type'), params.get('progress'), params.get('storage'))
|
||||||
elif mode in ['moveup', 'subfolder', 'file']:
|
elif mode in ['subfolder', 'file']:
|
||||||
self.file_browser(params.get('type'), params.get('path'), tdir)
|
self.file_browser(params)
|
||||||
elif mode == 'watched_item':
|
elif mode == 'watched_item':
|
||||||
if index == 1: action = 'open'
|
if index == 1: action = 'open'
|
||||||
elif index == 2: action = 'playnoseek'
|
elif index == 2: action = 'playnoseek'
|
||||||
|
|
Loading…
Reference in New Issue