<s> '''<STR_LIT>''' <EOL> import re , urllib , urlparse , base64 <EOL> from resources . lib . libraries import cleantitle <EOL> from resources . lib . libraries import client <EOL> from resources . lib import resolvers <EOL> class source : <EOL> def __init__ ( self ) : <EOL> self . base_link = '<STR_LIT>' <EOL> self . moviesearch_link = '<STR_LIT>' <EOL> self . tvsearch_link = '<STR_LIT>' <EOL> def get_movie ( self , imdb , title , year ) : <EOL> try : <EOL> query = self . moviesearch_link % urllib . quote_plus ( title ) <EOL> query = urlparse . urljoin ( self . base_link , query ) <EOL> result = client . source ( query ) <EOL> result = result . decode ( '<STR_LIT>' ) . encode ( '<STR_LIT:utf-8>' ) <EOL> result = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> title = '<STR_LIT>' + cleantitle . movie ( title ) <EOL> years = [ '<STR_LIT>' % str ( year ) , '<STR_LIT>' % str ( int ( year ) + <NUM_LIT:1> ) , '<STR_LIT>' % str ( int ( year ) - <NUM_LIT:1> ) ] <EOL> result = [ ( client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT>' ) [ <NUM_LIT:0> ] , client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT:title>' ) [ <NUM_LIT:0> ] ) for i in result ] <EOL> result = [ i for i in result if '<STR_LIT>' in i [ <NUM_LIT:0> ] ] <EOL> result = [ i for i in result if title == cleantitle . movie ( i [ <NUM_LIT:1> ] ) ] <EOL> result = [ i [ <NUM_LIT:0> ] for i in result if any ( x in i [ <NUM_LIT:1> ] for x in years ) ] [ <NUM_LIT:0> ] <EOL> result = result . split ( '<STR_LIT>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> try : url = re . compile ( '<STR_LIT>' ) . findall ( result ) [ <NUM_LIT:0> ] <EOL> except : url = result <EOL> url = client . replaceHTMLCodes ( url ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> return url <EOL> except : <EOL> return <EOL> def get_show ( self , imdb , tvdb , tvshowtitle , year ) : <EOL> try : <EOL> query = self . tvsearch_link % urllib . quote_plus ( tvshowtitle ) <EOL> query = urlparse . urljoin ( self . base_link , query ) <EOL> result = client . source ( query ) <EOL> result = result . decode ( '<STR_LIT>' ) . encode ( '<STR_LIT:utf-8>' ) <EOL> result = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> tvshowtitle = '<STR_LIT>' + cleantitle . tv ( tvshowtitle ) <EOL> years = [ '<STR_LIT>' % str ( year ) , '<STR_LIT>' % str ( int ( year ) + <NUM_LIT:1> ) , '<STR_LIT>' % str ( int ( year ) - <NUM_LIT:1> ) ] <EOL> result = [ ( client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT>' ) [ <NUM_LIT:0> ] , client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT:title>' ) [ <NUM_LIT:0> ] ) for i in result ] <EOL> result = [ i for i in result if '<STR_LIT>' in i [ <NUM_LIT:0> ] ] <EOL> result = [ i for i in result if tvshowtitle == cleantitle . tv ( i [ <NUM_LIT:1> ] ) ] <EOL> result = [ i [ <NUM_LIT:0> ] for i in result if any ( x in i [ <NUM_LIT:1> ] for x in years ) ] [ <NUM_LIT:0> ] <EOL> result = result . split ( '<STR_LIT>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> try : url = re . compile ( '<STR_LIT>' ) . findall ( result ) [ <NUM_LIT:0> ] <EOL> except : url = result <EOL> url = client . replaceHTMLCodes ( url ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> return url <EOL> except : <EOL> return <EOL> def get_episode ( self , url , imdb , tvdb , title , date , season , episode ) : <EOL> if url == None : return <EOL> url = url . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> url += '<STR_LIT>' % ( int ( season ) , int ( episode ) ) <EOL> url = client . replaceHTMLCodes ( url ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> return url <EOL> def get_sources ( self , url , hosthdDict , hostDict , locDict ) : <EOL> try : <EOL> sources = [ ] <EOL> if url == None : return sources <EOL> url = urlparse . urljoin ( self . base_link , url ) <EOL> result = client . source ( url ) <EOL> result = result . decode ( '<STR_LIT>' ) . encode ( '<STR_LIT:utf-8>' ) <EOL> links = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> for i in links : <EOL> try : <EOL> url = client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT>' ) <EOL> if len ( url ) > <NUM_LIT:1> : raise Exception ( ) <EOL> url = url [ <NUM_LIT:0> ] . split ( '<STR_LIT>' , <NUM_LIT:1> ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:&>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> url = base64 . urlsafe_b64decode ( url . encode ( '<STR_LIT:utf-8>' ) ) <EOL> url = client . replaceHTMLCodes ( url ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> host = urlparse . urlparse ( url ) . netloc <EOL> host = host . replace ( '<STR_LIT>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> host = host . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> host = host . lower ( ) <EOL> if not host in hostDict : raise Exception ( ) <EOL> host = client . replaceHTMLCodes ( host ) <EOL> host = host . encode ( '<STR_LIT:utf-8>' ) <EOL> quality = client . parseDOM ( i , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> if any ( x in [ '<STR_LIT>' , '<STR_LIT>' ] for x in quality ) : quality = '<STR_LIT>' <EOL> else : quality = '<STR_LIT>' <EOL> quality = quality . encode ( '<STR_LIT:utf-8>' ) <EOL> sources . append ( { '<STR_LIT:source>' : host , '<STR_LIT>' : quality , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : url } ) <EOL> except : <EOL> pass <EOL> return sources <EOL> except : <EOL> return sources <EOL> def resolve ( self , url ) : <EOL> try : <EOL> url = resolvers . request ( url ) <EOL> return url <EOL> except : <EOL> return </s>
