Advertisement
Guest User

Untitled

a guest
Jun 14th, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import sys, os
  2. import xbmc, xbmcgui
  3.  
  4. class Main:
  5.     def __init__( self ):
  6.         self._set_variables()
  7.         self._clear_properties()
  8.         self._parse_argv()
  9.         self._fetch_subtitle_info()
  10.  
  11.     def _set_variables( self ):
  12.         self.WINDOW = xbmcgui.Window( 12003 )
  13.  
  14.     def _clear_properties( self ):
  15.         self.WINDOW.clearProperty( "SubtitleInfo" )
  16.  
  17.     def _parse_argv( self ):
  18.         try:
  19.             params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
  20.         except:
  21.             params = {}
  22.         self.PATH = params.get( "path", "" )
  23.  
  24.     def _fetch_subtitle_info( self ):
  25.         sub_ext = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass" ]
  26.         for ext in sub_ext:
  27.             subfile = os.path.splitext( self.PATH )[0] + ext
  28.             if os.path.isfile( subfile ):
  29.                 xbmcgui.Window( 12003 ).setProperty( "SubtitleInfo", "true" )
  30.  
  31. if ( __name__ == "__main__" ):
  32.     Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement