home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / xbmc-9.11.exe / scripts / AppleMovieTrailers / resources / lib / showtimes.py < prev    next >
Encoding:
Python Source  |  2008-08-06  |  3.0 KB  |  83 lines

  1. """
  2. Showtimes module
  3.  
  4. Nuka1195
  5. """
  6.  
  7. import sys
  8. import xbmcgui
  9.  
  10. import showtimesScraper
  11. ShowtimesFetcher = showtimesScraper.ShowtimesFetcher()
  12. from utilities import *
  13.  
  14. _ = sys.modules[ "__main__" ].__language__
  15. __scriptname__ = sys.modules[ "__main__" ].__scriptname__
  16. __version__ = sys.modules[ "__main__" ].__version__
  17. __svn_url__ = sys.modules[ "__main__" ].__svn_url__
  18. __svn_revision__ = sys.modules[ "__main__" ].__svn_revision__
  19.  
  20.  
  21. class GUI( xbmcgui.WindowXMLDialog ):
  22.     def __init__( self, *args, **kwargs ):
  23.         xbmcgui.WindowXMLDialog.__init__( self, *args, **kwargs )
  24.         self.title = kwargs[ "title" ]
  25.         self.location = kwargs[ "location" ]
  26.         self.doModal()
  27.  
  28.     def onInit( self ):
  29.         xbmcgui.lock()
  30.         self._show_dialog()
  31.         xbmcgui.unlock()
  32.         self._get_showtimes()
  33.  
  34.     def _show_dialog( self ):
  35.         self.getControl( 20 ).setLabel( self.title )
  36.         self.getControl( 30 ).setLabel( "%s: %s" % ( _( 603 ), self.location ), )
  37.         self.getControl( 40 ).setLabel( "%s:" % _( 602 ) )
  38.         self.getControl( 50 ).setLabel( "" )
  39.         self.getControl( 100 ).reset()
  40.         self.getControl( 100 ).addItem( _( 601 ) )
  41.  
  42.     def _get_showtimes( self ):
  43.         date, self.movie_showtimes = ShowtimesFetcher.get_showtimes( self.title, self.location )
  44.         if ( date is None ): date = _( 600 )
  45.         else: date = "%s: %s" % ( _( 602 ), date, )
  46.         self.getControl( 40 ).setLabel( date )
  47.         self._fill_list()
  48.  
  49.     def _get_selection( self, choice ):
  50.         self.getControl( 20 ).setLabel( choice )
  51.         self.getControl( 30 ).setLabel( self.movie_showtimes[ choice ][ 0 ] )
  52.         self.getControl( 40 ).setLabel( "%s:" % _( 602 ) )
  53.         self.getControl( 50 ).setLabel( self.movie_showtimes[ choice ][ 2 ] )
  54.         self.getControl( 100 ).reset()
  55.         self.getControl( 100 ).addItem( _( 601 ) )
  56.         date, self.movie_showtimes = ShowtimesFetcher.get_selection( self.movie_showtimes[ choice ][ 3 ] )
  57.         self.getControl( 40 ).setLabel( "%s: %s" % ( _( 602 ), date, ) )
  58.         self._fill_list()
  59.  
  60.     def _fill_list( self ):
  61.         self.getControl( 100 ).reset()
  62.         if ( self.movie_showtimes ):
  63.             self.theaters = self.movie_showtimes.keys()
  64.             self.theaters.sort()
  65.             for theater in self.theaters:
  66.                 list_item = xbmcgui.ListItem( theater, self.movie_showtimes[ theater ][ 1 ], self.movie_showtimes[ theater ][ 0 ], self.movie_showtimes[ theater ][ 2 ] )
  67.                 self.getControl( 100 ).addItem( list_item )
  68.         else:
  69.             self.getControl( 100 ).addItem( _( 600 ) )
  70.  
  71.     def _close_dialog( self ):
  72.         self.close()
  73.  
  74.     def onClick( self, controlId ):
  75.         self._get_selection( self.theaters[ self.getControl( controlId ).getSelectedPosition() ] )
  76.  
  77.     def onFocus( self, controlId ):
  78.         pass
  79.  
  80.     def onAction( self, action ):
  81.         if ( action in ACTION_CANCEL_DIALOG ):
  82.             self._close_dialog()
  83.