pull/15/head
DiMartinoXBMC 2016-11-28 23:31:26 +03:00
parent 0bdb6ae37f
commit 9cfc007a29
1 changed files with 100 additions and 97 deletions

View File

@ -77,7 +77,6 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.right_menu() self.right_menu()
def connect_controls(self): def connect_controls(self):
self.connect(self.listing, self.right_press1) self.connect(self.listing, self.right_press1)
self.connect(self.button_history, self.history) self.connect(self.button_history, self.history)
@ -152,95 +151,28 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
link = {'mode': 'history_search_item', 'url': title, 'addtime': str(addtime), 'fav':str(fav)} link = {'mode': 'history_search_item', 'url': title, 'addtime': str(addtime), 'fav':str(fav)}
self.drawItem(bbstring % title, link, title, img) self.drawItem(bbstring % title, link, title, img)
def right_press1(self): def history_action(self, action, addtime, fav):
item = self.listing.getSelectedItem() db = HistoryDB()
params = json.loads(item.getLabel2())
mode = params.get('mode')
filename = item.getfilename()
label = item.getLabel()
tdir = params.get('tdir')
self.listing.reset()
if mode == 'search_item':
self.open_torrent(filename)
elif mode == 'torrent_subfolder':
self.open_torrent(filename, tdir)
elif mode == 'torrent_moveup':
self.last_action()
elif mode == 'torrent_play':
action = 'playTorrent'
url = self.form_link(action, params)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
self.close()
elif mode == 'history_search_item':
self.input_search.setText(filename)
self.search()
def right_press2(self): if action == 'delete':
item = self.listing.getSelectedItem() db.delete(addtime)
params = json.loads(item.getLabel2()) showMessage(self.localize('Search History'), self.localize('Deleted!'))
mode = params.get('mode')
filename = item.getfilename()
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)
def right_press3(self): if action == 'fav' and fav == '0':
item = self.listing.getSelectedItem() db.fav(addtime)
params = json.loads(item.getLabel2()) showMessage(self.localize('Favourites'), self.localize('Added!'))
filename = item.getfilename() elif action == 'fav':
mode = params.get('mode') db.unfav(addtime)
if mode == 'torrent_play': showMessage(self.localize('Favourites'), self.localize('Deleted!'))
action = 'downloadLibtorrent'
link = {'ind': str(params.get('url'))}
url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'search_item':
action = 'downloadLibtorrent'
link = {'url': filename}
url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'history_search_item':
addtime = params.get('addtime')
url = (os.path.join(__root__, 'controlcenter.py,') +
'addtime=%s&title=%s' % (str(addtime), filename))
xbmc.executebuiltin('xbmc.RunPlugin(%s)' % (url))
def right_press4(self): self.history()
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
mode = params.get('mode')
if mode == 'history_search_item':
addtime = params.get('addtime')
fav = params.get('fav')
self.history_action('fav', addtime, fav)
def right_press5(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
mode = params.get('mode')
if mode == 'history_search_item':
addtime = params.get('addtime')
fav = params.get('fav')
self.history_action('delete', addtime, fav)
def right_press6(self):
pass
def open_torrent(self, link, tdir = None): def open_torrent(self, link, tdir = None):
#cache #cache
if link != self.last_link: if link != self.last_link:
self.contentList = get_contentList(link) self.contentList = get_contentList(link)
self.last_link = link self.last_link = link
self.reconnect(pyxbmct.ACTION_NAV_BACK, self.search)
dirList, contentListNew = cutFolder(self.contentList, tdir) dirList, contentListNew = cutFolder(self.contentList, tdir)
@ -264,22 +196,6 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
params = {'mode': 'torrent_play', 'url': identifier, 'url2': ids_video.rstrip(',')} params = {'mode': 'torrent_play', 'url': identifier, 'url2': ids_video.rstrip(',')}
self.drawItem(title, params, link) self.drawItem(title, params, link)
def history_action(self, action, addtime, fav):
db = HistoryDB()
if action == 'delete':
db.delete(addtime)
showMessage(self.localize('Search History'), self.localize('Deleted!'))
if action == 'fav' and fav == '0':
db.fav(addtime)
showMessage(self.localize('Favourites'), self.localize('Added!'))
elif action == 'fav':
db.unfav(addtime)
showMessage(self.localize('Favourites'), self.localize('Deleted!'))
self.history()
def right_menu(self, mode='place'): def right_menu(self, mode='place'):
if not mode == 'place': if not mode == 'place':
self.last_right_buttons_count = self.right_buttons_count self.last_right_buttons_count = self.right_buttons_count
@ -334,6 +250,93 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.set_navigation() self.set_navigation()
def right_press1(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
mode = params.get('mode')
filename = item.getfilename()
label = item.getLabel()
tdir = params.get('tdir')
self.listing.reset()
if mode == 'search_item':
self.open_torrent(filename)
elif mode == 'torrent_subfolder':
self.open_torrent(filename, tdir)
elif mode == 'torrent_moveup':
self.search()
self.setFocus(self.listing)
elif mode == 'torrent_play':
action = 'playTorrent'
url = self.form_link(action, params)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
self.close()
elif mode == 'history_search_item':
addtime = params.get('addtime')
self.input_search.setText(filename)
self.search(addtime)
def right_press2(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
mode = params.get('mode')
filename = item.getfilename()
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)
def right_press3(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
filename = item.getfilename()
mode = params.get('mode')
if mode == 'torrent_play':
action = 'downloadLibtorrent'
link = {'ind': str(params.get('url'))}
url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'search_item':
action = 'downloadLibtorrent'
link = {'url': filename}
url = self.form_link(action, link)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif mode == 'history_search_item':
addtime = params.get('addtime')
url = (os.path.join(__root__, 'controlcenter.py,') +
'addtime=%s&title=%s' % (str(addtime), urllib.quote_plus(filename)))
log(url)
xbmc.executebuiltin('xbmc.RunScript(%s)' % (url))
def right_press4(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
mode = params.get('mode')
if mode == 'history_search_item':
addtime = params.get('addtime')
fav = params.get('fav')
self.history_action('fav', addtime, fav)
def right_press5(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getLabel2())
mode = params.get('mode')
if mode == 'history_search_item':
addtime = params.get('addtime')
fav = params.get('fav')
self.history_action('delete', addtime, fav)
def right_press6(self):
pass
def localize(self, string): def localize(self, string):
try: try:
return Localization.localize(string) return Localization.localize(string)