<s> '''<STR_LIT>''' <EOL> import urllib2 , os , time <EOL> import xbmc , xbmcgui , xbmcaddon , xbmcplugin <EOL> supportsite = '<STR_LIT>' <EOL> def openDialog ( image , audio ) : <EOL> audio = audio <EOL> print '<STR_LIT>' + audio <EOL> path = xbmc . translatePath ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> popimage = os . path . join ( path , '<STR_LIT>' ) <EOL> downloadFile ( image , popimage ) <EOL> musicsound = os . path . join ( path , '<STR_LIT>' ) <EOL> downloadFile ( audio , musicsound ) <EOL> if xbmc . getCondVisibility ( '<STR_LIT>' ) : <EOL> if not xbmc . getCondVisibility ( '<STR_LIT>' ) : <EOL> popup = dialog ( '<STR_LIT>' , xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) , '<STR_LIT>' , close_time = <NUM_LIT:20> , logo_path = '<STR_LIT>' % xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) , ) <EOL> if xbmc . getCondVisibility ( '<STR_LIT>' ) : <EOL> popup = dialog ( '<STR_LIT>' , xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) , '<STR_LIT>' , close_time = <NUM_LIT:20> , logo_path = '<STR_LIT>' % xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) ) <EOL> else : <EOL> popup = dialog ( '<STR_LIT>' , xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) , '<STR_LIT>' , close_time = <NUM_LIT:20> , logo_path = '<STR_LIT>' % xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) ) <EOL> popup . doModal ( ) <EOL> del popup <EOL> def downloadFile ( url , dest , silent = False , cookie = None ) : <EOL> try : <EOL> import urllib2 <EOL> file_name = url . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> print "<STR_LIT>" % ( file_name ) <EOL> if cookie : <EOL> import cookielib <EOL> cookie_file = os . path . join ( os . path . join ( xbmc . translatePath ( xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT>' ) ) , '<STR_LIT>' ) , cookie + '<STR_LIT>' ) <EOL> cj = cookielib . LWPCookieJar ( ) <EOL> if os . path . exists ( cookie_file ) : <EOL> try : cj . load ( cookie_file , True ) <EOL> except : cj . save ( cookie_file , True ) <EOL> else : cj . save ( cookie_file , True ) <EOL> opener = urllib2 . build_opener ( urllib2 . HTTPCookieProcessor ( cj ) ) <EOL> else : <EOL> opener = urllib2 . build_opener ( ) <EOL> opener . addheaders = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> u = opener . open ( url ) <EOL> f = open ( dest , '<STR_LIT:wb>' ) <EOL> meta = u . info ( ) <EOL> if meta . getheaders ( "<STR_LIT>" ) : <EOL> file_size = int ( meta . getheaders ( "<STR_LIT>" ) [ <NUM_LIT:0> ] ) <EOL> else : file_size = '<STR_LIT>' <EOL> file_size_dl = <NUM_LIT:0> <EOL> block_sz = <NUM_LIT> <EOL> while True : <EOL> buffer = u . read ( block_sz ) <EOL> if not buffer : break <EOL> file_size_dl += len ( buffer ) <EOL> f . write ( buffer ) <EOL> print "<STR_LIT>" % ( file_name , file_size ) <EOL> f . close ( ) <EOL> return True <EOL> except Exception : <EOL> print '<STR_LIT>' + url . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> if not silent : <EOL> dialog = xbmcgui . Dialog ( ) <EOL> dialog . ok ( "<STR_LIT>" , "<STR_LIT>" + supportsite , "<STR_LIT>" ) <EOL> return False <EOL> class dialog ( xbmcgui . WindowXMLDialog ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . shut = kwargs [ '<STR_LIT>' ] <EOL> xbmc . executebuiltin ( "<STR_LIT>" ) <EOL> xbmc . executebuiltin ( "<STR_LIT>" ) <EOL> def onInit ( self ) : <EOL> xbmc . Player ( ) . play ( '<STR_LIT>' % xbmcaddon . Addon ( ) . getAddonInfo ( '<STR_LIT:path>' ) ) <EOL> while self . shut > <NUM_LIT:0> : <EOL> xbmc . sleep ( <NUM_LIT:1000> ) <EOL> self . shut -= <NUM_LIT:1> <EOL> xbmc . Player ( ) . stop ( ) <EOL> self . _close_dialog ( ) <EOL> def onFocus ( self , controlID ) : pass <EOL> def onClick ( self , controlID ) : <EOL> if controlID == <NUM_LIT:12> or controlID == <NUM_LIT:7> : <EOL> xbmc . Player ( ) . stop ( ) <EOL> self . _close_dialog ( ) <EOL> def onAction ( self , action ) : <EOL> if action in [ <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ] or action . getButtonCode ( ) in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> xbmc . Player ( ) . stop ( ) <EOL> self . _close_dialog ( ) <EOL> def _close_dialog ( self ) : <EOL> path = xbmc . translatePath ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> popimage = os . path . join ( path , '<STR_LIT>' ) <EOL> musicsound = os . path . join ( path , '<STR_LIT>' ) <EOL> xbmc . executebuiltin ( "<STR_LIT>" ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . close ( ) <EOL> os . remove ( popimage ) <EOL> os . remove ( musicsound ) </s>
