external for myshows

pull/15/head
DiMartinoXBMC 2017-01-09 22:44:05 +03:00
parent 9193b14638
commit ed06cf611e
1 changed files with 85 additions and 2 deletions

View File

@ -71,6 +71,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.navi_load() self.navi_load()
elif params.get('mode') == 'search': elif params.get('mode') == 'search':
self.search(params) self.search(params)
elif params.get('mode') == 'externalsearch':
self.externalsearch(params)
elif params.get('mode') == 'history': elif params.get('mode') == 'history':
self.history() self.history()
elif params.get('mode') == 'downloadstatus': elif params.get('mode') == 'downloadstatus':
@ -373,6 +375,75 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.drawItem(title, {'mode': 'search_item', 'filename': link}, image) self.drawItem(title, {'mode': 'search_item', 'filename': link}, image)
self.setFocus(self.listing) self.setFocus(self.listing)
def externalsearch(self, params={}):
log('search init params: ' + str(params))
if hasattr(self, 'params'):
params = self.params
self.params = params
get = params.get
query = unquote(get('query'),'')
external = unquote(params.get("external"), 'torrenterall')
back_url = unquote(get("back_url"),'')
self.return_name = unquote(get("return_name"),'')
sdata = unquote(get("sdata"),'{}')
self.reconnect(self.button_search, self.externalsearch)
self.navi_route('externalsearch', params)
try:
sdata = json.loads(sdata)
except:
sdata = json.loads(urllib.unquote_plus(sdata))
if self.input_search.getText() not in ['', None]:
query = self.input_search.getText()
else:
self.input_search.setText(query)
#contextMenu = [
# (self.localize('Add to %s') % return_name,
# 'XBMC.RunPlugin(%s)' % (back_url + '&stringdata=' + urllib.quote_plus(
# json.dumps(sdata)))),
# url = 'plugin://plugin.video.torrenter/?action=searchWindow&mode=externalsearch&query=%s' \
# '&sdata=%s&external=%s&back_url=%s&return_name=%s' % \
# (urllib.quote_plus(query), urllib.quote_plus(json.dumps(sdata)),
# self.externals[self.stype], urllib.quote_plus(back_self.url),
# urllib.quote_plus(return_name))
log('Search query: ' + str(query))
searchersList = []
if not external or external == 'torrenterall':
searchersList = get_searchersList()
elif external == 'torrenterone':
slist = Searchers().list().keys()
ret = xbmcgui.Dialog().select(self.localize('Choose searcher')+':', slist)
if ret > -1 and ret < len(slist):
external = slist[ret]
searchersList.append(external)
else:
searchersList.append(external)
if len(query) > 0:
self.navi['filesList'] = get_filesList(query, searchersList)
else:
self.navi['filesList'] = []
if self.navi['filesList']:
for (order, seeds, leechers, size, title, link, image) in self.navi['filesList']:
title = titleMake(seeds, leechers, size, title)
sdata['filename'] = link
stringdata = json.dumps(sdata)
self.drawItem(title, {'mode': 'externalsearch_item', 'filename': link,
'stringdata': stringdata, 'back_url': back_url}, image)
self.setFocus(self.listing)
def history(self, params = {}): def history(self, params = {}):
self.navi_route('history', params) self.navi_route('history', params)
@ -844,6 +915,12 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.localize('Download via T-client'), self.localize('Download via T-client'),
self.localize('Download via Libtorrent'), self.localize('Download via Libtorrent'),
self.localize('Info'),] self.localize('Info'),]
if mode in ['externalsearch', 'externalsearch_item']:
label_list = [self.localize('Add to %s') % self.return_name,
self.localize('Open'),
self.localize('Download via T-client'),
self.localize('Download via Libtorrent'),
self.localize('Info'),]
elif mode in ['torrent_subfolder', 'file_browser', 'subfolder']: elif mode in ['torrent_subfolder', 'file_browser', 'subfolder']:
label_list = [self.localize('Open'),] label_list = [self.localize('Open'),]
elif mode in ['torrent_moveup', 'browser_moveup']: elif mode in ['torrent_moveup', 'browser_moveup']:
@ -1026,8 +1103,14 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
tdir = params.get('tdir') tdir = params.get('tdir')
action = None action = None
if mode in ['search_item', 'torrent_subfolder']: if mode in ['search_item', 'torrent_subfolder', 'externalsearch', 'externalsearch_item']:
if index == 1: if mode in ['externalsearch', 'externalsearch_item']:
index = index - 1
if index == 0:
url = params.get('back_url') + '&stringdata=' + urllib.quote_plus(params.get('stringdata'))
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
elif index == 1:
params = {'link': filename, 'tdir': tdir} params = {'link': filename, 'tdir': tdir}
self.open_torrent(params) self.open_torrent(params)
elif index == 2: elif index == 2: