right menu revolution

pull/15/head
DiMartinoXBMC 2016-12-15 22:05:11 +03:00
parent 87e80dda3f
commit 6d7a8945cc
1 changed files with 129 additions and 159 deletions

View File

@ -302,7 +302,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
else: else:
img = __root__ + '/icons/unfav.png' img = __root__ + '/icons/unfav.png'
link = {'mode': 'history_search_item', 'filename': title, 'addtime': str(addtime), link = {'mode': 'history_item', 'query': title, 'addtime': str(addtime),
'fav': str(fav)} 'fav': str(fav)}
self.drawItem(bbstring % title, link, img) self.drawItem(bbstring % title, link, img)
self.navi['route'][-1]['last_listing_item'] = last_listing_item self.navi['route'][-1]['last_listing_item'] = last_listing_item
@ -362,8 +362,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
if action == 'open': if action == 'open':
filename, foldername, path, url, seek, length, ind = db.get('filename, foldername, path, url, seek, length, ind', 'addtime', str(addtime)) filename, foldername, path, url, seek, length, ind = db.get('filename, foldername, path, url, seek, length, ind', 'addtime', str(addtime))
#self.reconnect(pyxbmct.ACTION_NAV_BACK, self.watched) params = {'link': path.encode('utf-8')}
self.open_torrent(path.encode('utf-8')) self.open_torrent(params)
if action == 'playnoseek' or action == 'playwithseek': if action == 'playnoseek' or action == 'playwithseek':
filename, path, url, seek, length, ind = db.get('filename, path, url, seek, length, ind', 'addtime', str(addtime)) filename, path, url, seek, length, ind = db.get('filename, path, url, seek, length, ind', 'addtime', str(addtime))
@ -707,7 +707,13 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
else: else:
self.setFocus(self.button_downloadstatus) self.setFocus(self.button_downloadstatus)
def open_torrent(self, link, tdir=None): def open_torrent(self, params):
self.navi_route('open_torrent', params)
# def open_torrent(self, link, tdir=None):
get = params.get
link = get('link')
tdir = get('tdir')
# cache # cache
if link != self.last_link: if link != self.last_link:
self.contentList = get_contentList(link) self.contentList = get_contentList(link)
@ -741,7 +747,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
label_list = ["Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"] label_list = ["Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"]
if mode in ['search', 'search_item', 'torrent_play']: if mode in ['search', 'search_item', 'torrent_play', 'open_torrent']:
label_list = [self.localize('Open'), label_list = [self.localize('Open'),
self.localize('Download via T-client'), self.localize('Download via T-client'),
self.localize('Download via Libtorrent'), self.localize('Download via Libtorrent'),
@ -751,7 +757,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
label_list = [self.localize('Open'),] label_list = [self.localize('Open'),]
elif mode in ['file']: elif mode in ['file']:
label_list = [self.localize('Play'), ] label_list = [self.localize('Play'), ]
elif mode in ['history', 'history_search_item']: elif mode in ['history', 'history_item']:
label_list = [self.localize('Open'), label_list = [self.localize('Open'),
self.localize('Edit'), self.localize('Edit'),
self.localize('Individual Tracker Options'), self.localize('Individual Tracker Options'),
@ -892,177 +898,141 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
button.setLabel(label) button.setLabel(label)
def right_press1(self): def right_press1(self):
item = self.listing.getSelectedItem() self.right_press(1)
params = json.loads(item.getfilename())
log('params ' + str(params))
mode = params.get('mode')
filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir')
self.listing.reset()
if mode in ['search_item', 'torrent_subfolder']:
#self.reconnect(pyxbmct.ACTION_NAV_BACK, self.search)
self.open_torrent(filename, tdir)
elif mode == 'torrent_moveup':
self.search()
self.setFocus(self.listing)
elif mode == 'torrent_play':
url = self.form_link('playTorrent', params)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
self.close()
elif mode == 'history_search_item':
addtime = params.get('addtime')
self.input_search.setText(filename)
params = {'addtime': addtime}
self.search(params)
elif mode in ['browser_item', 'browser_subfolder', 'browser_moveup']:
self.browser(hash, tdir)
elif mode == 'browser_file':
self.browser_action(hash, 'play', tdir = tdir, ind = ind)
self.close()
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']:
self.downloadstatus_action('play', params.get('addtime'), params.get('path'),
params.get('type'), params.get('progress'), params.get('storage'))
elif mode in ['moveup', 'subfolder', 'file']:
self.file_browser(params.get('type'), params.get('path'), tdir)
elif mode == 'watched_item':
self.watched_action('open', params.get('addtime'))
def right_press2(self): def right_press2(self):
item = self.listing.getSelectedItem() self.right_press(2)
params = json.loads(item.getfilename())
mode = params.get('mode')
filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir')
if mode == 'torrent_play':
action = 'downloadFilesList'
link = {'ind': str(params.get('url'))}
url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'search_item':
action = 'downloadFilesList'
link = {'url': filename}
url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'history_search_item':
self.input_search.setText(filename)
self.setFocus(self.input_search)
elif mode == 'browser_item':
self.browser_action(hash, 'start')
elif mode == 'browser_subfolder':
self.browser_action(hash, '3', tdir=tdir, ind=ind)
elif mode == 'browser_file':
self.browser_action(hash, '3', tdir=tdir, ind=ind)
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']:
self.downloadstatus_action('start', params.get('addtime'), params.get('path'),
params.get('type'), params.get('progress'), params.get('storage'))
elif mode == 'watched_item':
self.watched_action('playnoseek', params.get('addtime'))
def right_press3(self): def right_press3(self):
self.right_press(3)
def right_press4(self):
self.right_press(4)
def right_press5(self):
self.right_press(5)
def right_press6(self):
self.right_press(6)
def right_press7(self):
self.right_press(7)
def right_press(self, index):
item = self.listing.getSelectedItem() item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) params = json.loads(item.getfilename())
log('right_press %d params %s' % (index, str(params)))
mode = params.get('mode') mode = params.get('mode')
filename = params.get('filename') filename = params.get('filename')
hash = params.get('hash') hash = params.get('hash')
ind = params.get('ind') ind = params.get('ind')
tdir = params.get('tdir') tdir = params.get('tdir')
if mode == 'torrent_play': action = None
action = 'downloadLibtorrent'
link = {'ind': str(params.get('url'))} if mode in ['search_item', 'torrent_subfolder']:
if index == 1:
params = {'link': filename, 'tdir': tdir}
self.open_torrent(params)
elif index == 2:
action = 'downloadFilesList'
link = {'url': filename}
url = self.form_link(action, link) url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url)) xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'search_item': elif index == 3:
action = 'downloadLibtorrent' action = 'downloadLibtorrent'
link = {'url': filename} link = {'url': filename}
url = self.form_link(action, link) url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url)) xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'history_search_item': elif index == 4: #search_item
params['title'] = params.get('filename')
self.controlCenter(params)
elif mode == 'browser_item':
self.browser_action(hash, 'stop')
elif mode == 'browser_subfolder':
self.browser_action(hash, '0', tdir=tdir, ind=ind)
elif mode == 'browser_file':
self.browser_action(hash, '0', tdir=tdir, ind=ind)
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']:
self.downloadstatus_action('pause', params.get('addtime'), params.get('path'),
params.get('type'), params.get('progress'), params.get('storage'))
elif mode == 'watched_item':
self.watched_action('playwithseek', params.get('addtime'))
def right_press4(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getfilename())
mode = params.get('mode')
filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir')
if mode == 'history_search_item':
addtime = params.get('addtime')
fav = params.get('fav')
self.history_action('fav', addtime, fav)
elif mode == 'search_item':
cleanlabel = re.sub('\[[^\]]*\]', '', item.getLabel()) cleanlabel = re.sub('\[[^\]]*\]', '', item.getLabel())
ttl, yr = xbmc.getCleanMovieTitle(cleanlabel) ttl, yr = xbmc.getCleanMovieTitle(cleanlabel)
infoW = InfoWindow(ttl, yr) infoW = InfoWindow(ttl, yr)
infoW.doModal() infoW.doModal()
del infoW del infoW
elif mode == 'browser_item': elif mode == 'torrent_moveup':
self.browser_action(hash, 'remove') if index == 1:
self.browser() self.search()
elif mode == 'browser_subfolder': self.setFocus(self.listing)
self.browser_action(hash, 'copy', tdir=tdir, ind=ind) elif mode == 'torrent_play':
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']: if index == 1:
self.downloadstatus_action('stop', params.get('addtime'), params.get('path'), url = self.form_link('playTorrent', params)
params.get('type'), params.get('progress'), params.get('storage')) xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'watched_item': self.close()
self.watched_action('delete', params.get('addtime')) elif index == 2:
action = 'downloadFilesList'
def right_press5(self): link = {'ind': str(params.get('url'))}
item = self.listing.getSelectedItem() url = self.form_link(action, link)
params = json.loads(item.getfilename()) xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
mode = params.get('mode') elif index == 3:
filename = params.get('filename') action = 'downloadLibtorrent'
hash = params.get('hash') link = {'ind': str(params.get('url'))}
if mode == 'history_search_item': url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'history_item':
addtime = params.get('addtime') addtime = params.get('addtime')
fav = params.get('fav') fav = params.get('fav')
self.history_action('delete', addtime, fav) query = params.get('query')
elif mode == 'browser_item': if index == 1:
self.browser_action(hash, '3') self.input_search.setText(query)
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']: self.search({'addtime': addtime})
self.downloadstatus_action('delete', params.get('addtime'), params.get('path'), elif index == 2:
params.get('type'), params.get('progress'), params.get('storage')) self.input_search.setText(query)
elif mode == 'watched_item': self.setFocus(self.input_search)
self.watched_action('clear', params.get('addtime')) elif index == 3:
params['title'] = params.get('query')
self.controlCenter(params)
else:
if index == 4: action = 'fav'
elif index == 5: action = 'delete'
self.history_action(action, addtime, fav)
elif mode in ['browser_item', 'browser_subfolder', 'browser_moveup']:
if index == 1:
self.browser(hash, tdir)
elif index in [2, 3, 4] and mode =='browser_subfolder':
if index == 2: action = '3'
elif index == 3: action = '0'
elif index == 4: action = 'copy'
def right_press6(self): self.browser_action(hash, action, tdir=tdir, ind=ind)
item = self.listing.getSelectedItem() else:
params = json.loads(item.getfilename()) if index == 2: action = 'start'
mode = params.get('mode') elif index == 3: action = 'stop'
filename = params.get('filename') elif index == 4: action = 'remove'
hash = params.get('hash') elif index == 5: action = '3'
if mode == 'browser_item': elif index == 6: action = '0'
self.browser_action(hash, '0') elif index == 7: action = 'removedata'
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']:
self.downloadstatus_action('masscontrol', params.get('addtime'), params.get('path'),
params.get('type'), params.get('progress'), params.get('storage'))
def right_press7(self): self.browser_action(hash, action)
item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) if index in [4, 7]:
mode = params.get('mode')
filename = params.get('filename')
hash = params.get('hash')
if mode == 'browser_item':
self.browser_action(hash, 'removedata')
self.browser() self.browser()
elif mode == 'browser_file':
if index == 1: action = 'play'
elif index == 2: action = '3'
elif index == 3: action = '0'
self.browser_action(hash, action, tdir = tdir, ind = ind)
if index == 1:
self.close()
elif mode in ['downloadstatus', 'downloadstatus_subfolder', 'downloadstatus_file']:
if index == 1: action = 'play'
elif index == 2: action = 'start'
elif index == 3: action = 'pause'
elif index == 4: action = 'stop'
elif index == 5: action = 'delete'
elif index == 6: action = 'masscontrol'
self.downloadstatus_action(action, params.get('addtime'), params.get('path'),
params.get('type'), params.get('progress'), params.get('storage'))
elif mode in ['moveup', 'subfolder', 'file']:
self.file_browser(params.get('type'), params.get('path'), tdir)
elif mode == 'watched_item':
if index == 1: action = 'open'
elif index == 2: action = 'playnoseek'
elif index == 3: action = 'playwithseek'
elif index == 4: action = 'delete'
elif index == 5: action = 'clear'
self.watched_action(action, params.get('addtime'))
def localize(self, string): def localize(self, string):
try: try: