diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5ca5e8e..2c3cc30 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,4 @@
-
-
-
+
+
\ No newline at end of file
diff --git a/.idea/plugin.video.torrenter.iml b/.idea/plugin.video.torrenter.iml
index a34a857..ca32dfa 100644
--- a/.idea/plugin.video.torrenter.iml
+++ b/.idea/plugin.video.torrenter.iml
@@ -2,8 +2,7 @@
-
+
-
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index dd00281..a1da39e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,10 +1,12 @@
-
+
+
+
-
-
+
+
@@ -31,219 +33,58 @@
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -253,12 +94,415 @@
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -266,28 +510,18 @@
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -304,6 +538,48 @@
+
+
+ HistoryDB
+ self.db
+ controlCenter
+ setAnimation
+ AddonDialogWindow
+ showFilesList
+ openSection
+ items
+ Default
+ save_folder
+ xbmc.Run
+ addI
+ downloadFilesList
+ .info()
+ info
+ self.torrentFileInfo
+ name
+ chooseHASH
+ self.button_right1
+ set_navigation
+ right_buttons_count
+ self.reconnect(pyxbmct.ACTION_NAV_BACK, self.close)
+ progressBar
+ getTorrentFile
+ 30018
+ titleMake
+ params
+ version_check
+ right_press1
+ last_mode
+
+
+ pyxbmct.Button(
+ button_history
+ button_right1
+ self.right_press1
+ action
+ self.progressBar
+
+
@@ -315,19 +591,6 @@
@@ -375,16 +651,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -402,12 +669,6 @@
-
-
-
-
-
-
@@ -432,24 +693,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -512,37 +755,20 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
@@ -731,111 +957,6 @@
1420801533300
-
- 1455384796936
-
-
-
- 1455384796938
-
-
- 1456153123745
-
-
-
- 1456153123747
-
-
- 1456332526199
-
-
-
- 1456332526199
-
-
- 1456428558314
-
-
-
- 1456428558315
-
-
- 1456851519690
-
-
-
- 1456851519691
-
-
- 1456855905709
-
-
-
- 1456855905709
-
-
- 1456937177859
-
-
-
- 1456937177860
-
-
- 1457024869511
-
-
-
- 1457024869512
-
-
- 1457084786854
-
-
-
- 1457084786855
-
-
- 1457251492008
-
-
-
- 1457251492009
-
-
- 1457373523416
-
-
-
- 1457373523418
-
-
- 1457374373046
-
-
-
- 1457374373046
-
-
- 1457537482800
-
-
-
- 1457537482812
-
-
- 1457772582074
-
-
-
- 1457772582075
-
-
- 1457774220583
-
-
-
- 1457774220583
-
1457776923389
@@ -1074,7 +1195,112 @@
1478266893338
-
+
+ 1480148256409
+
+
+
+ 1480148256412
+
+
+ 1480150613343
+
+
+
+ 1480150613343
+
+
+ 1480151164289
+
+
+
+ 1480151164289
+
+
+ 1480155273428
+
+
+
+ 1480155273429
+
+
+ 1480176304344
+
+
+
+ 1480176304344
+
+
+ 1480252275572
+
+
+
+ 1480252275573
+
+
+ 1480252326658
+
+
+
+ 1480252326658
+
+
+ 1480279488798
+
+
+
+ 1480279488798
+
+
+ 1480279505453
+
+
+
+ 1480279505453
+
+
+ 1480353770986
+
+
+
+ 1480353770986
+
+
+ 1480360883062
+
+
+
+ 1480360883062
+
+
+ 1480364949177
+
+
+
+ 1480364949177
+
+
+ 1480365086883
+
+
+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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Core.py b/Core.py
index cf95322..2644659 100644
--- a/Core.py
+++ b/Core.py
@@ -1908,7 +1908,6 @@ class Core:
dialog_items.append('[' + str(data['progress']) + '%] ' + data['name'])
dialog_items_clean.append(data['name'])
-
log('[chooseHASH]: name %s ' % str(name))
for data in dat:
# Debug('[chooseHASH]: '+str((data['name'], data['id'], data['dir'].encode('utf-8'))))
diff --git a/searchwindow.py b/searchwindow.py
index b08bcf7..829f4df 100644
--- a/searchwindow.py
+++ b/searchwindow.py
@@ -22,7 +22,7 @@ import sys, os, urllib, json
import xbmcaddon
import xbmc
import xbmcgui
-from functions import get_filesList, HistoryDB, get_contentList, log, cutFolder, get_ids_video, showMessage
+from functions import get_filesList, HistoryDB, get_contentList, log, cutFolder, get_ids_video, showMessage, getParameters
import pyxbmct.addonwindow as pyxbmct
import Localization
@@ -37,6 +37,9 @@ log('SYS ARGV: ' + str(sys.argv))
#https://github.com/xbmc/xbmc/blob/8d4a5bba55638dfd0bdc5e7de34f3e5293f99933/xbmc/input/Key.h
ACTION_STOP = 13
ACTION_PLAYER_PLAY = 79
+ACTION_MOUSE_RIGHT_CLICK = 101
+ACTION_CONTEXT_MENU = 117
+ACTION_SHOW_OSD = 24
class SearchWindow(pyxbmct.AddonDialogWindow):
__settings__ = sys.modules["__main__"].__settings__
@@ -71,8 +74,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.button_controlcenter = pyxbmct.Button("Control\r\nCenter")
self.placeControl(self.button_controlcenter, 0, 9, 1, 2)
- self.listing = self.listing = pyxbmct.List(_imageWidth=60, _imageHeight=60, _itemTextXOffset=10,
- _itemTextYOffset=2, _itemHeight=60, _space=2, _alignmentY=4)
+ self.listing = pyxbmct.List(_imageWidth=60, _imageHeight=60, _itemTextXOffset=1,
+ _itemTextYOffset=0, _itemHeight=50, _space=0, _alignmentY=4)
self.placeControl(self.listing, 1, 0, 8, 14)
self.right_menu()
@@ -85,6 +88,10 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.connect(pyxbmct.ACTION_NAV_BACK, self.close)
self.connect(pyxbmct.ACTION_PREVIOUS_MENU, self.close)
+ self.connect(ACTION_MOUSE_RIGHT_CLICK, self.context)
+ self.connect(ACTION_CONTEXT_MENU, self.context)
+ self.connect(ACTION_SHOW_OSD, self.context)
+
def set_navigation(self):
#Top menu
@@ -196,6 +203,40 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
params = {'mode': 'torrent_play', 'url': identifier, 'url2': ids_video.rstrip(',')}
self.drawItem(title, params, link)
+ def get_menulist(self, mode):
+
+ label_list = ["Empty","Empty","Empty","Empty","Empty","Empty"]
+
+ if mode in ['search', 'search_item', 'torrent_play']:
+ label_list = ["Open",
+ self.localize('Download via T-client'),
+ self.localize('Download via Libtorrent')]
+ elif mode in ['torrent_subfolder', 'torrent_moveup']:
+ label_list = ["Open"]
+ elif mode in ['history', 'history_search_item']:
+ label_list = [self.localize('Open'),
+ self.localize('Edit'),
+ self.localize('Individual Tracker Options'),
+ 'Fav/Unfav',
+ self.localize('Delete')]
+
+ return label_list
+
+ def context(self):
+ if self.getFocus() == self.listing:
+ item = self.listing.getSelectedItem()
+ params = json.loads(item.getLabel2())
+ mode = params.get('mode')
+ label_list = self.get_menulist(mode)
+
+ if not self.version_check():
+ ret = xbmcgui.Dialog().select(self.localize('Context menu'), label_list)
+ else:
+ ret = xbmcgui.Dialog().contextmenu(list=[(x) for x in label_list])
+
+ if ret > -1 and ret < len(label_list):
+ getattr(self, "right_press" + str(ret + 1))()
+
def right_menu(self, mode='place'):
if not mode == 'place':
self.last_right_buttons_count = self.right_buttons_count
@@ -204,21 +245,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.disconnectEventList(remove_list)
self.removeControls(remove_list)
- label_list = []
- if mode == 'place':
- label_list = ["Empty","Empty","Empty","Empty","Empty","Empty"]
-
- elif mode == 'search':
- label_list = ["Open",
- self.localize('Download via T-client'),
- self.localize('Download via Libtorrent')]
-
- elif mode == 'history':
- label_list = [self.localize('Open'),
- self.localize('Edit'),
- self.localize('Individual Tracker Options'),
- 'Fav/Unfav',
- self.localize('Delete')]
+ label_list = self.get_menulist(mode)
self.right_buttons_count = len(label_list)
button_num_list = range(1, self.right_buttons_count+1)
@@ -374,6 +401,9 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.disconnect(event)
self.connect(event, callable)
+ def version_check(self):
+ return False if int(xbmc.getInfoLabel( "System.BuildVersion" )[:2]) < 17 else True
+
def log(msg):
try:
xbmc.log("### [%s]: %s" % (__plugin__,msg,), level=xbmc.LOGNOTICE )
@@ -398,9 +428,25 @@ def titleMake(seeds, leechers, size, title):
title += '\r\n' + clDimgray % second
return title
-if __name__ == "__main__":
+def main():
dialog = SearchWindow("Torrenter Search Window")
dialog.doModal()
del dialog #You need to delete your instance when it is no longer needed
- #because underlying xbmcgui classes are not grabage-collected.
\ No newline at end of file
+ #because underlying xbmcgui classes are not grabage-collected.
+
+
+if __name__ == '__main__':
+ if len(sys.argv) > 1:
+ params = getParameters(sys.argv[1])
+ else:
+ params = {}
+
+ try:
+ main()
+ except Exception, e:
+ import xbmc
+ import traceback
+
+ map(xbmc.log, traceback.format_exc().split("\n"))
+ raise
\ No newline at end of file