torrent browser

pull/15/head
DiMartinoXBMC 2016-12-09 21:11:23 +03:00
parent f5dbf2bb7a
commit 25a7d9a3fb
15 changed files with 247 additions and 189 deletions

15
Core.py
View File

@ -90,7 +90,7 @@ class Core:
self.drawItem('< %s >' % self.localize('Download Status'), 'DownloadStatus', image=self.ROOT + '/icons/download.png', self.drawItem('< %s >' % self.localize('Download Status'), 'DownloadStatus', image=self.ROOT + '/icons/download.png',
contextMenu=DLScontextMenu, replaceMenu=False) contextMenu=DLScontextMenu, replaceMenu=False)
self.drawItem('< %s >' % self.localize('Torrent-client Browser'), 'uTorrentBrowser', self.drawItem('< %s >' % self.localize('Torrent-client Browser'), 'uTorrentBrowser',
image=self.ROOT + '/icons/' + self.getTorrentClientIcon()) image=self.ROOT + '/icons/' + getTorrentClientIcon())
if self.history_bool: if self.history_bool:
WatchedHistorycontextMenu=[] WatchedHistorycontextMenu=[]
WatchedHistorycontextMenu.extend(contextMenu) WatchedHistorycontextMenu.extend(contextMenu)
@ -1940,19 +1940,6 @@ class Core:
i=delete_russian(ok=True, action='return') i=delete_russian(ok=True, action='return')
showMessage(self.localize('Return Russian stuff'),self.localize('%d files have been returned')%i) showMessage(self.localize('Return Russian stuff'),self.localize('%d files have been returned')%i)
def getTorrentClientIcon(self):
client = self.__settings__.getSetting("torrent")
if client == '1':
return 'transmission.png'
elif client == '2':
return 'vuze.png'
elif client == '3':
return 'deluge.png'
elif client == '4':
return 'qbittorrent.png'
else:
return 'torrent-client.png'
def callback(self, params={}): def callback(self, params={}):
get = params.get get = params.get

View File

@ -809,6 +809,9 @@ def localize(text):
'Play (from start)':'Lejátszás (az elejétől)', 'Play (from start)':'Lejátszás (az elejétől)',
}, },
'ru': { 'ru': {
'Info':'Инфо',
'Delete torrent with files?':'Вы уверены, что хотите удалить торрент с файлами?',
'Fav. / Unfav.':'Доб./удал. Избранное',
'Search Window': 'Окно поиска', 'Search Window': 'Окно поиска',
'Context menu': 'Контекстное меню', 'Context menu': 'Контекстное меню',
'Seeds searching.': 'Идёт поиск сидов.', 'Seeds searching.': 'Идёт поиск сидов.',
@ -1011,6 +1014,7 @@ def localize(text):
'Stop All':'Остановить Все', 'Stop All':'Остановить Все',
'Keyboard':'Клавиатура', 'Keyboard':'Клавиатура',
'Copy Files in Root':'Скопировать файлы в Корень', 'Copy Files in Root':'Скопировать файлы в Корень',
'Copy in Root': 'Скопировать в Корень',
'Copied %d files!':'Скопировано %d файлов!', 'Copied %d files!':'Скопировано %d файлов!',
'Return to %s':'Вернуться в %s', 'Return to %s':'Вернуться в %s',
'Search results:':'Результаты поиска:', 'Search results:':'Результаты поиска:',

View File

@ -2190,3 +2190,16 @@ def get_platform():
ret["arch"] = "arm" ret["arch"] = "arm"
return ret return ret
def getTorrentClientIcon():
client = __settings__.getSetting("torrent")
if client == '1':
return 'transmission.png'
elif client == '2':
return 'vuze.png'
elif client == '3':
return 'deluge.png'
elif client == '4':
return 'qbittorrent.png'
else:
return 'torrent-client.png'

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -17,13 +17,12 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
''' '''
import xbmcaddon
import xbmcvfs
import xbmcgui
from functions import *
import pyxbmct.addonwindow as pyxbmct import pyxbmct.addonwindow as pyxbmct
import Localization import xbmcaddon
import re import xbmcgui
import xbmcvfs
from functions import *
__settings__ = xbmcaddon.Addon(id='plugin.video.torrenter') __settings__ = xbmcaddon.Addon(id='plugin.video.torrenter')
__language__ = __settings__.getLocalizedString __language__ = __settings__.getLocalizedString
@ -40,6 +39,7 @@ ACTION_MOUSE_RIGHT_CLICK = 101
ACTION_CONTEXT_MENU = 117 ACTION_CONTEXT_MENU = 117
ACTION_SHOW_OSD = 24 ACTION_SHOW_OSD = 24
class SearchWindow(pyxbmct.AddonDialogWindow): class SearchWindow(pyxbmct.AddonDialogWindow):
__settings__ = sys.modules["__main__"].__settings__ __settings__ = sys.modules["__main__"].__settings__
fileList = [] fileList = []
@ -57,6 +57,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
count = 0 count = 0
icon = __root__ + '/icons/searchwindow/%s.png' icon = __root__ + '/icons/searchwindow/%s.png'
icon_tc = __root__ + '/icons/searchwindow/%s' + getTorrentClientIcon()
def __init__(self, title="", s_param={}): def __init__(self, title="", s_param={}):
super(SearchWindow, self).__init__(title) super(SearchWindow, self).__init__(title)
@ -69,22 +70,32 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.history() self.history()
def set_controls(self): def set_controls(self):
if not __settings__.getSetting('debug') == 'true':
self.background.setImage('%s/icons/%s.png' % (__root__, 'ContentPanel')) self.background.setImage('%s/icons/%s.png' % (__root__, 'ContentPanel'))
# Top menu # Top menu
self.button_downloadstatus = pyxbmct.Button("OFF", textColor = '0xFF0000FF', focusTexture = self.icon % 'fdownloadstatus', noFocusTexture = self.icon % 'nfdownloadstatus') self.button_downloadstatus = pyxbmct.Button("OFF", textColor='0xFF0000FF',
focusTexture=self.icon % 'fdownloadstatus',
noFocusTexture=self.icon % 'nfdownloadstatus')
self.placeControl(self.button_downloadstatus, 0, 2, 1, 1) self.placeControl(self.button_downloadstatus, 0, 2, 1, 1)
self.button_torrentclient = pyxbmct.Button("OFF", textColor = '0xFF0000FF', focusTexture = self.icon % 'ftorrentclient', noFocusTexture = self.icon % 'nftorrentclient')
self.button_torrentclient = pyxbmct.Button("",
focusTexture=self.icon_tc % 'f',
noFocusTexture=self.icon_tc % 'nf')
self.placeControl(self.button_torrentclient, 0, 3, 1, 1) self.placeControl(self.button_torrentclient, 0, 3, 1, 1)
self.button_keyboard = pyxbmct.Button("", focusTexture = self.icon % 'fkeyboard', noFocusTexture = self.icon % 'nfkeyboard') self.button_keyboard = pyxbmct.Button("", focusTexture=self.icon % 'fkeyboard',
noFocusTexture=self.icon % 'nfkeyboard')
self.placeControl(self.button_keyboard, 0, 4, 1, 1) self.placeControl(self.button_keyboard, 0, 4, 1, 1)
self.input_search = pyxbmct.Edit("", _alignment=pyxbmct.ALIGN_CENTER_X | pyxbmct.ALIGN_CENTER_Y) self.input_search = pyxbmct.Edit("", _alignment=pyxbmct.ALIGN_CENTER_X | pyxbmct.ALIGN_CENTER_Y)
self.placeControl(self.input_search, 0, 5, 1, 5) self.placeControl(self.input_search, 0, 5, 1, 5)
self.button_search = pyxbmct.Button("", focusTexture = self.icon % 'fsearch', noFocusTexture = self.icon % 'nfsearch') self.button_search = pyxbmct.Button("", focusTexture=self.icon % 'fsearch',
noFocusTexture=self.icon % 'nfsearch')
self.placeControl(self.button_search, 0, 10, 1, 1) self.placeControl(self.button_search, 0, 10, 1, 1)
self.button_history = pyxbmct.Button("", focusTexture = self.icon % 'fhistory', noFocusTexture = self.icon % 'nfhistory') self.button_history = pyxbmct.Button("", focusTexture=self.icon % 'fhistory',
noFocusTexture=self.icon % 'nfhistory')
self.placeControl(self.button_history, 0, 11, 1, 1) self.placeControl(self.button_history, 0, 11, 1, 1)
self.button_controlcenter = pyxbmct.Button("", focusTexture = self.icon % 'fcontrolcenter', noFocusTexture = self.icon % 'nfcontrolcenter') self.button_controlcenter = pyxbmct.Button("", focusTexture=self.icon % 'fcontrolcenter',
noFocusTexture=self.icon % 'nfcontrolcenter')
self.placeControl(self.button_controlcenter, 0, 12, 1, 1) self.placeControl(self.button_controlcenter, 0, 12, 1, 1)
# Main # Main
@ -115,8 +126,10 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
def set_navigation(self): def set_navigation(self):
# Top menu # Top menu
self.button_downloadstatus.setNavigation(self.listing, self.listing, self.last_right_button, self.button_torrentclient) self.button_downloadstatus.setNavigation(self.listing, self.listing, self.last_right_button,
self.button_torrentclient.setNavigation(self.listing, self.listing, self.button_downloadstatus, self.button_keyboard) self.button_torrentclient)
self.button_torrentclient.setNavigation(self.listing, self.listing, self.button_downloadstatus,
self.button_keyboard)
self.button_keyboard.setNavigation(self.listing, self.listing, self.button_torrentclient, self.input_search) self.button_keyboard.setNavigation(self.listing, self.listing, self.button_torrentclient, self.input_search)
self.input_search.setNavigation(self.listing, self.listing, self.button_keyboard, self.button_search) self.input_search.setNavigation(self.listing, self.listing, self.button_keyboard, self.button_search)
self.button_search.setNavigation(self.listing, self.listing, self.input_search, self.button_history) self.button_search.setNavigation(self.listing, self.listing, self.input_search, self.button_history)
@ -124,7 +137,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.button_controlcenter.setNavigation(self.listing, self.listing, self.button_history, self.last_right_button) self.button_controlcenter.setNavigation(self.listing, self.listing, self.button_history, self.last_right_button)
# Main # Main
self.listing.setNavigation(self.input_search, self.input_search, self.button_downloadstatus, self.last_right_button) self.listing.setNavigation(self.input_search, self.input_search, self.button_downloadstatus,
self.last_right_button)
if self.listing.size(): if self.listing.size():
self.setFocus(self.listing) self.setFocus(self.listing)
@ -202,7 +216,8 @@ 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), 'fav':str(fav)} link = {'mode': 'history_search_item', 'filename': title, 'addtime': str(addtime),
'fav': str(fav)}
self.drawItem(bbstring % title, link, img) self.drawItem(bbstring % title, link, img)
def history_action(self, action, addtime, fav): def history_action(self, action, addtime, fav):
@ -221,19 +236,12 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
self.history() self.history()
def browser(self, params={}): def browser(self, hash = None, tdir = None):
from resources.utorrent.net import Download from resources.utorrent.net import Download
self.listing.reset() self.listing.reset()
menu, dirs = [], [] menu, dirs = [], []
contextMenustring = 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % (sys.argv[0], 'uTorrentBrowser', '%s') contextMenustring = 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % (sys.argv[0], 'uTorrentBrowser', '%s')
get = params.get
action = get('action')
hash = get('hash')
ind = get('ind')
tdir = get('tdir')
DownloadList = Download().list() DownloadList = Download().list()
if DownloadList == False: if DownloadList == False:
showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True) showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True)
@ -241,6 +249,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
if not hash: if not hash:
self.right_menu('browser') self.right_menu('browser')
self.reconnect(pyxbmct.ACTION_NAV_BACK, self.history)
for data in DownloadList: for data in DownloadList:
status = " " status = " "
img = '' img = ''
@ -262,7 +271,9 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
menu.append( menu.append(
{"title": title, "image": img, "argv": {'mode': 'browser_item', 'hash': str(data['id'])}}) {"title": title, "image": img, "argv": {'mode': 'browser_item', 'hash': str(data['id'])}})
elif not tdir: elif not tdir:
self.right_menu('browser_file') self.right_menu('browser_subfolder')
self.reconnect(pyxbmct.ACTION_NAV_BACK, self.browser)
self.drawItem('..', {'mode': 'browser_moveup'}, isFolder=True)
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0]) dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
for name, percent, ind, size in dllist: for name, percent, ind, size in dllist:
if '/' not in name: if '/' not in name:
@ -270,61 +281,50 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
menu.append({"title": title, "image": '', menu.append({"title": title, "image": '',
"argv": {'mode': 'browser_file', 'hash': hash, 'ind': str(ind)}}) "argv": {'mode': 'browser_file', 'hash': hash, 'ind': str(ind)}})
else: else:
tdir = name.split('/')[0] newtdir = name.split('/')[0]
if tdir not in dirs: dirs.append(tdir) if newtdir not in dirs: dirs.append(newtdir)
elif tdir: elif tdir:
self.right_menu('browser_subfolder')
tdir_up = tdir[:len(tdir)-len(tdir.split('/')[-1])-1] if '/' in tdir else None
self.drawItem('..', {'mode': 'browser_subfolder', 'hash': hash, 'tdir': tdir_up}, isFolder=True)
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0]) dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
for name, percent, ind, size in dllist: for name, percent, ind, size in dllist:
if '/' in name and tdir in name:
menu.append(
{"title": '[' + str(percent) + '%]' + '[' + str(size) + '] ' + name[len(tdir) + 1:], "image":'',
"argv": {'hash': hash, 'ind': str(ind), 'action': 'context'}})
for i in dirs: if name[:len(tdir)] == tdir:
app = {'mode':'browser_folder', 'hash': hash, 'tdir': i} name = name[len(tdir) + 1:]
link = json.dumps(app) if '/' not in name:
popup = [] title = '[%s%%][%s]%s' % (str(percent), str(size), name)
folder = True menu.append({"title": title, "image": '',
actions = [('3', self.localize('High Priority Files')), ('copy', self.localize('Copy Files in Root')), ('0', self.localize('Skip All Files'))] "argv": {'mode': 'browser_file', 'hash': hash, 'ind': str(ind)}})
for a, title in actions: else:
app['action'] = a newtdir = tdir+'/'+name.split('/')[0]
popup.append((self.localize(title), contextMenustring % urllib.quote_plus(json.dumps(app)))) if newtdir not in dirs: dirs.append(newtdir)
self.drawItem(i, 'uTorrentBrowser', link, isFolder=folder)
for tdir in dirs:
params = {'mode': 'browser_subfolder', 'hash': hash, 'tdir': tdir}
title = tdir.split('/')[-1] if '/' in tdir else tdir
self.drawItem(title, params, isFolder = True)
for i in menu: for i in menu:
app = i['argv'] params = i['argv']
link = json.dumps(app)
img = i['image'] img = i['image']
popup = [] popup = []
if not hash: if not hash:
actions = [('start', self.localize('Start')), ('stop', self.localize('Stop')),
('remove', self.localize('Remove')),
('3', self.localize('High Priority Files')), ('0', self.localize('Skip All Files')),
('removedata', self.localize('Remove with files'))]
folder = True folder = True
else: else:
actions = [('3', self.localize('High Priority')), ('0', self.localize('Skip File')),
('play', self.localize('Play File'))]
folder = False folder = False
for a, title in actions:
app['action'] = a
popup.append((self.localize(title), contextMenustring % urllib.quote_plus(json.dumps(app))))
self.drawItem(i['title'], link, image=img, isFolder=folder) self.drawItem(i['title'], params, image = img, isFolder = folder)
# def drawItem(self, title, params, image = None, isFolder = False): # def drawItem(self, title, params, image = None, isFolder = False):
if self.listing.size():
self.setFocus(self.listing)
else:
self.setFocus(self.button_torrentclient)
return return
def browser_action(self, params={}): def browser_action(self, hash, action, tdir = None, ind = None):
from resources.utorrent.net import Download from resources.utorrent.net import Download
menu = [] menu = []
get = params.get
action = get('action')
hash = get('hash')
ind = get('ind')
tdir = get('tdir')
DownloadList = Download().list() DownloadList = Download().list()
if DownloadList == False: if DownloadList == False:
@ -340,20 +340,20 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
folder = data['dir'] folder = data['dir']
break break
if isRemoteTorr(): if isRemoteTorr():
t_dir = self.__settings__.getSetting("torrent_dir") torrent_dir = self.__settings__.getSetting("torrent_dir")
torrent_replacement = self.__settings__.getSetting("torrent_replacement") torrent_replacement = self.__settings__.getSetting("torrent_replacement")
empty = [None, ''] empty = [None, '']
if t_dir in empty or torrent_replacement in empty: if torrent_dir in empty or torrent_replacement in empty:
if xbmcgui.Dialog().yesno( if xbmcgui.Dialog().yesno(
self.localize('Remote Torrent-client'), self.localize('Remote Torrent-client'),
self.localize('You didn\'t set up replacement path in setting.'), self.localize('You didn\'t set up replacement path in setting.'),
self.localize('For example /media/dl_torr/ to smb://SERVER/dl_torr/. Setup now?')): self.localize('For example /media/dl_torr/ to smb://SERVER/dl_torr/. Setup now?')):
if t_dir in empty: if torrent_dir in empty:
torrent_dir() torrent_dir()
self.__settings__.openSettings() self.__settings__.openSettings()
return return
folder = folder.replace(t_dir, torrent_replacement) folder = folder.replace(torrent_dir, torrent_replacement)
if (ind or ind == 0) and action == 'play': if (ind or ind == 0) and action == 'play':
for data in dllist: for data in dllist:
if data[2] == int(ind): if data[2] == int(ind):
@ -384,6 +384,10 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
showMessage(self.localize('Torrent-client Browser'), self.localize('Copied %d files!') % i, forced=True) showMessage(self.localize('Torrent-client Browser'), self.localize('Copied %d files!') % i, forced=True)
return return
elif not tdir and action not in ('0', '3'): elif not tdir and action not in ('0', '3'):
if action == 'removedata':
ok = xbmcgui.Dialog().yesno(self.localize('Torrent-client Browser'),
self.localize('Delete torrent with files?'))
if not ok: sys.exit(1)
Download().action_simple(action, hash) Download().action_simple(action, hash)
elif action in ('0', '3'): elif action in ('0', '3'):
dllist = sorted(Download().listfiles(hash), key=lambda x: x[0]) dllist = sorted(Download().listfiles(hash), key=lambda x: x[0])
@ -395,7 +399,6 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
menu.append((hash, action, str(ind))) menu.append((hash, action, str(ind)))
Download().setprio_simple_multi(menu) Download().setprio_simple_multi(menu)
return return
xbmc.executebuiltin('Container.Refresh')
return return
def open_torrent(self, link, tdir=None): def open_torrent(self, link, tdir=None):
@ -408,7 +411,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
dirList, contentListNew = cutFolder(self.contentList, tdir) dirList, contentListNew = cutFolder(self.contentList, tdir)
if not tdir: if not tdir:
self.drawItem('..', {'mode': 'torrent_moveup', 'filename': link}, isFolder=True) params = {'mode': 'torrent_moveup', 'filename': link}
else: else:
params = {'mode': 'torrent_subfolder', 'filename': link} params = {'mode': 'torrent_subfolder', 'filename': link}
self.drawItem('..', params, isFolder=True) self.drawItem('..', params, isFolder=True)
@ -431,33 +434,35 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
def get_menulist(self, mode): def get_menulist(self, mode):
label_list = ["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']:
label_list = ["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'),
'Info'] self.localize('Info'),]
elif mode in ['torrent_subfolder', 'torrent_moveup']: elif mode in ['torrent_subfolder', 'torrent_moveup',
label_list = ["Open"] 'browser_moveup']:
label_list = [self.localize('Open'),]
elif mode in ['history', 'history_search_item']: elif mode in ['history', 'history_search_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'),
'Fav/Unfav', self.localize('Fav. / Unfav.'),
self.localize('Delete')] self.localize('Delete')]
elif mode in ['browser', 'browser_item']: elif mode in ['browser', 'browser_item']:
label_list = [self.localize('Start'), self.localize('Stop'), label_list = [self.localize('Open'), self.localize('Start'), self.localize('Stop'),
self.localize('Remove'), self.localize('High Priority Files'), self.localize('Remove'), self.localize('High Priority'),
self.localize('Skip All Files'), self.localize('Remove with files')] self.localize('Skip All Files'), self.localize('Remove with files')]
elif mode in ['browser_file']: elif mode in ['browser_file']:
label_list = [self.localize('High Priority'), self.localize('Skip File'), label_list = [self.localize('Play File'),
self.localize('Play File')] self.localize('High Priority'), self.localize('Skip File')]
elif mode in ['browser_folder']: elif mode in ['browser_subfolder']:
label_list = [self.localize('High Priority Files'), label_list = [self.localize('Open'),
self.localize('High Priority'),
self.localize('Skip All Files'), self.localize('Skip All Files'),
self.localize('Copy Files in Root'),] self.localize('Copy in Root'), ]
return label_list return label_list
@ -502,12 +507,15 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
button = getattr(self, "button_right" + str(index)) button = getattr(self, "button_right" + str(index))
if self.right_buttons_count == 1: if self.right_buttons_count == 1:
button.setNavigation(self.button_controlcenter, self.button_right1, self.listing, self.input_search) button.setNavigation(self.button_controlcenter,
self.button_right1, self.listing, self.input_search)
else: else:
if index == button_num_list[0]: if index == button_num_list[0]:
button.setNavigation(self.button_controlcenter, self.button_right2, self.listing, self.input_search) button.setNavigation(getattr(self, "button_right" + str(self.right_buttons_count)),
self.button_right2, self.listing, self.input_search)
elif index == button_num_list[-1]: elif index == button_num_list[-1]:
button.setNavigation(getattr(self, "button_right" + str(index-1)), self.button_right1, self.listing, button.setNavigation(getattr(self, "button_right" + str(index - 1)), self.button_right1,
self.listing,
self.input_search) self.input_search)
else: else:
button.setNavigation(getattr(self, "button_right" + str(index - 1)), button.setNavigation(getattr(self, "button_right" + str(index - 1)),
@ -557,11 +565,11 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
def setlabel(self, button, label): def setlabel(self, button, label):
label = label.decode('utf-8') label = label.decode('utf-8')
log(label+' '+str(len(label))) debug('setlabel: ' + label + ' ' + str(len(label)))
if len(label) > 10: if len(label) > 10:
spaces = label.count(' ') spaces = label.count(' ')
log('spaces=' + str(spaces)) debug('setlabel spaces=' + str(spaces))
if spaces == 0: if spaces == 0:
words = [label[:10], label[10:]] words = [label[:10], label[10:]]
label = '%s-\r\n%s' % (words[0], words[1]) label = '%s-\r\n%s' % (words[0], words[1])
@ -579,38 +587,45 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
button.setLabel(label) button.setLabel(label)
def right_press1(self): def right_press1(self):
item = self.listing.getSelectedItem() item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) params = json.loads(item.getfilename())
log('params ' + str(params))
mode = params.get('mode') mode = params.get('mode')
filename = params.get('filename') filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir') tdir = params.get('tdir')
self.listing.reset() self.listing.reset()
if mode == 'search_item': if mode in ['search_item', 'torrent_subfolder']:
self.open_torrent(filename)
elif mode == 'torrent_subfolder':
self.open_torrent(filename, tdir) self.open_torrent(filename, tdir)
elif mode == 'torrent_moveup': elif mode == 'torrent_moveup':
self.search() self.search()
self.setFocus(self.listing) self.setFocus(self.listing)
elif mode == 'torrent_play': elif mode == 'torrent_play':
action = 'playTorrent' url = self.form_link('playTorrent', params)
url = self.form_link(action, params)
xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url)) xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url))
self.close() self.close()
elif mode == 'history_search_item': elif mode == 'history_search_item':
addtime = params.get('addtime') addtime = params.get('addtime')
self.input_search.setText(filename) self.input_search.setText(filename)
self.search(addtime) self.search(addtime)
elif mode == 'browser_item': elif mode in ['browser_item', 'browser_subfolder']:
self.browser(params) self.browser(hash, tdir)
elif mode == 'browser_moveup':
self.browser(hash, tdir)
elif mode == 'browser_file':
self.browser_action(hash, 'play', tdir = tdir, ind = ind)
self.close()
def right_press2(self): def right_press2(self):
item = self.listing.getSelectedItem() item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) params = json.loads(item.getfilename())
mode = params.get('mode') mode = params.get('mode')
filename = params.get('filename') filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir')
if mode == 'torrent_play': if mode == 'torrent_play':
action = 'downloadFilesList' action = 'downloadFilesList'
link = {'ind': str(params.get('url'))} link = {'ind': str(params.get('url'))}
@ -624,12 +639,21 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
elif mode == 'history_search_item': elif mode == 'history_search_item':
self.input_search.setText(filename) self.input_search.setText(filename)
self.setFocus(self.input_search) 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)
def right_press3(self): def right_press3(self):
item = self.listing.getSelectedItem() item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) params = json.loads(item.getfilename())
mode = params.get('mode') mode = params.get('mode')
filename = params.get('filename') filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir')
if mode == 'torrent_play': if mode == 'torrent_play':
action = 'downloadLibtorrent' action = 'downloadLibtorrent'
link = {'ind': str(params.get('url'))} link = {'ind': str(params.get('url'))}
@ -643,35 +667,68 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
elif mode == 'history_search_item': elif mode == 'history_search_item':
params['title'] = params.get('filename') params['title'] = params.get('filename')
self.controlCenter(params) 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)
def right_press4(self): def right_press4(self):
item = self.listing.getSelectedItem() item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) params = json.loads(item.getfilename())
mode = params.get('mode') mode = params.get('mode')
filename = params.get('filename') filename = params.get('filename')
hash = params.get('hash')
ind = params.get('ind')
tdir = params.get('tdir')
if mode == 'history_search_item': if mode == 'history_search_item':
addtime = params.get('addtime') addtime = params.get('addtime')
fav = params.get('fav') fav = params.get('fav')
self.history_action('fav', addtime, fav) self.history_action('fav', addtime, fav)
else: 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':
self.browser_action(hash, 'remove')
self.browser()
elif mode == 'browser_subfolder':
self.browser_action(hash, 'copy', tdir=tdir, ind=ind)
def right_press5(self): def right_press5(self):
item = self.listing.getSelectedItem() item = self.listing.getSelectedItem()
params = json.loads(item.getfilename()) params = json.loads(item.getfilename())
mode = params.get('mode') mode = params.get('mode')
filename = params.get('filename') filename = params.get('filename')
hash = params.get('hash')
if mode == 'history_search_item': if mode == 'history_search_item':
addtime = params.get('addtime') addtime = params.get('addtime')
fav = params.get('fav') fav = params.get('fav')
self.history_action('delete', addtime, fav) self.history_action('delete', addtime, fav)
elif mode == 'browser_item':
self.browser_action(hash, '3')
def right_press6(self): def right_press6(self):
pass item = self.listing.getSelectedItem()
params = json.loads(item.getfilename())
mode = params.get('mode')
filename = params.get('filename')
hash = params.get('hash')
if mode == 'browser_item':
self.browser_action(hash, '0')
def right_press7(self):
item = self.listing.getSelectedItem()
params = json.loads(item.getfilename())
mode = params.get('mode')
filename = params.get('filename')
hash = params.get('hash')
if mode == 'browser_item':
self.browser_action(hash, 'removedata')
self.browser()
def localize(self, string): def localize(self, string):
try: try:
@ -706,9 +763,9 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
import controlcenter import controlcenter
controlcenter.main() controlcenter.main()
def reconnect(self, event, callabel): def reconnect(self, event, callable):
self.disconnect(event) self.disconnect(event)
self.connect(event, callabel) self.connect(event, callable)
def version_check(self): def version_check(self):
return False if int(xbmc.getInfoLabel("System.BuildVersion")[:2]) < 17 else True return False if int(xbmc.getInfoLabel("System.BuildVersion")[:2]) < 17 else True
@ -718,8 +775,6 @@ class SearchWindow(pyxbmct.AddonDialogWindow):
class InfoWindow(pyxbmct.AddonDialogWindow): class InfoWindow(pyxbmct.AddonDialogWindow):
def __init__(self, title="", year=""): def __init__(self, title="", year=""):
super(InfoWindow, self).__init__(title) super(InfoWindow, self).__init__(title)
self.title = title self.title = title
@ -729,7 +784,6 @@ class InfoWindow(pyxbmct.AddonDialogWindow):
self.connect_controls() self.connect_controls()
# self.set_navigation() # self.set_navigation()
def set_controls(self): def set_controls(self):
# pyxbmct.AddonWindow().setImage(__root__ + '/resources/skins/Default/media/ConfluenceDialogBack.png') # pyxbmct.AddonWindow().setImage(__root__ + '/resources/skins/Default/media/ConfluenceDialogBack.png')
# self.placeControl(self.background, 0, 0, rowspan=3, columnspan=2) # self.placeControl(self.background, 0, 0, rowspan=3, columnspan=2)
@ -744,7 +798,6 @@ class InfoWindow(pyxbmct.AddonDialogWindow):
# self.button_search = pyxbmct.Button("Search") # self.button_search = pyxbmct.Button("Search")
# self.placeControl(self.button_search, 0, 5, 1, 2) # self.placeControl(self.button_search, 0, 5, 1, 2)
def connect_controls(self): def connect_controls(self):
from resources.scrapers.scrapers import Scrapers from resources.scrapers.scrapers import Scrapers
self.Scraper = Scrapers() self.Scraper = Scrapers()
@ -766,6 +819,7 @@ class InfoWindow(pyxbmct.AddonDialogWindow):
self.logoimg.setImage(meta.get('thumbnail')) self.logoimg.setImage(meta.get('thumbnail'))
self.plot.setText(meta.get('plot')) self.plot.setText(meta.get('plot'))
def log(msg): def log(msg):
try: try:
xbmc.log("### [%s]: %s" % (__plugin__, msg,), level=xbmc.LOGNOTICE) xbmc.log("### [%s]: %s" % (__plugin__, msg,), level=xbmc.LOGNOTICE)
@ -774,8 +828,8 @@ def log(msg):
except: except:
xbmc.log("### [%s]: %s" % (__plugin__, 'ERROR LOG',), level=xbmc.LOGNOTICE) xbmc.log("### [%s]: %s" % (__plugin__, 'ERROR LOG',), level=xbmc.LOGNOTICE)
def titleMake(seeds, leechers, size, title):
def titleMake(seeds, leechers, size, title):
# AARRGGBB # AARRGGBB
clGreen = '[COLOR FF008000]%s[/COLOR]' clGreen = '[COLOR FF008000]%s[/COLOR]'
clDodgerblue = '[COLOR FF1E90FF]%s[/COLOR]' clDodgerblue = '[COLOR FF1E90FF]%s[/COLOR]'