2016-11-26 12:06:04 +03:00
# -*- coding: utf-8 -*-
'''
Torrenter v2 plugin for XBMC / Kodi
Copyright ( C ) 2012 - 2015 Vadim Skorba v1 - DiMartino v2
https : / / forums . tvaddons . ag / addon - releases / 29224 - torrenter - v2 . html
This program is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the #
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : / / www . gnu . org / licenses / > .
'''
2016-12-09 21:11:23 +03:00
import pyxbmct . addonwindow as pyxbmct
2016-11-26 13:14:33 +03:00
import xbmcaddon
2016-11-26 12:06:04 +03:00
import xbmcgui
2016-12-09 21:11:23 +03:00
import xbmcvfs
2016-12-08 18:30:45 +03:00
from functions import *
2016-11-26 12:06:04 +03:00
__settings__ = xbmcaddon . Addon ( id = ' plugin.video.torrenter ' )
2016-11-26 13:14:33 +03:00
__language__ = __settings__ . getLocalizedString
2016-11-26 12:06:04 +03:00
__version__ = __settings__ . getAddonInfo ( ' version ' )
__plugin__ = __settings__ . getAddonInfo ( ' name ' ) + " v. " + __version__
2016-11-26 13:14:33 +03:00
__root__ = __settings__ . getAddonInfo ( ' path ' )
log ( ' SYS ARGV: ' + str ( sys . argv ) )
2016-11-26 12:06:04 +03:00
2016-12-09 21:11:23 +03:00
# https://github.com/xbmc/xbmc/blob/8d4a5bba55638dfd0bdc5e7de34f3e5293f99933/xbmc/input/Key.h
2016-11-27 23:45:05 +03:00
ACTION_STOP = 13
ACTION_PLAYER_PLAY = 79
2016-11-29 23:29:11 +03:00
ACTION_MOUSE_RIGHT_CLICK = 101
ACTION_CONTEXT_MENU = 117
ACTION_SHOW_OSD = 24
2016-11-26 12:06:04 +03:00
2016-12-09 21:11:23 +03:00
2016-11-28 20:22:50 +03:00
class SearchWindow ( pyxbmct . AddonDialogWindow ) :
2016-11-26 19:05:04 +03:00
__settings__ = sys . modules [ " __main__ " ] . __settings__
fileList = [ ]
2016-11-27 16:12:06 +03:00
contentList = [ ]
2016-12-08 18:30:45 +03:00
searchersList = [ ]
2016-12-08 19:15:42 +03:00
addtime = None
2016-12-15 00:24:21 +03:00
right_buttons_count = 7
2016-12-16 20:17:10 +03:00
right_label_count = 7
2016-11-27 16:12:06 +03:00
last_right_buttons_count = 0
last_link = None
last_query = None
2016-11-28 20:22:50 +03:00
last_top_button = None
last_right_button = None
2016-12-08 23:58:03 +03:00
last_listing_mode = None
count = 0
2016-12-15 00:24:21 +03:00
navi = {
' last_top_button ' : 4 ,
' last_right_button ' : 1 ,
' right_menu ' : [ ] ,
' top_menu ' : [ ] ,
' route ' : [ { ' mode ' : ' close ' , ' params ' : { } , ' last_listing_item ' : 0 } ]
}
2016-11-26 19:05:04 +03:00
2016-12-08 18:30:45 +03:00
icon = __root__ + ' /icons/searchwindow/ %s .png '
2016-12-09 21:11:23 +03:00
icon_tc = __root__ + ' /icons/searchwindow/ %s ' + getTorrentClientIcon ( )
2016-12-08 18:30:45 +03:00
2016-12-15 00:24:21 +03:00
def __init__ ( self , params = None ) :
super ( SearchWindow , self ) . __init__ ( self . localize ( ' Torrenter Search Window ' ) )
2016-11-26 12:06:04 +03:00
self . setGeometry ( 1280 , 720 , 9 , 16 )
self . set_controls ( )
self . connect_controls ( )
2016-12-15 00:24:21 +03:00
if params :
self . search ( params )
2016-12-04 12:12:03 +03:00
else :
2016-12-15 00:24:21 +03:00
self . history ( )
if self . listing . size ( ) :
self . setFocus ( self . listing )
else :
self . setFocus ( self . input_search )
2016-11-26 12:06:04 +03:00
def set_controls ( self ) :
2016-12-09 21:11:23 +03:00
if not __settings__ . getSetting ( ' debug ' ) == ' true ' :
self . background . setImage ( ' %s /icons/ %s .png ' % ( __root__ , ' ContentPanel ' ) )
2016-11-26 12:06:04 +03:00
2016-12-10 01:01:06 +03:00
#self.background.setImage('%s/icons/%s.png' % (__root__, 'ContentPanel'))
2016-12-09 21:11:23 +03:00
# Top menu
2016-12-12 19:28:00 +03:00
self . button_downloadstatus = pyxbmct . Button ( " " ,
2016-12-09 21:11:23 +03:00
focusTexture = self . icon % ' fdownloadstatus ' ,
noFocusTexture = self . icon % ' nfdownloadstatus ' )
2016-12-11 01:13:58 +03:00
self . placeControl ( self . button_downloadstatus , 0 , 1 , 1 , 1 )
2016-12-09 21:11:23 +03:00
2016-12-16 20:17:10 +03:00
self . button_browser = pyxbmct . Button ( " " ,
2016-12-09 21:11:23 +03:00
focusTexture = self . icon_tc % ' f ' ,
noFocusTexture = self . icon_tc % ' nf ' )
2016-12-16 20:17:10 +03:00
self . placeControl ( self . button_browser , 0 , 2 , 1 , 1 )
2016-12-09 21:11:23 +03:00
self . button_keyboard = pyxbmct . Button ( " " , focusTexture = self . icon % ' fkeyboard ' ,
noFocusTexture = self . icon % ' nfkeyboard ' )
2016-12-11 01:13:58 +03:00
self . placeControl ( self . button_keyboard , 0 , 3 , 1 , 1 )
2016-12-07 16:31:03 +03:00
self . input_search = pyxbmct . Edit ( " " , _alignment = pyxbmct . ALIGN_CENTER_X | pyxbmct . ALIGN_CENTER_Y )
2016-12-11 01:13:58 +03:00
self . placeControl ( self . input_search , 0 , 4 , 1 , 5 )
2016-12-09 21:11:23 +03:00
self . button_search = pyxbmct . Button ( " " , focusTexture = self . icon % ' fsearch ' ,
noFocusTexture = self . icon % ' nfsearch ' )
2016-12-11 01:13:58 +03:00
self . placeControl ( self . button_search , 0 , 9 , 1 , 1 )
2016-12-09 21:11:23 +03:00
self . button_history = pyxbmct . Button ( " " , focusTexture = self . icon % ' fhistory ' ,
noFocusTexture = self . icon % ' nfhistory ' )
2016-12-11 01:13:58 +03:00
self . placeControl ( self . button_history , 0 , 10 , 1 , 1 )
self . button_watched = pyxbmct . Button ( " " , focusTexture = self . icon % ' fwatched ' ,
noFocusTexture = self . icon % ' nfwatched ' )
self . placeControl ( self . button_watched , 0 , 11 , 1 , 1 )
2016-12-09 21:11:23 +03:00
self . button_controlcenter = pyxbmct . Button ( " " , focusTexture = self . icon % ' fcontrolcenter ' ,
noFocusTexture = self . icon % ' nfcontrolcenter ' )
2016-12-07 16:31:03 +03:00
self . placeControl ( self . button_controlcenter , 0 , 12 , 1 , 1 )
2016-12-09 21:11:23 +03:00
# Main
2016-11-29 23:29:11 +03:00
self . listing = pyxbmct . List ( _imageWidth = 60 , _imageHeight = 60 , _itemTextXOffset = 1 ,
2016-11-30 15:59:47 +03:00
_itemTextYOffset = 0 , _itemHeight = 60 , _space = 0 , _alignmentY = 4 )
2016-11-26 13:14:33 +03:00
self . placeControl ( self . listing , 1 , 0 , 8 , 14 )
2016-11-26 12:06:04 +03:00
2016-12-16 20:17:10 +03:00
self . navi [ ' top_menu ' ] = [ self . button_downloadstatus , self . button_browser , self . button_keyboard ,
2016-12-15 00:24:21 +03:00
self . input_search , self . button_search , self . button_history , self . button_watched ,
self . button_controlcenter ]
2016-12-09 21:11:23 +03:00
# Right menu
2016-11-28 20:22:50 +03:00
self . right_menu ( )
2016-11-26 12:06:04 +03:00
def connect_controls ( self ) :
2016-11-27 23:45:05 +03:00
self . connect ( self . listing , self . right_press1 )
2016-11-26 19:05:04 +03:00
self . connect ( self . button_history , self . history )
self . connect ( self . button_search , self . search )
2016-12-16 20:17:10 +03:00
self . connect ( self . button_controlcenter , self . controlcenter )
self . connect ( self . button_browser , self . browser )
2016-12-10 01:01:06 +03:00
self . connect ( self . button_downloadstatus , self . downloadstatus )
2016-12-11 01:13:58 +03:00
self . connect ( self . button_watched , self . watched )
2016-11-26 12:06:04 +03:00
2016-12-15 00:24:21 +03:00
self . connect ( pyxbmct . ACTION_NAV_BACK , self . navi_back )
self . connect ( pyxbmct . ACTION_PREVIOUS_MENU , self . navi_back )
2016-12-21 18:52:26 +03:00
self . connect ( xbmcgui . ACTION_BACKSPACE , self . navi_back )
self . connect ( xbmcgui . KEY_BUTTON_BACK , self . navi_back )
2016-12-15 00:24:21 +03:00
2016-11-29 23:29:11 +03:00
self . connect ( ACTION_MOUSE_RIGHT_CLICK , self . context )
self . connect ( ACTION_CONTEXT_MENU , self . context )
self . connect ( ACTION_SHOW_OSD , self . context )
2016-12-15 00:24:21 +03:00
self . connect ( pyxbmct . ACTION_MOVE_LEFT , self . navi_update )
self . connect ( pyxbmct . ACTION_MOVE_RIGHT , self . navi_update )
self . connect ( pyxbmct . ACTION_MOVE_UP , self . navi_update )
self . connect ( pyxbmct . ACTION_MOVE_DOWN , self . navi_update )
2016-12-08 23:58:03 +03:00
2016-11-26 12:06:04 +03:00
def set_navigation ( self ) :
2016-12-09 21:11:23 +03:00
# Top menu
2016-12-16 20:17:10 +03:00
self . button_browser . setNavigation ( self . listing , self . listing , self . button_downloadstatus ,
2016-12-09 21:11:23 +03:00
self . button_keyboard )
2016-12-16 20:17:10 +03:00
self . button_keyboard . setNavigation ( self . listing , self . listing , self . button_browser , self . input_search )
2016-12-07 16:31:03 +03:00
self . input_search . setNavigation ( self . listing , self . listing , self . button_keyboard , self . button_search )
2016-11-26 13:14:33 +03:00
self . button_search . setNavigation ( self . listing , self . listing , self . input_search , self . button_history )
2016-12-11 01:13:58 +03:00
self . button_history . setNavigation ( self . listing , self . listing , self . button_search , self . button_watched )
self . button_watched . setNavigation ( self . listing , self . listing , self . button_history , self . button_controlcenter )
2016-12-15 00:24:21 +03:00
self . update_navigation ( )
def update_navigation ( self ) :
self . last_top_button = self . navi [ ' top_menu ' ] [ self . navi [ ' last_top_button ' ] - 1 ]
2016-12-16 20:17:10 +03:00
if self . navi [ ' last_right_button ' ] > self . right_label_count :
self . navi [ ' last_right_button ' ] = self . right_label_count
2016-12-15 00:24:21 +03:00
self . last_right_button = self . navi [ ' right_menu ' ] [ self . navi [ ' last_right_button ' ] - 1 ]
# Top menu
self . button_downloadstatus . setNavigation ( self . listing , self . listing , self . last_right_button ,
2016-12-16 20:17:10 +03:00
self . button_browser )
2016-12-11 01:13:58 +03:00
self . button_controlcenter . setNavigation ( self . listing , self . listing , self . button_watched , self . last_right_button )
2016-12-07 16:31:03 +03:00
2016-12-09 21:11:23 +03:00
# Main
2016-12-15 00:24:21 +03:00
self . listing . setNavigation ( self . last_top_button , self . input_search , self . button_downloadstatus ,
2016-12-09 21:11:23 +03:00
self . last_right_button )
2016-11-26 13:14:33 +03:00
def setAnimation ( self , control ) :
# Set fade animation for all add-on window controls
control . setAnimations ( [ ( ' WindowOpen ' , ' effect=fade start=0 end=100 time=500 ' , ) ,
( ' WindowClose ' , ' effect=fade start=100 end=0 time=500 ' , ) ] )
2016-12-15 00:24:21 +03:00
def navi_back ( self ) :
log ( ' navi_back init ' )
self . navi [ ' route ' ] . pop ( - 1 )
2016-12-19 19:53:58 +03:00
self . navi_restore ( )
def navi_restore ( self ) :
log ( ' navi_restore init ' )
2016-12-15 00:24:21 +03:00
route = self . navi [ ' route ' ] [ - 1 ]
action = getattr ( self , route [ ' mode ' ] )
if route [ ' params ' ] :
action ( route [ ' params ' ] )
else :
action ( )
self . setFocus ( self . listing )
log ( ' route[last_listing_item]: ' + str ( route [ ' last_listing_item ' ] ) )
if route [ ' last_listing_item ' ] > 0 :
self . listing . selectItem ( route [ ' last_listing_item ' ] )
def navi_update ( self ) :
log ( ' navi_update init ' )
2016-12-16 20:17:10 +03:00
try :
focused_control = self . getFocus ( )
except :
focused_control = None
2016-12-15 00:24:21 +03:00
debug ( ' start navi_update ' + str ( focused_control ) )
log ( str ( self . navi [ ' route ' ] ) )
if focused_control == self . listing :
item_index = self . listing . getSelectedPosition ( )
self . navi [ ' route ' ] [ - 1 ] [ ' last_listing_item ' ] = item_index
debug ( ' self.listing getSelectedPosition ' + str ( item_index ) )
item = self . listing . getSelectedItem ( )
params = json . loads ( item . getfilename ( ) )
mode = params . get ( ' mode ' )
log ( ' navi_update: ' + str ( mode ) )
if self . last_listing_mode != mode :
self . last_listing_mode = mode
debug ( ' set_menulist navi_update: ' + str ( mode ) )
self . set_menulist ( mode )
2016-12-16 20:17:10 +03:00
self . update_navigation ( )
2016-12-15 00:24:21 +03:00
2016-12-16 20:17:10 +03:00
elif focused_control in self . navi [ ' top_menu ' ] :
2016-12-15 00:24:21 +03:00
self . navi [ ' last_top_button ' ] = self . navi [ ' top_menu ' ] . index ( focused_control ) + 1
self . update_navigation ( )
2016-12-16 20:17:10 +03:00
elif focused_control in self . navi [ ' right_menu ' ] :
2016-12-15 00:24:21 +03:00
self . navi [ ' last_right_button ' ] = self . navi [ ' right_menu ' ] . index ( focused_control ) + 1
self . update_navigation ( )
2016-12-19 19:53:58 +03:00
def navi_route ( self , mode , params = { } , right_menu = None ) :
2016-12-15 21:05:49 +03:00
log ( ' navi_route init ' )
2016-12-16 20:17:10 +03:00
try :
focused_control = self . getFocus ( )
except :
focused_control = None
if focused_control in self . navi [ ' top_menu ' ] :
2016-12-19 19:53:58 +03:00
log ( ' focused_control in self.navi[ \' top_menu \' ] ' )
2016-12-16 20:17:10 +03:00
self . navi [ ' route ' ] = [ self . navi [ ' route ' ] [ 0 ] ]
2016-12-19 19:53:58 +03:00
if not params or not params . get ( ' back ' ) :
log ( ' ***** self.navi[ \' route \' ].append ***** ' + str ( mode ) + str ( params ) )
2016-12-15 21:05:49 +03:00
if not params :
params = { ' back ' : True }
else :
params [ ' back ' ] = True
self . navi [ ' route ' ] . append ( { ' mode ' : mode ,
' params ' : params ,
2016-12-19 19:53:58 +03:00
' last_listing_item ' : 0 } )
self . right_menu ( mode if not right_menu else right_menu )
2016-11-26 12:06:04 +03:00
self . listing . reset ( )
2016-12-15 00:24:21 +03:00
2016-12-16 20:17:10 +03:00
def search ( self , params = { } ) :
2016-12-15 00:24:21 +03:00
self . navi_route ( ' search ' , params )
get = params . get
addtime = get ( ' addtime ' )
2016-12-16 20:17:10 +03:00
query = get ( ' query ' )
2016-12-15 00:24:21 +03:00
2016-12-16 20:17:10 +03:00
if query :
search = urllib . unquote_plus ( query )
external = get ( " return_name " )
if external :
searcher = ' landing from : %s ' % str ( external )
2016-12-04 12:12:03 +03:00
else :
2016-12-16 20:17:10 +03:00
searcher = ' '
#self.setWindowTitle(title='%s %s' % ('Torrenter Search Window', searcher))
if get ( ' showKey ' ) == ' true ' :
self . input_search . setText ( search )
self . setFocus ( self . input_search )
return
else :
self . input_search . setText ( search )
query = search
else :
query = self . input_search . getText ( )
2016-12-09 21:11:23 +03:00
log ( ' Search query: ' + str ( query ) )
2016-11-26 19:05:04 +03:00
2016-12-08 19:15:42 +03:00
if not addtime and query == self . last_query :
addtime = self . addtime
2016-12-08 18:30:45 +03:00
searchersList = get_searchersList ( addtime )
2016-12-09 21:11:23 +03:00
# cache
2016-12-16 20:17:10 +03:00
self . navi [ ' route ' ] [ - 1 ] [ ' query ' ] = query
2016-12-09 21:11:23 +03:00
if ( query != self . last_query or self . searchersList != searchersList ) and len ( query ) > 0 :
2016-12-08 18:30:45 +03:00
self . filesList = get_filesList ( query , searchersList , addtime )
2016-12-08 19:15:42 +03:00
self . addtime = addtime
2016-12-08 18:30:45 +03:00
self . searchersList = searchersList
2016-11-27 16:12:06 +03:00
self . last_query = query
2016-12-09 21:11:23 +03:00
elif len ( query ) == 0 :
2016-12-04 12:12:03 +03:00
self . filesList = [ ]
2016-12-15 21:05:49 +03:00
if self . filesList :
for ( order , seeds , leechers , size , title , link , image ) in self . filesList :
title = titleMake ( seeds , leechers , size , title )
self . drawItem ( title , { ' mode ' : ' search_item ' , ' filename ' : link } , image )
self . setFocus ( self . listing )
2016-11-26 12:06:04 +03:00
2016-12-16 20:17:10 +03:00
def history ( self , params = { } ) :
2016-12-15 21:05:49 +03:00
self . navi_route ( ' history ' , params )
2016-11-28 22:21:22 +03:00
db = HistoryDB ( )
items = db . get_all ( )
favlist = [ ( 1 , ' [B] %s [/B] ' ) , ( 0 , ' %s ' ) ]
2016-12-15 21:05:49 +03:00
last_listing_item = 0
2016-11-28 22:21:22 +03:00
if items :
for favbool , bbstring in favlist :
for addtime , string , fav in items :
if favbool == int ( fav ) :
title = string . encode ( ' utf-8 ' )
if int ( fav ) == 1 :
img = __root__ + ' /icons/fav.png '
2016-12-15 21:05:49 +03:00
last_listing_item + = 1
2016-11-28 22:21:22 +03:00
else :
img = __root__ + ' /icons/unfav.png '
2016-12-15 22:05:11 +03:00
link = { ' mode ' : ' history_item ' , ' query ' : title , ' addtime ' : str ( addtime ) ,
2016-12-09 21:11:23 +03:00
' fav ' : str ( fav ) }
2016-11-29 23:55:05 +03:00
self . drawItem ( bbstring % title , link , img )
2016-12-15 21:05:49 +03:00
self . navi [ ' route ' ] [ - 1 ] [ ' last_listing_item ' ] = last_listing_item
2016-11-28 22:21:22 +03:00
2016-11-28 23:31:26 +03:00
def history_action ( self , action , addtime , fav ) :
db = HistoryDB ( )
2016-11-27 23:45:05 +03:00
2016-11-28 23:31:26 +03:00
if action == ' delete ' :
db . delete ( addtime )
showMessage ( self . localize ( ' Search History ' ) , self . localize ( ' Deleted! ' ) )
2016-11-28 20:22:50 +03:00
2016-11-28 23:31:26 +03:00
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! ' ) )
2016-11-28 20:22:50 +03:00
2016-11-28 23:31:26 +03:00
self . history ( )
2016-11-28 20:22:50 +03:00
2016-12-19 19:53:58 +03:00
def watched ( self , params = { } ) :
self . navi_route ( ' watched ' , params )
2016-12-11 01:13:58 +03:00
db = WatchedHistoryDB ( )
items = db . get_all ( )
log ( ' [WatchedHistory]: items - ' + str ( items ) )
if items :
for addtime , filename , foldername , path , url , seek , length , ind , size in items :
seek = int ( seek ) if int ( seek ) > 3 * 60 else 0
watchedPercent = int ( ( float ( seek ) / float ( length ) ) * 100 )
duration = ' %02d : %02d : %02d ' % ( ( length / ( 60 * 60 ) ) , ( length / 60 ) % 60 , length % 60 )
title = ' [ %d %% ][ %s ] %s [ %d MB] ' % \
( watchedPercent , duration , filename . encode ( ' utf-8 ' ) , int ( size ) )
clDimgray = ' [COLOR FF696969] %s [/COLOR] '
clWhite = ' [COLOR FFFFFFFF] %s [/COLOR] '
title = clWhite % title + chr ( 10 ) + clDimgray % ' ( %s ) ' % foldername . encode ( ' utf-8 ' )
if watchedPercent > = 85 :
img = __root__ + ' /icons/stop-icon.png '
else :
img = __root__ + ' /icons/pause-icon.png '
link = { ' mode ' : ' watched_item ' , ' addtime ' : str ( addtime ) }
self . drawItem ( title , link , image = img )
def watched_action ( self , action , addtime ) :
db = WatchedHistoryDB ( )
if action == ' delete ' :
db . delete ( addtime )
showMessage ( self . localize ( ' Watched History ' ) , self . localize ( ' Deleted! ' ) )
self . watched ( )
if action == ' open ' :
filename , foldername , path , url , seek , length , ind = db . get ( ' filename, foldername, path, url, seek, length, ind ' , ' addtime ' , str ( addtime ) )
2016-12-15 22:05:11 +03:00
params = { ' link ' : path . encode ( ' utf-8 ' ) }
self . open_torrent ( params )
2016-12-11 01:13:58 +03:00
if action == ' playnoseek ' or action == ' playwithseek ' :
filename , path , url , seek , length , ind = db . get ( ' filename, path, url, seek, length, ind ' , ' addtime ' , str ( addtime ) )
if action == ' playwithseek ' :
seek = int ( seek )
else :
seek = 0
if os . path . exists ( path ) :
__settings__ . setSetting ( " lastTorrent " , path )
else :
from Downloader import Downloader
torrent = Downloader . Torrent ( self . userStorageDirectory , torrentFilesDirectory = self . torrentFilesDirectory )
__settings__ . setSetting ( " lastTorrent " , torrent . saveTorrent ( url ) )
xbmc . executebuiltin ( ' xbmc.RunPlugin( " plugin://plugin.video.torrenter/?action=playTorrent&url= ' + str ( ind ) + ' &seek= ' + str ( seek ) + ' " ) ' )
self . close ( )
if action == ' clear ' :
db . clear ( )
showMessage ( self . localize ( ' Watched History ' ) , self . localize ( ' Clear! ' ) )
self . watched ( )
2016-12-19 19:53:58 +03:00
def browser ( self , params = { } ) :
2016-12-08 18:30:45 +03:00
from resources . utorrent . net import Download
menu , dirs = [ ] , [ ]
2016-12-19 19:53:58 +03:00
get = params . get
hash = get ( ' hash ' )
tdir = get ( ' tdir ' )
2016-12-08 18:30:45 +03:00
DownloadList = Download ( ) . list ( )
if DownloadList == False :
showMessage ( self . localize ( ' Error ' ) , self . localize ( ' No connection! Check settings! ' ) , forced = True )
return
if not hash :
2016-12-19 19:53:58 +03:00
self . navi_route ( ' browser ' )
2016-12-08 18:30:45 +03:00
for data in DownloadList :
status = " "
2016-12-09 21:11:23 +03:00
img = ' '
2016-12-08 18:30:45 +03:00
if data [ ' status ' ] in ( ' seed_pending ' , ' stopped ' ) :
status = TextBB ( ' [||] ' , ' b ' )
elif data [ ' status ' ] in ( ' seeding ' , ' downloading ' ) :
status = TextBB ( ' [>] ' , ' b ' )
2016-12-09 21:11:23 +03:00
if data [ ' status ' ] == ' seed_pending ' :
2016-12-08 23:58:03 +03:00
img = os . path . join ( __root__ , ' icons ' , ' pause-icon.png ' )
2016-12-08 18:30:45 +03:00
elif data [ ' status ' ] == ' stopped ' :
2016-12-08 23:58:03 +03:00
img = os . path . join ( __root__ , ' icons ' , ' stop-icon.png ' )
2016-12-08 18:30:45 +03:00
elif data [ ' status ' ] == ' seeding ' :
2016-12-08 23:58:03 +03:00
img = os . path . join ( __root__ , ' icons ' , ' upload-icon.png ' )
2016-12-08 18:30:45 +03:00
elif data [ ' status ' ] == ' downloading ' :
2016-12-08 23:58:03 +03:00
img = os . path . join ( __root__ , ' icons ' , ' download-icon.png ' )
2016-12-09 21:11:23 +03:00
title = ' [ %s %% ] %s %s [ %s ] ' % ( str ( data [ ' progress ' ] ) , status , data [ ' name ' ] , str ( data [ ' ratio ' ] ) )
2016-12-08 18:30:45 +03:00
menu . append (
2016-12-09 21:11:23 +03:00
{ " title " : title , " image " : img , " argv " : { ' mode ' : ' browser_item ' , ' hash ' : str ( data [ ' id ' ] ) } } )
2016-12-19 19:53:58 +03:00
2016-12-08 18:30:45 +03:00
elif not tdir :
2016-12-19 19:53:58 +03:00
self . navi_route ( ' browser ' , params , ' browser_subfolder ' )
2016-12-16 20:17:10 +03:00
self . drawItem ( ' .. ' , { ' mode ' : ' browser_moveup ' } , image = ' DefaultFolderBack.png ' , isFolder = True )
2016-12-08 18:30:45 +03:00
dllist = sorted ( Download ( ) . listfiles ( hash ) , key = lambda x : x [ 0 ] )
for name , percent , ind , size in dllist :
if ' / ' not in name :
2016-12-08 23:58:03 +03:00
title = ' [ %s %% ][ %s ] %s ' % ( str ( percent ) , str ( size ) , name )
2016-12-09 21:11:23 +03:00
menu . append ( { " title " : title , " image " : ' ' ,
" argv " : { ' mode ' : ' browser_file ' , ' hash ' : hash , ' ind ' : str ( ind ) } } )
2016-12-08 18:30:45 +03:00
else :
2016-12-09 21:11:23 +03:00
newtdir = name . split ( ' / ' ) [ 0 ]
if newtdir not in dirs : dirs . append ( newtdir )
2016-12-08 18:30:45 +03:00
elif tdir :
2016-12-19 19:53:58 +03:00
self . navi_route ( ' browser ' , params , ' browser_subfolder ' )
self . drawItem ( ' .. ' , { ' mode ' : ' browser_moveup ' } , isFolder = True )
2016-12-08 18:30:45 +03:00
dllist = sorted ( Download ( ) . listfiles ( hash ) , key = lambda x : x [ 0 ] )
for name , percent , ind , size in dllist :
2016-12-09 21:11:23 +03:00
if name [ : len ( tdir ) ] == tdir :
name = name [ len ( tdir ) + 1 : ]
if ' / ' not in name :
title = ' [ %s %% ][ %s ] %s ' % ( str ( percent ) , str ( size ) , name )
menu . append ( { " title " : title , " image " : ' ' ,
" argv " : { ' mode ' : ' browser_file ' , ' hash ' : hash , ' ind ' : str ( ind ) } } )
else :
newtdir = tdir + ' / ' + name . split ( ' / ' ) [ 0 ]
if newtdir not in dirs : dirs . append ( newtdir )
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 )
2016-12-08 18:30:45 +03:00
for i in menu :
2016-12-09 21:11:23 +03:00
params = i [ ' argv ' ]
2016-12-08 18:30:45 +03:00
img = i [ ' image ' ]
popup = [ ]
if not hash :
folder = True
else :
folder = False
2016-12-09 21:11:23 +03:00
self . drawItem ( i [ ' title ' ] , params , image = img , isFolder = folder )
# def drawItem(self, title, params, image = None, isFolder = False):
if self . listing . size ( ) :
self . setFocus ( self . listing )
else :
2016-12-16 20:17:10 +03:00
self . setFocus ( self . button_browser )
2016-12-08 18:30:45 +03:00
return
2016-12-09 21:11:23 +03:00
def browser_action ( self , hash , action , tdir = None , ind = None ) :
2016-12-08 18:30:45 +03:00
from resources . utorrent . net import Download
2016-12-08 23:58:03 +03:00
menu = [ ]
2016-12-08 18:30:45 +03:00
DownloadList = Download ( ) . list ( )
if DownloadList == False :
showMessage ( self . localize ( ' Error ' ) , self . localize ( ' No connection! Check settings! ' ) , forced = True )
2016-12-19 19:53:58 +03:00
return False
2016-12-08 18:30:45 +03:00
if ( ind or ind == 0 ) and action in ( ' 0 ' , ' 3 ' ) :
Download ( ) . setprio_simple ( hash , action , ind )
2016-12-09 21:11:23 +03:00
elif action in [ ' play ' , ' copy ' ] :
2016-12-08 18:30:45 +03:00
p , dllist , i , folder , filename = DownloadList , Download ( ) . listfiles ( hash ) , 0 , None , None
for data in p :
if data [ ' id ' ] == hash :
folder = data [ ' dir ' ]
break
if isRemoteTorr ( ) :
2016-12-11 01:13:58 +03:00
torrent_dir = __settings__ . getSetting ( " torrent_dir " )
torrent_replacement = __settings__ . getSetting ( " torrent_replacement " )
2016-12-08 18:30:45 +03:00
empty = [ None , ' ' ]
2016-12-09 21:11:23 +03:00
if torrent_dir in empty or torrent_replacement in empty :
2016-12-08 18:30:45 +03:00
if xbmcgui . Dialog ( ) . yesno (
self . localize ( ' Remote Torrent-client ' ) ,
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? ' ) ) :
2016-12-09 21:11:23 +03:00
if torrent_dir in empty :
2016-12-08 18:30:45 +03:00
torrent_dir ( )
2016-12-11 01:13:58 +03:00
__settings__ . openSettings ( )
2016-12-08 18:30:45 +03:00
return
2016-12-09 21:11:23 +03:00
folder = folder . replace ( torrent_dir , torrent_replacement )
2016-12-08 18:30:45 +03:00
if ( ind or ind == 0 ) and action == ' play ' :
for data in dllist :
if data [ 2 ] == int ( ind ) :
filename = data [ 0 ]
break
filename = os . path . join ( folder , filename )
xbmc . executebuiltin ( ' xbmc.PlayMedia( " ' + filename . encode ( ' utf-8 ' ) + ' " ) ' )
elif tdir and action == ' copy ' :
2016-12-09 21:11:23 +03:00
path = os . path . join ( folder , tdir )
dirs , files = xbmcvfs . listdir ( path )
2016-12-08 18:30:45 +03:00
if len ( dirs ) > 0 :
dirs . insert ( 0 , self . localize ( ' ./ (Root folder) ' ) )
for dd in dirs :
dd = file_decode ( dd )
2016-12-09 21:11:23 +03:00
dds = xbmcvfs . listdir ( os . path . join ( path , dd ) ) [ 0 ]
if len ( dds ) > 0 :
2016-12-08 18:30:45 +03:00
for d in dds :
2016-12-09 21:11:23 +03:00
dirs . append ( dd + os . sep + d )
2016-12-08 18:30:45 +03:00
ret = xbmcgui . Dialog ( ) . select ( self . localize ( ' Choose directory: ' ) , dirs )
if ret > 0 :
2016-12-09 21:11:23 +03:00
path = os . path . join ( path , dirs [ ret ] )
dirs , files = xbmcvfs . listdir ( path )
2016-12-08 18:30:45 +03:00
for file in files :
2016-12-09 21:11:23 +03:00
if not xbmcvfs . exists ( os . path . join ( path , file ) ) :
xbmcvfs . delete ( os . path . join ( path , file ) )
xbmcvfs . copy ( os . path . join ( path , file ) , os . path . join ( folder , file ) )
i = i + 1
2016-12-08 18:30:45 +03:00
showMessage ( self . localize ( ' Torrent-client Browser ' ) , self . localize ( ' Copied %d files! ' ) % i , forced = True )
2016-12-19 19:53:58 +03:00
return True
2016-12-08 18:30:45 +03:00
elif not tdir and action not in ( ' 0 ' , ' 3 ' ) :
2016-12-09 21:11:23 +03:00
if action == ' removedata ' :
ok = xbmcgui . Dialog ( ) . yesno ( self . localize ( ' Torrent-client Browser ' ) ,
self . localize ( ' Delete torrent with files? ' ) )
if not ok : sys . exit ( 1 )
2016-12-08 18:30:45 +03:00
Download ( ) . action_simple ( action , hash )
elif action in ( ' 0 ' , ' 3 ' ) :
dllist = sorted ( Download ( ) . listfiles ( hash ) , key = lambda x : x [ 0 ] )
for name , percent , ind , size in dllist :
if tdir :
if ' / ' in name and tdir in name :
menu . append ( ( hash , action , str ( ind ) ) )
else :
menu . append ( ( hash , action , str ( ind ) ) )
Download ( ) . setprio_simple_multi ( menu )
2016-12-19 19:53:58 +03:00
return True
return True
2016-12-08 18:30:45 +03:00
2016-12-16 20:17:10 +03:00
def downloadstatus ( self , params = { } ) :
2016-12-10 01:01:06 +03:00
self . listing . reset ( )
self . right_menu ( ' downloadstatus ' )
2016-12-15 00:24:21 +03:00
#self.reconnect(pyxbmct.ACTION_NAV_BACK, self.history)
2016-12-10 01:01:06 +03:00
db = DownloadDB ( )
items = db . get_all ( )
2016-12-11 01:13:58 +03:00
if items :
for addtime , title , path , type , info , status , torrent , ind , lastupdate , storage in items :
jsoninfo = json . loads ( urllib . unquote_plus ( info ) )
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
if status != ' stopped ' and int ( lastupdate ) < int ( time . time ( ) ) - 10 :
status = ' stopped '
db . update_status ( addtime , status )
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
progress = int ( jsoninfo . get ( ' progress ' ) )
if status == ' pause ' :
status_sign = ' [||] '
img = os . path . join ( __root__ , ' icons ' , ' pause-icon.png ' )
elif status == ' stopped ' :
status_sign = ' [X] '
img = os . path . join ( __root__ , ' icons ' , ' stop-icon.png ' )
2016-12-10 01:01:06 +03:00
else :
2016-12-11 01:13:58 +03:00
status_sign = ' [>] '
if progress == 100 :
img = os . path . join ( __root__ , ' icons ' , ' upload-icon.png ' )
else :
img = os . path . join ( __root__ , ' icons ' , ' download-icon.png ' )
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
title = ' [ %d %% ] %s %s ' % ( progress , status_sign , title )
if jsoninfo . get ( ' seeds ' ) != None and jsoninfo . get ( ' peers ' ) != None and \
jsoninfo . get ( ' download ' ) != None and jsoninfo . get ( ' upload ' ) != None :
d , u = float ( jsoninfo [ ' download ' ] ) / 1000000 , float ( jsoninfo [ ' upload ' ] ) / 1000000
s , p = str ( jsoninfo [ ' seeds ' ] ) , str ( jsoninfo [ ' peers ' ] )
second = ' [D/U %.2f / %.2f (MB/s)][S/L %s / %s ] ' % ( d , u , s , p )
title = dlstat_titleMake ( ' [B] %s [/B] ' % title if type == ' folder ' else title , second )
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
params = { ' addtime ' : addtime , ' type ' : type , ' path ' : path ,
' status ' : status , ' progress ' : progress , ' storage ' : storage }
params [ ' mode ' ] = ' downloadstatus_subfolder ' if type == ' folder ' else ' downloadstatus_file '
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
self . drawItem ( title , params , image = img , isFolder = type == ' folder ' )
2016-12-10 01:01:06 +03:00
# def drawItem(self, title, params, image = None, isFolder = False):
if self . listing . size ( ) :
self . setFocus ( self . listing )
else :
self . setFocus ( self . button_downloadstatus )
return
def downloadstatus_action ( self , action , addtime , path , type , progress , storage ) :
db = DownloadDB ( )
if action == ' play ' :
2016-12-11 01:13:58 +03:00
if type == ' file ' and progress > 30 or progress == 100 :
self . file_browser ( type , path , path )
2016-12-10 01:01:06 +03:00
else :
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Download has not finished yet ' ) )
2016-12-11 01:13:58 +03:00
elif action == ' delete ' :
2016-12-10 01:01:06 +03:00
db . delete ( addtime )
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Stopped and Deleted! ' ) )
2016-12-11 01:13:58 +03:00
elif action == ' pause ' :
2016-12-10 01:01:06 +03:00
db . update_status ( addtime , ' pause ' )
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Paused! ' ) )
2016-12-11 01:13:58 +03:00
elif action == ' stop ' :
2016-12-10 01:01:06 +03:00
db . update_status ( addtime , ' stopped ' )
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Stopped! ' ) )
2016-12-11 01:13:58 +03:00
elif action == ' start ' :
start = db . get_byaddtime ( addtime )
if start [ 5 ] == ' pause ' :
2016-12-10 01:01:06 +03:00
db . update_status ( addtime , ' downloading ' )
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Unpaused! ' ) )
else :
torrent , ind = start [ 6 ] , start [ 7 ]
2016-12-11 01:13:58 +03:00
del db
import SkorbaLoader
__settings__ . setSetting ( " lastTorrent " , torrent . encode ( ' utf-8 ' ) )
2016-12-12 19:28:00 +03:00
torrent = SkorbaLoader . SkorbaLoader ( storage . encode ( ' utf-8 ' ) , torrent )
2016-12-11 01:13:58 +03:00
encryption = __settings__ . getSetting ( ' encryption ' ) == ' true '
2016-12-12 19:28:00 +03:00
torrent . downloadProcess ( ind , encryption )
2016-12-10 01:01:06 +03:00
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Started! ' ) )
2016-12-12 19:28:00 +03:00
xbmc . sleep ( 1000 )
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
elif action == ' masscontrol ' :
dialog_items = [ self . localize ( ' Start All ' ) , self . localize ( ' Stop All ' ) ,
self . localize ( ' Clear %s ' ) % self . localize ( ' Download Status ' ) , self . localize ( ' Cancel ' ) ]
ret = xbmcgui . Dialog ( ) . select ( self . localize ( ' Mass Control ' ) , dialog_items )
if ret == 0 :
items = db . get_all ( )
2016-12-12 19:28:00 +03:00
del db
2016-12-11 01:13:58 +03:00
if items :
2016-12-12 19:28:00 +03:00
import SkorbaLoader
2016-12-11 01:13:58 +03:00
for addtime , title , path , type , info , status , torrent , ind , lastupdate , storage in items :
2016-12-12 19:28:00 +03:00
__settings__ . setSetting ( " lastTorrent " , torrent . encode ( ' utf-8 ' ) )
torrent = SkorbaLoader . SkorbaLoader ( storage . encode ( ' utf-8 ' ) , torrent )
encryption = __settings__ . getSetting ( ' encryption ' ) == ' true '
torrent . downloadProcess ( ind , encryption )
2016-12-11 01:13:58 +03:00
xbmc . sleep ( 1000 )
2016-12-12 19:28:00 +03:00
xbmc . sleep ( 2000 )
2016-12-11 01:13:58 +03:00
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Started All! ' ) )
elif ret == 1 :
items = db . get_all ( )
if items :
for addtime , title , path , type , info , status , torrent , ind , lastupdate , storage in items :
db . update_status ( addtime , ' stopped ' )
xbmc . sleep ( 1000 )
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Stopped All! ' ) )
elif ret == 2 :
db . clear ( )
showMessage ( self . localize ( ' Download Status ' ) , self . localize ( ' Clear! ' ) )
xbmc . sleep ( 1000 )
self . downloadstatus ( )
2016-12-19 19:53:58 +03:00
def file_browser ( self , params ) :
self . navi_route ( ' browser ' , params )
get = params . get
mode = get ( ' mode ' )
path = get ( ' path ' )
tdir = get ( ' tdir ' )
2016-12-11 01:13:58 +03:00
path = encode_msg ( path )
tdir = encode_msg ( tdir )
2016-12-10 01:01:06 +03:00
2016-12-11 01:13:58 +03:00
if tdir == os . path . dirname ( path ) :
self . downloadstatus ( )
elif mode == ' file ' :
xbmc . Player ( ) . play ( localize_path ( tdir ) )
self . close ( )
else :
self . right_menu ( ' file_browser ' )
2016-12-15 00:24:21 +03:00
#self.reconnect(pyxbmct.ACTION_NAV_BACK, self.downloadstatus)
2016-12-11 01:13:58 +03:00
self . drawItem ( ' .. ' , { ' mode ' : ' moveup ' , ' path ' : path ,
2016-12-16 20:17:10 +03:00
' tdir ' : os . path . dirname ( tdir ) } , image = ' DefaultFolderBack.png ' , isFolder = True )
2016-12-11 01:13:58 +03:00
dirs , files = xbmcvfs . listdir ( tdir + os . sep )
if len ( dirs ) > 0 :
for dir in dirs :
link = { ' mode ' : ' subfolder ' , ' path ' : path , ' type ' : ' folder ' ,
' tdir ' : os . path . join ( tdir , dir ) }
self . drawItem ( dir , link , isFolder = True )
for file in files :
link = { ' mode ' : ' file ' , ' path ' : path , ' type ' : ' file ' ,
' tdir ' : os . path . join ( tdir , file ) }
self . drawItem ( file , link , isFolder = False )
if self . listing . size ( ) :
self . setFocus ( self . listing )
else :
self . setFocus ( self . button_downloadstatus )
2016-12-10 01:01:06 +03:00
2016-12-15 22:05:11 +03:00
def open_torrent ( self , params ) :
self . navi_route ( ' open_torrent ' , params )
# def open_torrent(self, link, tdir=None):
get = params . get
link = get ( ' link ' )
tdir = get ( ' tdir ' )
2016-12-09 21:11:23 +03:00
# cache
2016-11-27 16:12:06 +03:00
if link != self . last_link :
self . contentList = get_contentList ( link )
self . last_link = link
dirList , contentListNew = cutFolder ( self . contentList , tdir )
if not tdir :
2016-12-09 21:11:23 +03:00
params = { ' mode ' : ' torrent_moveup ' , ' filename ' : link }
2016-11-27 16:12:06 +03:00
else :
2016-11-29 23:55:05 +03:00
params = { ' mode ' : ' torrent_subfolder ' , ' filename ' : link }
2016-12-16 20:17:10 +03:00
self . drawItem ( ' .. ' , params , image = ' DefaultFolderBack.png ' , isFolder = True )
2016-11-27 16:12:06 +03:00
2016-11-29 23:55:05 +03:00
dirList = sorted ( dirList , key = lambda x : x [ 0 ] , reverse = False )
2016-11-27 16:12:06 +03:00
for title in dirList :
2016-12-09 21:11:23 +03:00
self . drawItem ( title , { ' mode ' : ' torrent_subfolder ' , ' tdir ' : title , ' filename ' : link } , isFolder = True )
2016-11-27 16:12:06 +03:00
ids_video_result = get_ids_video ( contentListNew )
2016-12-09 21:11:23 +03:00
ids_video = ' '
2016-11-27 16:12:06 +03:00
2016-12-09 21:11:23 +03:00
if len ( ids_video_result ) > 0 :
2016-11-27 16:12:06 +03:00
for identifier in ids_video_result :
ids_video = ids_video + str ( identifier ) + ' , '
2016-11-29 23:55:05 +03:00
contentListNew = sorted ( contentListNew , key = lambda x : x [ 0 ] , reverse = False )
2016-11-27 16:12:06 +03:00
for title , identifier , filesize in contentListNew :
2016-11-29 23:55:05 +03:00
params = { ' mode ' : ' torrent_play ' , ' url ' : identifier , ' url2 ' : ids_video . rstrip ( ' , ' ) , ' filename ' : link }
self . drawItem ( title , params )
2016-11-26 19:05:04 +03:00
2016-11-29 23:29:11 +03:00
def get_menulist ( self , mode ) :
2016-11-27 16:12:06 +03:00
2016-12-09 21:11:23 +03:00
label_list = [ " Empty " , " Empty " , " Empty " , " Empty " , " Empty " , " Empty " , " Empty " ]
2016-11-27 16:12:06 +03:00
2016-12-15 22:05:11 +03:00
if mode in [ ' search ' , ' search_item ' , ' torrent_play ' , ' open_torrent ' ] :
2016-12-09 21:11:23 +03:00
label_list = [ self . localize ( ' Open ' ) ,
2016-11-28 20:22:50 +03:00
self . localize ( ' Download via T-client ' ) ,
2016-11-30 15:59:47 +03:00
self . localize ( ' Download via Libtorrent ' ) ,
2016-12-09 21:11:23 +03:00
self . localize ( ' Info ' ) , ]
2016-12-16 20:17:10 +03:00
elif mode in [ ' torrent_subfolder ' , ' file_browser ' , ' subfolder ' ] :
2016-12-09 21:11:23 +03:00
label_list = [ self . localize ( ' Open ' ) , ]
2016-12-16 20:17:10 +03:00
elif mode in [ ' torrent_moveup ' , ' browser_moveup ' ] :
label_list = [ self . localize ( ' Move Up ' ) , ]
2016-12-10 01:01:06 +03:00
elif mode in [ ' file ' ] :
label_list = [ self . localize ( ' Play ' ) , ]
2016-12-15 22:05:11 +03:00
elif mode in [ ' history ' , ' history_item ' ] :
2016-11-28 22:21:22 +03:00
label_list = [ self . localize ( ' Open ' ) ,
self . localize ( ' Edit ' ) ,
self . localize ( ' Individual Tracker Options ' ) ,
2016-12-09 21:11:23 +03:00
self . localize ( ' Fav. / Unfav. ' ) ,
2016-11-28 22:21:22 +03:00
self . localize ( ' Delete ' ) ]
2016-12-08 18:30:45 +03:00
elif mode in [ ' browser ' , ' browser_item ' ] :
2016-12-09 21:11:23 +03:00
label_list = [ self . localize ( ' Open ' ) , self . localize ( ' Start ' ) , self . localize ( ' Stop ' ) ,
self . localize ( ' Remove ' ) , self . localize ( ' High Priority ' ) ,
2016-12-08 18:30:45 +03:00
self . localize ( ' Skip All Files ' ) , self . localize ( ' Remove with files ' ) ]
elif mode in [ ' browser_file ' ] :
2016-12-09 21:11:23 +03:00
label_list = [ self . localize ( ' Play File ' ) ,
self . localize ( ' High Priority ' ) , self . localize ( ' Skip File ' ) ]
elif mode in [ ' browser_subfolder ' ] :
label_list = [ self . localize ( ' Open ' ) ,
self . localize ( ' High Priority ' ) ,
2016-12-08 23:58:03 +03:00
self . localize ( ' Skip All Files ' ) ,
2016-12-09 21:11:23 +03:00
self . localize ( ' Copy in Root ' ) , ]
2016-12-10 01:01:06 +03:00
elif mode in [ ' downloadstatus ' , ' downloadstatus_subfolder ' ] :
label_list = [ self . localize ( ' Open ' ) , self . localize ( ' Start ' ) , self . localize ( ' Pause ' ) ,
self . localize ( ' Stop ' ) , self . localize ( ' Delete ' ) , self . localize ( ' Mass Control ' ) , ]
elif mode in [ ' downloadstatus_file ' ] :
label_list = [ self . localize ( ' Play ' ) , self . localize ( ' Start ' ) , self . localize ( ' Pause ' ) ,
self . localize ( ' Stop ' ) , self . localize ( ' Delete ' ) , self . localize ( ' Mass Control ' ) , ]
2016-12-11 01:13:58 +03:00
elif mode in [ ' watched ' , ' watched_item ' ] :
label_list = [ self . localize ( ' Open Torrent ' ) , self . localize ( ' Play (from start) ' ) ,
self . localize ( ' Play (with seek) ' ) , self . localize ( ' Delete ' ) , self . localize ( ' Clear History ' ) , ]
2016-12-16 20:17:10 +03:00
self . right_label_count = len ( label_list )
2016-11-29 23:29:11 +03:00
return label_list
def context ( self ) :
if self . getFocus ( ) == self . listing :
item = self . listing . getSelectedItem ( )
2016-11-29 23:55:05 +03:00
params = json . loads ( item . getfilename ( ) )
2016-11-29 23:29:11 +03:00
mode = params . get ( ' mode ' )
2016-11-29 23:55:05 +03:00
filename = params . get ( ' filename ' )
2016-11-29 23:29:11 +03:00
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
remove_list = [ getattr ( self , " button_right " + str ( index ) ) for index
2016-12-09 21:11:23 +03:00
in range ( 1 , self . last_right_buttons_count + 1 ) ]
2016-11-29 23:29:11 +03:00
self . disconnectEventList ( remove_list )
self . removeControls ( remove_list )
label_list = self . get_menulist ( mode )
2016-12-15 00:24:21 +03:00
self . navi [ ' right_menu ' ] = [ ]
2016-11-29 23:29:11 +03:00
2016-11-28 20:22:50 +03:00
self . right_buttons_count = len ( label_list )
2016-12-09 21:11:23 +03:00
button_num_list = range ( 1 , self . right_buttons_count + 1 )
2016-11-28 20:22:50 +03:00
for index in button_num_list :
setattr ( self , " button_right " + str ( index ) , pyxbmct . Button ( label_list [ index - 1 ] ) )
button = getattr ( self , " button_right " + str ( index ) )
2016-12-09 21:11:23 +03:00
self . connect ( button , getattr ( self , " right_press " + str ( index ) ) )
2016-11-28 20:22:50 +03:00
self . placeControl ( button , index , 14 , 1 , 2 )
2016-12-09 21:11:23 +03:00
# Navigation
2016-12-15 00:24:21 +03:00
self . navi [ ' last_right_button ' ] = 1
2016-11-28 20:22:50 +03:00
for index in button_num_list :
button = getattr ( self , " button_right " + str ( index ) )
2016-12-15 00:24:21 +03:00
self . navi [ ' right_menu ' ] . append ( button )
2016-11-28 20:22:50 +03:00
if self . right_buttons_count == 1 :
2016-12-09 21:11:23 +03:00
button . setNavigation ( self . button_controlcenter ,
self . button_right1 , self . listing , self . input_search )
2016-11-28 20:22:50 +03:00
else :
if index == button_num_list [ 0 ] :
2016-12-09 21:11:23 +03:00
button . setNavigation ( getattr ( self , " button_right " + str ( self . right_buttons_count ) ) ,
self . button_right2 , self . listing , self . input_search )
2016-11-28 20:22:50 +03:00
elif index == button_num_list [ - 1 ] :
2016-12-09 21:11:23 +03:00
button . setNavigation ( getattr ( self , " button_right " + str ( index - 1 ) ) , self . button_right1 ,
self . listing ,
self . input_search )
2016-11-28 20:22:50 +03:00
else :
button . setNavigation ( getattr ( self , " button_right " + str ( index - 1 ) ) ,
getattr ( self , " button_right " + str ( index + 1 ) ) ,
self . listing ,
self . input_search )
2016-12-08 23:58:03 +03:00
self . set_menulist ( mode )
2016-11-28 20:22:50 +03:00
self . set_navigation ( )
2016-11-26 13:14:33 +03:00
2016-12-08 23:58:03 +03:00
def set_menulist ( self , mode ) :
2016-12-09 21:11:23 +03:00
self . count + = 1
2016-12-08 23:58:03 +03:00
label_list = self . get_menulist ( mode )
2016-12-09 21:11:23 +03:00
debug ( ' set_menulist; ' + str ( label_list ) )
2016-12-08 23:58:03 +03:00
2016-12-16 20:17:10 +03:00
button_num_list = range ( 1 , self . right_label_count + 1 )
2016-12-09 21:11:23 +03:00
debug ( ' set_menulist button_num_list: ' + str ( button_num_list ) )
2016-12-08 23:58:03 +03:00
for index in button_num_list :
button = getattr ( self , " button_right " + str ( index ) )
self . setlabel ( button , ( label_list [ index - 1 ] ) )
button . setEnabled ( True )
2016-12-16 20:17:10 +03:00
if self . right_buttons_count > self . right_label_count :
disable_button_num_list = range ( self . right_label_count + 1 , self . right_buttons_count + 1 )
2016-12-08 23:58:03 +03:00
debug ( ' set_menulist disable_button_num_list: ' + str ( disable_button_num_list ) )
for index in disable_button_num_list :
button = getattr ( self , " button_right " + str ( index ) )
button . setLabel ( ' ' )
button . setEnabled ( False )
def setlabel ( self , button , label ) :
label = label . decode ( ' utf-8 ' )
2016-12-09 21:11:23 +03:00
debug ( ' setlabel: ' + label + ' ' + str ( len ( label ) ) )
2016-12-08 23:58:03 +03:00
if len ( label ) > 10 :
spaces = label . count ( ' ' )
2016-12-09 21:11:23 +03:00
debug ( ' setlabel spaces= ' + str ( spaces ) )
2016-12-08 23:58:03 +03:00
if spaces == 0 :
words = [ label [ : 10 ] , label [ 10 : ] ]
label = ' %s - \r \n %s ' % ( words [ 0 ] , words [ 1 ] )
elif spaces == 1 :
words = label . split ( ' ' )
label = ' %s \r \n %s ' % ( words [ 0 ] , words [ 1 ] )
elif spaces == 2 :
words = label . split ( ' ' )
if len ( words [ 0 ] ) < = len ( words [ 2 ] ) :
words [ 0 ] = words [ 0 ] + ' ' + words [ 1 ]
words [ 1 ] = words [ 2 ]
else :
words [ 1 ] = words [ 1 ] + ' ' + words [ 2 ]
label = ' %s \r \n %s ' % ( words [ 0 ] , words [ 1 ] )
button . setLabel ( label )
2016-11-28 23:31:26 +03:00
def right_press1 ( self ) :
2016-12-15 22:05:11 +03:00
self . right_press ( 1 )
def right_press2 ( self ) :
self . right_press ( 2 )
def right_press3 ( self ) :
self . right_press ( 3 )
def right_press4 ( self ) :
self . right_press ( 4 )
def right_press5 ( self ) :
self . right_press ( 5 )
def right_press6 ( self ) :
self . right_press ( 6 )
def right_press7 ( self ) :
self . right_press ( 7 )
def right_press ( self , index ) :
2016-11-28 23:31:26 +03:00
item = self . listing . getSelectedItem ( )
2016-11-29 23:55:05 +03:00
params = json . loads ( item . getfilename ( ) )
2016-12-15 22:05:11 +03:00
log ( ' right_press %d params %s ' % ( index , str ( params ) ) )
2016-11-28 23:31:26 +03:00
mode = params . get ( ' mode ' )
2016-11-29 23:55:05 +03:00
filename = params . get ( ' filename ' )
2016-12-09 21:11:23 +03:00
hash = params . get ( ' hash ' )
ind = params . get ( ' ind ' )
2016-11-28 23:31:26 +03:00
tdir = params . get ( ' tdir ' )
2016-12-15 22:05:11 +03:00
action = None
2016-12-09 21:11:23 +03:00
if mode in [ ' search_item ' , ' torrent_subfolder ' ] :
2016-12-15 22:05:11 +03:00
if index == 1 :
params = { ' link ' : filename , ' tdir ' : tdir }
self . open_torrent ( params )
elif index == 2 :
action = ' downloadFilesList '
link = { ' url ' : filename }
url = self . form_link ( action , link )
xbmc . executebuiltin ( ' xbmc.RunPlugin( " %s " ) ' % ( url ) )
elif index == 3 :
action = ' downloadLibtorrent '
link = { ' url ' : filename }
url = self . form_link ( action , link )
xbmc . executebuiltin ( ' xbmc.RunPlugin( " %s " ) ' % ( url ) )
elif index == 4 : #search_item
cleanlabel = re . sub ( ' \ [[^ \ ]]* \ ] ' , ' ' , item . getLabel ( ) )
ttl , yr = xbmc . getCleanMovieTitle ( cleanlabel )
infoW = InfoWindow ( ttl , yr )
infoW . doModal ( )
del infoW
2016-12-19 19:53:58 +03:00
elif mode in [ ' torrent_moveup ' , ' browser_moveup ' , ' moveup ' ] :
self . navi_back ( )
2016-11-28 23:31:26 +03:00
elif mode == ' torrent_play ' :
2016-12-15 22:05:11 +03:00
if index == 1 :
url = self . form_link ( ' playTorrent ' , params )
xbmc . executebuiltin ( ' xbmc.RunPlugin( " %s " ) ' % ( url ) )
self . close ( )
elif index == 2 :
action = ' downloadFilesList '
link = { ' ind ' : str ( params . get ( ' url ' ) ) }
url = self . form_link ( action , link )
xbmc . executebuiltin ( ' xbmc.RunPlugin( " %s " ) ' % ( url ) )
elif index == 3 :
action = ' downloadLibtorrent '
link = { ' ind ' : str ( params . get ( ' url ' ) ) }
url = self . form_link ( action , link )
xbmc . executebuiltin ( ' xbmc.RunPlugin( " %s " ) ' % ( url ) )
elif mode == ' history_item ' :
2016-11-28 23:31:26 +03:00
addtime = params . get ( ' addtime ' )
2016-12-15 22:05:11 +03:00
fav = params . get ( ' fav ' )
query = params . get ( ' query ' )
if index == 1 :
self . input_search . setText ( query )
self . search ( { ' addtime ' : addtime } )
elif index == 2 :
self . input_search . setText ( query )
self . setFocus ( self . input_search )
elif index == 3 :
params [ ' title ' ] = params . get ( ' query ' )
self . controlCenter ( params )
else :
if index == 4 : action = ' fav '
elif index == 5 : action = ' delete '
self . history_action ( action , addtime , fav )
2016-12-19 19:53:58 +03:00
elif mode in [ ' browser_item ' , ' browser_subfolder ' ] :
2016-12-15 22:05:11 +03:00
if index == 1 :
2016-12-19 19:53:58 +03:00
self . browser ( params )
2016-12-15 22:05:11 +03:00
elif index in [ 2 , 3 , 4 ] and mode == ' browser_subfolder ' :
if index == 2 : action = ' 3 '
elif index == 3 : action = ' 0 '
elif index == 4 : action = ' copy '
self . browser_action ( hash , action , tdir = tdir , ind = ind )
else :
if index == 2 : action = ' start '
elif index == 3 : action = ' stop '
elif index == 4 : action = ' remove '
elif index == 5 : action = ' 3 '
elif index == 6 : action = ' 0 '
elif index == 7 : action = ' removedata '
2016-11-28 23:31:26 +03:00
2016-12-19 19:53:58 +03:00
if self . browser_action ( hash , action ) :
self . navi_restore ( )
2016-12-09 21:11:23 +03:00
elif mode == ' browser_file ' :
2016-12-15 22:05:11 +03:00
if index == 1 : action = ' play '
elif index == 2 : action = ' 3 '
elif index == 3 : action = ' 0 '
2016-11-28 23:31:26 +03:00
2016-12-15 22:05:11 +03:00
self . browser_action ( hash , action , tdir = tdir , ind = ind )
2016-11-28 23:31:26 +03:00
2016-12-15 22:05:11 +03:00
if index == 1 :
self . close ( )
2016-12-11 01:13:58 +03:00
elif mode in [ ' downloadstatus ' , ' downloadstatus_subfolder ' , ' downloadstatus_file ' ] :
2016-12-15 22:05:11 +03:00
if index == 1 : action = ' play '
elif index == 2 : action = ' start '
elif index == 3 : action = ' pause '
elif index == 4 : action = ' stop '
elif index == 5 : action = ' delete '
elif index == 6 : action = ' masscontrol '
self . downloadstatus_action ( action , params . get ( ' addtime ' ) , params . get ( ' path ' ) ,
2016-12-11 01:13:58 +03:00
params . get ( ' type ' ) , params . get ( ' progress ' ) , params . get ( ' storage ' ) )
2016-12-19 19:53:58 +03:00
elif mode in [ ' subfolder ' , ' file ' ] :
self . file_browser ( params )
2016-12-11 01:13:58 +03:00
elif mode == ' watched_item ' :
2016-12-15 22:05:11 +03:00
if index == 1 : action = ' open '
elif index == 2 : action = ' playnoseek '
elif index == 3 : action = ' playwithseek '
elif index == 4 : action = ' delete '
elif index == 5 : action = ' clear '
self . watched_action ( action , params . get ( ' addtime ' ) )
2016-11-28 23:31:26 +03:00
2016-11-26 13:14:33 +03:00
def localize ( self , string ) :
try :
return Localization . localize ( string )
except :
return string
2016-11-26 12:06:04 +03:00
2016-12-09 21:11:23 +03:00
def drawItem ( self , title , params , image = None , isFolder = False ) :
2016-11-27 16:12:06 +03:00
if isinstance ( params , str ) :
params = { ' mode ' : params }
if not image and isFolder :
image = ' DefaultFolder.png '
elif not image :
image = ' DefaultVideo.png '
2016-11-29 23:55:05 +03:00
listitem = xbmcgui . ListItem ( title , ' ' , image , image , json . dumps ( params ) )
2016-11-27 16:12:06 +03:00
self . listing . addItem ( listitem )
def form_link ( self , action , link ) :
if isinstance ( link , dict ) :
link_url = ' '
for key in link . keys ( ) :
if link . get ( key ) and key != ' mode ' :
link_url = ' %s & %s = %s ' % ( link_url , key , urllib . quote_plus ( link . get ( key ) ) )
url = ' %s ?action= %s ' % ( ' plugin://plugin.video.torrenter/ ' , action ) + link_url
else :
url = ' %s ?action= %s &url= %s ' % ( ' plugin://plugin.video.torrenter/ ' , action , urllib . quote_plus ( link ) )
return url
2016-12-16 20:17:10 +03:00
def controlcenter ( self , params = { } ) :
2016-12-04 13:03:44 +03:00
import controlcenter
2016-12-07 16:31:03 +03:00
controlcenter . main ( )
2016-11-27 23:45:05 +03:00
2016-12-09 21:11:23 +03:00
def reconnect ( self , event , callable ) :
2016-11-28 22:21:22 +03:00
self . disconnect ( event )
2016-12-09 21:11:23 +03:00
self . connect ( event , callable )
2016-11-28 22:21:22 +03:00
2016-11-29 23:29:11 +03:00
def version_check ( self ) :
2016-12-09 21:11:23 +03:00
return False if int ( xbmc . getInfoLabel ( " System.BuildVersion " ) [ : 2 ] ) < 17 else True
2016-11-29 23:29:11 +03:00
2016-11-30 15:59:47 +03:00
class InfoWindow ( pyxbmct . AddonDialogWindow ) :
2016-11-30 21:02:38 +03:00
def __init__ ( self , title = " " , year = " " ) :
2016-11-30 15:59:47 +03:00
super ( InfoWindow , self ) . __init__ ( title )
self . title = title
2016-11-30 21:02:38 +03:00
self . year = year
self . setGeometry ( 600 , 600 , 3 , 3 )
2016-11-30 15:59:47 +03:00
self . set_controls ( )
self . connect_controls ( )
2016-12-09 21:11:23 +03:00
# self.set_navigation()
2016-12-08 18:30:45 +03:00
2016-11-30 15:59:47 +03:00
def set_controls ( self ) :
2016-12-09 21:11:23 +03:00
# pyxbmct.AddonWindow().setImage(__root__ + '/resources/skins/Default/media/ConfluenceDialogBack.png')
# self.placeControl(self.background, 0, 0, rowspan=3, columnspan=2)
2016-11-30 21:02:38 +03:00
self . listing = pyxbmct . List ( _imageWidth = 30 , _imageHeight = 30 , _itemTextXOffset = 1 ,
_itemTextYOffset = 0 , _itemHeight = 30 , _space = 0 , _alignmentY = 0 )
self . placeControl ( self . listing , 0 , 1 , 2 , 2 )
self . logoimg = pyxbmct . Image ( ' ' , aspectRatio = 0 )
self . placeControl ( self . logoimg , 0 , 0 , rowspan = 2 )
self . plot = pyxbmct . TextBox ( )
self . placeControl ( self . plot , 2 , 0 , 1 , columnspan = 3 )
self . plot . autoScroll ( 1000 , 1000 , 1000 )
2016-12-09 21:11:23 +03:00
# self.button_search = pyxbmct.Button("Search")
# self.placeControl(self.button_search, 0, 5, 1, 2)
2016-11-30 15:59:47 +03:00
def connect_controls ( self ) :
2016-11-30 21:02:38 +03:00
from resources . scrapers . scrapers import Scrapers
self . Scraper = Scrapers ( )
meta = self . Scraper . scraper ( ' tmdb ' , { ' label ' : ' tmdb ' , ' search ' : self . title , ' year ' : ' ' } , ' en ' )
meta = meta . get ( ' info ' )
2016-12-09 21:11:23 +03:00
2016-11-30 15:59:47 +03:00
"""
2016-11-30 21:02:38 +03:00
meta results for xXx
{ ' info ' : { ' count ' : 7451 , ' plot ' : u ' Xander Cage is your standard adrenaline junkie with no fear and a lousy attitude. When the US Government " recruits " him to go on a mission, he \' s not exactly thrilled. His mission: to gather information on an organization that may just be planning the destruction of the world, led by the nihilistic Yorgi. ' , ' votes ' : u ' 809 ' , ' code ' : u ' tt0295701 ' , ' rating ' : 5.7000000000000002 , ' title ' : u ' xXx ' , ' tagline ' : u ' A New Breed Of Secret Agent. ' , ' director ' : u ' Rob Cohen ' , ' premiered ' : u ' 2002-08-09 ' , ' originaltitle ' : u ' xXx ' , ' cast ' : [ u ' Vin Diesel ' , u ' Asia Argento ' , u ' Marton Csokas ' , u ' Samuel L. Jackson ' , u ' Michael Roof ' , u ' Petr J \xe1 kl Jr. ' , u ' Richy M \xfc ller ' , u ' Joe Bucaro III ' , u ' Eve ' , u ' Leila Arcieri ' , u ' William Hope ' , u ' Ted Maynard ' , u ' Martin Hub ' ] , ' castandrole ' : [ u ' Vin Diesel|Xander Cage ' , u ' Asia Argento|Yelena ' , u ' Marton Csokas|Yorgi ' , u ' Samuel L. Jackson|Agent Gibbons ' , u ' Michael Roof|Agent Toby Lee Shavers ' , u ' Petr J \xe1 kl Jr.|Kolya ' , u ' Richy M \xfc ller|Milan Sova ' , u ' Joe Bucaro III|Virg ' , u ' Eve|J.J. ' , u ' Leila Arcieri|Jordan King ' , u ' William Hope|Agent Roger Donnan ' , u ' Ted Maynard|James Tannick ' , u ' Martin Hub|Ivan Podrov ' ] , ' studio ' : u ' Columbia Pictures, Original Film, Revolution Studios ' , ' year ' : 2002 , ' genre ' : u ' Action ' , ' runtime ' : u ' 124 ' } , ' thumbnail ' : u ' http://image.tmdb.org/t/p/original/fPHNTG1OXFBQ6aEVO7Lv8tSgfrY.jpg ' , ' label ' : ' tmdb ' , ' properties ' : { ' fanart_image ' : u ' http://image.tmdb.org/t/p/original/oNQIcuvJssiK93TjrXVtbERaKE1.jpg ' } , ' icon ' : u ' http://image.tmdb.org/t/p/original/fPHNTG1OXFBQ6aEVO7Lv8tSgfrY.jpg ' }
2016-11-30 15:59:47 +03:00
"""
self . connect ( pyxbmct . ACTION_NAV_BACK , self . close )
self . connect ( pyxbmct . ACTION_PREVIOUS_MENU , self . close )
2016-12-09 21:11:23 +03:00
self . listing . addItem ( " Title: %s " % meta . get ( ' title ' ) )
self . listing . addItem ( " genre: %s " % meta . get ( ' genre ' ) )
self . listing . addItem ( " rating: %s " % meta . get ( ' rating ' ) )
self . listing . addItem ( " year: %s " % meta . get ( ' year ' ) )
self . listing . addItem ( " runtime: %s m " % meta . get ( ' runtime ' ) )
2016-11-30 21:02:38 +03:00
if meta . get ( ' thumbnail ' ) :
2016-12-09 21:11:23 +03:00
self . logoimg . setImage ( meta . get ( ' thumbnail ' ) )
2016-11-30 21:02:38 +03:00
self . plot . setText ( meta . get ( ' plot ' ) )
2016-12-09 21:11:23 +03:00
2016-11-26 12:06:04 +03:00
def log ( msg ) :
try :
2016-12-09 21:11:23 +03:00
xbmc . log ( " ### [ %s ]: %s " % ( __plugin__ , msg , ) , level = xbmc . LOGNOTICE )
2016-11-26 12:06:04 +03:00
except UnicodeEncodeError :
2016-12-09 21:11:23 +03:00
xbmc . log ( " ### [ %s ]: %s " % ( __plugin__ , msg . encode ( " utf-8 " , " ignore " ) , ) , level = xbmc . LOGNOTICE )
2016-11-26 12:06:04 +03:00
except :
2016-12-09 21:11:23 +03:00
xbmc . log ( " ### [ %s ]: %s " % ( __plugin__ , ' ERROR LOG ' , ) , level = xbmc . LOGNOTICE )
2016-11-26 12:06:04 +03:00
2016-12-09 21:11:23 +03:00
def titleMake ( seeds , leechers , size , title ) :
# AARRGGBB
2016-11-26 12:06:04 +03:00
clGreen = ' [COLOR FF008000] %s [/COLOR] '
clDodgerblue = ' [COLOR FF1E90FF] %s [/COLOR] '
2016-11-26 13:14:33 +03:00
clDimgray = ' [COLOR FF999999] %s [/COLOR] '
2016-11-26 12:06:04 +03:00
clWhite = ' [COLOR FFFFFFFF] %s [/COLOR] '
clAliceblue = ' [COLOR FFF0F8FF] %s [/COLOR] '
clRed = ' [COLOR FFFF0000] %s [/COLOR] '
title = title . replace ( ' 720p ' , ' [B]720p[/B] ' ) . replace ( ' 1080p ' , ' [B]1080p[/B] ' )
title = clWhite % title
2016-11-26 13:14:33 +03:00
second = ' [I]( %s ) [S/L: %d / %d ] [/I] ' % ( size , seeds , leechers )
title + = ' \r \n ' + clDimgray % second
2016-11-26 12:06:04 +03:00
return title
2016-12-10 01:01:06 +03:00
def dlstat_titleMake ( title , second ) :
# AARRGGBB
clDimgray = ' [COLOR FF999999] %s [/COLOR] '
clWhite = ' [COLOR FFFFFFFF] %s [/COLOR] '
title = clWhite % title
title + = ' \r \n ' + clDimgray % second
return title
2016-11-26 19:05:04 +03:00
2016-12-15 00:24:21 +03:00
def main ( params = None ) :
dialog = SearchWindow ( params )
2016-11-26 12:06:04 +03:00
dialog . doModal ( )
2016-12-09 21:11:23 +03:00
del dialog # You need to delete your instance when it is no longer needed
# because underlying xbmcgui classes are not grabage-collected.
2016-11-29 23:29:11 +03:00
if __name__ == ' __main__ ' :
try :
main ( )
except Exception , e :
import xbmc
import traceback
map ( xbmc . log , traceback . format_exc ( ) . split ( " \n " ) )
2016-11-30 15:59:47 +03:00
raise