#NEWLINE# def get_movie( self , imdb , title , year ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# query = ( self . search_link % urllib . quote_plus ( title ) ) #NEWLINE# query = urlparse . urljoin ( self . base_link , query ) #NEWLINE# result = client . source ( query , headers = self . headers ) #NEWLINE# result = client . parseDOM ( result , 'li' , attrs = { #NEWLINE# #INDENT# 'class' : '[^"]*movie[^"]*' , #NEWLINE# #UNINDENT# } ) #NEWLINE# title = cleantitle . movie ( title ) #NEWLINE# years = [ ( '%s' % str ( year ) ) , ( '%s' % str ( ( int ( year ) + 1 ) ) ) , ( '%s' % str ( ( int ( year ) - 1 ) ) ) ] #NEWLINE# result = [ ( client . parseDOM ( i , 'a' , ret = 'href' ) , client . parseDOM ( i , 'h4' ) ) for i in result ] #NEWLINE# result = [ ( i [ 0 ] [ 0 ] , i [ 1 ] [ 0 ] ) for i in result if ( ( len ( i [ 0 ] ) > 0 ) and ( len ( i [ 1 ] ) > 0 ) ) ] #NEWLINE# result = [ i for i in result if ( title == cleantitle . movie ( i [ 1 ] ) ) ] #NEWLINE# result = [ i [ 0 ] for i in result ] [ 0 ] #NEWLINE# url = re . compile ( 'movie-detail/(.+?)/' ) . findall ( result ) [ 0 ] #NEWLINE# url = ( self . detail_link % url ) #NEWLINE# url = url . encode ( 'utf-8' ) #NEWLINE# if ( len ( result ) > 1 ) : #NEWLINE# #INDENT# y = client . source ( urlparse . urljoin ( self . base_link , url ) ) #NEWLINE# y = re . compile ( '(\\d{4})-\\d{2}-\\d{2}' ) . findall ( y ) [ ( - 1 ) ] #NEWLINE# if ( not ( str ( y ) in years ) ) : #NEWLINE# #INDENT# raise Exception ( ) #NEWLINE# #UNINDENT# #UNINDENT# return url #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return