ready to use new searchwindow
parent
f71dae3d7b
commit
1dbdacfe69
6
Core.py
6
Core.py
|
@ -1606,9 +1606,9 @@ class Core:
|
||||||
xbmc.executebuiltin(
|
xbmc.executebuiltin(
|
||||||
'xbmc.RunScript(%s,)' % os.path.join(ROOT, 'controlcenter.py'))
|
'xbmc.RunScript(%s,)' % os.path.join(ROOT, 'controlcenter.py'))
|
||||||
|
|
||||||
def searchWindow(self, params={}):
|
def search(self, params={}):
|
||||||
xbmc.executebuiltin(
|
import searchwindow
|
||||||
'xbmc.RunScript(%s,)' % os.path.join(ROOT, 'searchwindow.py'))
|
searchwindow.main(params)
|
||||||
|
|
||||||
def showFilesList(self, filesList, params={}):
|
def showFilesList(self, filesList, params={}):
|
||||||
get = params.get
|
get = params.get
|
||||||
|
|
|
@ -22,7 +22,7 @@ import sys, os, urllib, json
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
from functions import get_filesList, HistoryDB, get_contentList, log, cutFolder, get_ids_video, showMessage, getParameters
|
from functions import get_filesList, HistoryDB, get_contentList, log, cutFolder, get_ids_video, showMessage, getParameters, unquote
|
||||||
import pyxbmct.addonwindow as pyxbmct
|
import pyxbmct.addonwindow as pyxbmct
|
||||||
import Localization
|
import Localization
|
||||||
import re
|
import re
|
||||||
|
@ -54,13 +54,15 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
last_top_button = None
|
last_top_button = None
|
||||||
last_right_button = None
|
last_right_button = None
|
||||||
|
|
||||||
def __init__(self, title=""):
|
def __init__(self, title="", s_param={}):
|
||||||
super(SearchWindow, self).__init__(title)
|
super(SearchWindow, self).__init__(title)
|
||||||
self.setGeometry(1280, 720, 9, 16)
|
self.setGeometry(1280, 720, 9, 16)
|
||||||
self.set_controls()
|
self.set_controls()
|
||||||
self.connect_controls()
|
self.connect_controls()
|
||||||
#self.set_navigation()
|
if s_param:
|
||||||
self.history()
|
self.search(s_param=s_param)
|
||||||
|
else:
|
||||||
|
self.history()
|
||||||
|
|
||||||
def icon(self, icon):
|
def icon(self, icon):
|
||||||
return '%s/icons/%s.png' %(__root__, icon)
|
return '%s/icons/%s.png' %(__root__, icon)
|
||||||
|
@ -114,11 +116,31 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
control.setAnimations([('WindowOpen', 'effect=fade start=0 end=100 time=500',),
|
control.setAnimations([('WindowOpen', 'effect=fade start=0 end=100 time=500',),
|
||||||
('WindowClose', 'effect=fade start=100 end=0 time=500',)])
|
('WindowClose', 'effect=fade start=100 end=0 time=500',)])
|
||||||
|
|
||||||
def search(self, addtime=None):
|
def search(self, addtime=None, s_param={}):
|
||||||
self.reconnect(pyxbmct.ACTION_NAV_BACK, self.history)
|
self.reconnect(pyxbmct.ACTION_NAV_BACK, self.history)
|
||||||
self.right_menu('search')
|
self.right_menu('search')
|
||||||
self.listing.reset()
|
self.listing.reset()
|
||||||
query = self.input_search.getText()
|
if s_param:
|
||||||
|
if s_param.get('url'):
|
||||||
|
search = urllib.unquote_plus(s_param.get('url'))
|
||||||
|
external = s_param.get("return_name")
|
||||||
|
if external:
|
||||||
|
searcher = 'landing from : %s ' % str(external)
|
||||||
|
else:
|
||||||
|
searcher = ''
|
||||||
|
self.setWindowTitle(title='%s %s' % ('Torrenter Search Window', searcher))
|
||||||
|
if s_param.get('showKey') == 'true':
|
||||||
|
self.input_search.setText(search)
|
||||||
|
query = self.input_search.getText()
|
||||||
|
else:
|
||||||
|
self.input_search.setText(search)
|
||||||
|
query = search
|
||||||
|
#self.setFocus(self.listing)
|
||||||
|
else:
|
||||||
|
query = self.input_search.getText()
|
||||||
|
self.history()
|
||||||
|
else:
|
||||||
|
query = self.input_search.getText()
|
||||||
log('Search query: '+str(query))
|
log('Search query: '+str(query))
|
||||||
|
|
||||||
#cache
|
#cache
|
||||||
|
@ -126,16 +148,19 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
|
||||||
self.filesList = get_filesList(query, addtime)
|
self.filesList = get_filesList(query, addtime)
|
||||||
self.last_query = query
|
self.last_query = query
|
||||||
elif len(query)==0:
|
elif len(query)==0:
|
||||||
self.filesList = [(1919, 1919, 52, u'102.66 MiB', u'South.Park.S20E06.HDTV.x264-FUM[ettv]',
|
self.filesList = []
|
||||||
u'ThePirateBay::magnet:?xt=urn:btih:0792ea51bc16a19893871197fa927ecec7ca25aa&dn=South.Park.S20E06.HDTV.x264-FUM%5Bettv%5D&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969',
|
#self.filesList = [(1919, 1919, 52, u'102.66 MiB', u'South.Park.S20E06.HDTV.x264-FUM[ettv]',
|
||||||
'C:\\Users\\Admin\\AppData\\Roaming\\Kodi\\addons\\torrenter.searcher.ThePirateBay\\icon.png'),
|
#u'ThePirateBay::magnet:?xt=urn:btih:0792ea51bc16a19893871197fa927ecec7ca25aa&dn=South.Park.S20E06.HDTV.x264-FUM%5Bettv%5D&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969',
|
||||||
(1919, 1919, 52, u'102.66 MiB', u'Haruhi',
|
#'C:\\Users\\Admin\\AppData\\Roaming\\Kodi\\addons\\torrenter.searcher.ThePirateBay\\icon.png'),
|
||||||
u'D:\\htest.torrent',
|
#(1919, 1919, 52, u'102.66 MiB', u'Haruhi',
|
||||||
'C:\\Users\\Admin\\AppData\\Roaming\\Kodi\\addons\\torrenter.searcher.ThePirateBay\\icon.png') ]
|
# u'D:\\htest.torrent',
|
||||||
|
# 'C:\\Users\\Admin\\AppData\\Roaming\\Kodi\\addons\\torrenter.searcher.ThePirateBay\\icon.png') ]
|
||||||
if 1==1:
|
if 1==1:
|
||||||
for (order, seeds, leechers, size, title, link, image) in self.filesList:
|
if self.filesList:
|
||||||
title = titleMake(seeds, leechers, size, title)
|
for (order, seeds, leechers, size, title, link, image) in self.filesList:
|
||||||
self.drawItem(title, {'mode':'search_item', 'filename': link}, image)
|
title = titleMake(seeds, leechers, size, title)
|
||||||
|
self.drawItem(title, {'mode':'search_item', 'filename': link}, image)
|
||||||
|
self.setFocus(self.listing)
|
||||||
|
|
||||||
def history(self):
|
def history(self):
|
||||||
self.right_menu('history')
|
self.right_menu('history')
|
||||||
|
@ -492,19 +517,14 @@ def titleMake(seeds, leechers, size, title):
|
||||||
return title
|
return title
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(params={}):
|
||||||
dialog = SearchWindow("Torrenter Search Window")
|
dialog = SearchWindow("Torrenter Search Window", params)
|
||||||
dialog.doModal()
|
dialog.doModal()
|
||||||
del dialog #You need to delete your instance when it is no longer needed
|
del dialog #You need to delete your instance when it is no longer needed
|
||||||
#because underlying xbmcgui classes are not grabage-collected.
|
#because underlying xbmcgui classes are not grabage-collected.
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
|
||||||
params = getParameters(sys.argv[1])
|
|
||||||
else:
|
|
||||||
params = {}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
Loading…
Reference in New Issue