def __init__( self ):
        #
        # Search...
        #
        listitem = xbmcgui.ListItem( __language__(30009), iconImage="DefaultFolder.png" )
        xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1] ), url = '%s?action=list-search&query=&plugin_category=%s' % ( sys.argv[ 0 ], __language__(30008) ), listitem=listitem, isFolder=True)
		
        #
        # Previous search queries...
        #
        try :
            saved_queries = eval( __settings__.getSetting( "saved_queries" ) )
        except :
            saved_queries = []
        
        for query in saved_queries :
            listitem = xbmcgui.ListItem( query, iconImage="DefaultFolder.png" )
            xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), 
                                        url = '%s?action=list-search&query=%s&plugin_category=%s' % ( sys.argv[ 0 ], urllib.quote( query ), __language__(30008) ), 
                                        listitem=listitem, 
                                        isFolder=True)		

        # Label (top-right)...
        xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=( "%s" % __language__(30008) ) )

        # Disable sorting...
        xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
		
        # End of list...
        xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
	def __init__( self ) :
		# Constants
		self.DEBUG         = False
		self.IMAGES_PATH   = xbmc.translatePath( os.path.join( os.getcwd(), 'resources', 'images' ) )
		self.ENTRY_LIST_RE = re.compile( "(\d+) to (\d+) of (\d+)" )
		
		# Parse parameters...
		params = dict(part.split('=') for part in sys.argv[ 2 ][ 1: ].split('&'))
		self.plugin_category = params[ "plugin_category" ] 
		self.current_page    = int ( params.get( "page", "1" ) )
		self.query           = urllib.unquote( params[ "query" ] )

		# Settings
		self.video_quality   = __settings__.getSetting ("video_quality")

		# Ask for query if none was passed...
		if self.query == "" :
			# ask for the query string (keyboard)...			
			keyboard = xbmc.Keyboard( "", "", False )
			keyboard.doModal()
			if ( keyboard.isConfirmed() ):
				self.query = unicode( keyboard.getText(), "utf-8" )
			else :
				xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=False )
				return

		#
		# Get the videos...
		#
		self.getVideos()
	def __init__( self ) :
		# Parse parameters...
		params = dict(part.split('=') for part in sys.argv[ 2 ][ 1: ].split('&'))
		self.plugin_category  = params[ "plugin_category" ] 
		self.current_page     = int ( params.get( "page", "1" ) )
		self.entries_par_page = 10

		# Settings
		self.video_quality   = __settings__.getSetting ("video_quality")

		#
		# Get the videos...
		#
		self.getVideos()
	def __init__( self ) :
		#
		# Constants
		#
		self.DEBUG                     = False
		self.PLAYER_URL_RE             = re.compile( ".*/player/(\d+).html" )
		self.EPISODE_BONUSROUND_URL_RE = re.compile( ".*/episode/bonusround/.*" )
		self.BONUSROUND_PHP_URL_RE     = re.compile( ".*/bonusround.php\?ep=(\d+)" )
		self.VIDEO_URL_RE              = re.compile( ".*/video/(.+)?/(\d+)" )
		self.GAMETRAILERS_TV_PLAYER_RE = re.compile( ".*/gametrailerstv_player.php?.*" )
		self.EPISODE_GAMETRAILER_TV_RE = re.compile( ".*/episode/gametrailers-tv/.*" )
		self.USER_MOVIES_URL_RE        = re.compile( ".*/usermovies/(\d+).html" )
		self.MOSES_MOVIES_THUMBS       = re.compile( ".*/moses/moviesthumbs/(\d+)-.*" )
		self.VIDEOS_URL_RE             = re.compile( ".*/videos/.*" )
		self.REVIEWS_URL_RE            = re.compile( ".*/reviews/.*")
		self.FULL_EPISODES_URL_RE      = re.compile( ".*/full-episodes/.*")
		
		#
		# Parse parameters...
		#
		params = dict(part.split('=') for part in sys.argv[ 2 ][ 1: ].split('&'))
		
		self.video_page_url = urllib.unquote_plus( params[ "video_page_url" ] ) 

		# Settings
		self.video_players = { "0" : xbmc.PLAYER_CORE_AUTO,
							   "1" : xbmc.PLAYER_CORE_DVDPLAYER,
							   "2" : xbmc.PLAYER_CORE_MPLAYER }
		self.video_player  = __settings__.getSetting("video_player")
		
		self.video_format  = __settings__.getSetting("video_format")
		self.video_quality = __settings__.getSetting("video_quality")

		#
		# Play video...
		#
		self.playVideo()
	def __init__( self ) :
		# Constants
		self.DEBUG         = False
		self.IMAGES_PATH   = xbmc.translatePath( os.path.join( os.getcwd(), 'resources', 'images' ) )
		self.ENTRY_LIST_RE = re.compile( "(\d+) to (\d+) of \d+" )
		
		# Parse parameters...
		params = dict(part.split('=') for part in sys.argv[ 2 ][ 1: ].split('&'))
		self.plugin_category =  unicode( params[ "plugin_category" ], "utf-8")
		self.current_page    =      int( params.get( "page", "1" ) )
		
		# Settings
		self.video_quality   = __settings__.getSetting ("video_quality")		
		
		#
		# Get the videos...
		#
		self.getVideos()
	def getVideos( self ) :
		# 
		# Get HTML page...
		#
		url           = "http://www.gametrailers.com/feeds/search/child/c9c01382-1f7c-4a3a-b68f-2e5ecc67fdd3/?keywords=%s&tabName=videos&platforms=&currentPage=%d" % ( urllib.quote( self.query ), self.current_page )
		htmlData      = HTTPCommunicator().get( url )

		# Parse response...
		beautifulSoup = BeautifulSoup( htmlData )
		
		#
		# Parse movie entries...
		#
		lis = beautifulSoup.findAll ( "div", { "class" : "video_information" } )
		for li in lis :
			div_holder = li.find ( "div", { "class" : "holder" } )
			
			# Title
			h3    = div_holder.find ( "h3" )
			h4    = div_holder.find ( "h4" )
			if (h3.a.string != None) :
				title = "%s - %s" % ( h3.a.string.strip(), h4.a.string.strip() )
			else :
				title = h4.a.string.strip()
			
			# Thumbnail
			a_thumbnail      = div_holder.find ( "a", { "class" : "thumbnail" } )
			a_thumbnail_imgs = a_thumbnail.findAll ( "img" )
			thumbnail_url    = a_thumbnail_imgs[ -1 ] [ "src" ]
			
			# Video page...
			video_page_url = a_thumbnail[ "href" ]
			
			# Add to list...
			listitem        = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail_url )
			listitem.setInfo( "video", { "Title" : title, "Studio" : "GameTrailers" } )
			plugin_play_url = '%s?action=play&video_page_url=%s' % ( sys.argv[ 0 ], urllib.quote_plus( video_page_url ) )
			xbmcplugin.addDirectoryItem( handle=int(sys.argv[ 1 ]), url=plugin_play_url, listitem=listitem, isFolder=False)

		# Next page entry...
		listitem = xbmcgui.ListItem (__language__(30503), iconImage = "DefaultFolder.png", thumbnailImage = os.path.join(self.IMAGES_PATH, 'next-page.png'))
		xbmcplugin.addDirectoryItem( handle = int(sys.argv[1]), url = "%s?action=list-search&query=%s&plugin_category=%s&page=%i" % ( sys.argv[0], self.query, self.plugin_category, self.current_page + 1 ), listitem = listitem, isFolder = True)

		# Disable sorting...
		xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
		
		# End of directory...
		xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
		
		#
		# Save the query for future use...
		#
		#
		try :
			saved_queries = eval( __settings__.getSetting( "saved_queries" ) )
		except :
			saved_queries = []
		
		# Add the entry to the list...
		try :
			# ... if not already in the list...
			saved_queries.index( self.query )
		except :
			saved_queries.append( self.query )
			
			# Sort the list...
			saved_queries.sort()
			
			# Save queries...
			__settings__.setSetting( "saved_queries", repr( saved_queries ))