<s> '''<STR_LIT>''' <EOL> import re , urllib , urlparse <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 . link_1 = '<STR_LIT>' <EOL> self . link_2 = '<STR_LIT>' <EOL> self . link_3 = '<STR_LIT>' <EOL> self . search_link = '<STR_LIT>' <EOL> self . show_link = '<STR_LIT>' <EOL> self . episode_link = '<STR_LIT>' <EOL> self . headers = { } <EOL> def get_movie ( self , imdb , title , year ) : <EOL> try : <EOL> query = self . search_link <EOL> post = { '<STR_LIT>' : title , '<STR_LIT>' : '<STR_LIT:1>' } <EOL> result = '<STR_LIT>' <EOL> links = [ self . link_1 , self . link_3 ] <EOL> for base_link in links : <EOL> result = client . source ( urlparse . urljoin ( base_link , query ) , post = post , headers = self . headers ) <EOL> if '<STR_LIT>' in str ( result ) : break <EOL> result = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) [ <NUM_LIT:0> ] <EOL> result = client . parseDOM ( result , '<STR_LIT>' ) <EOL> title = 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:1> ] , client . parseDOM ( i , '<STR_LIT:a>' ) [ - <NUM_LIT:1> ] ) for i in result ] <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> url = client . replaceHTMLCodes ( result ) <EOL> try : url = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ '<STR_LIT:u>' ] [ <NUM_LIT:0> ] <EOL> except : pass <EOL> url = urlparse . urlparse ( url ) . path <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 . search_link <EOL> post = { '<STR_LIT>' : tvshowtitle , '<STR_LIT>' : '<STR_LIT:2>' } <EOL> result = '<STR_LIT>' <EOL> links = [ self . link_1 , self . link_3 ] <EOL> for base_link in links : <EOL> result = client . source ( urlparse . urljoin ( base_link , query ) , post = post , headers = self . headers ) <EOL> if '<STR_LIT>' in str ( result ) : break <EOL> result = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) [ <NUM_LIT:0> ] <EOL> result = client . parseDOM ( result , '<STR_LIT>' ) <EOL> tvshowtitle = 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:1> ] , client . parseDOM ( i , '<STR_LIT:a>' ) [ - <NUM_LIT:1> ] ) for i in result ] <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> url = client . replaceHTMLCodes ( result ) <EOL> try : url = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ '<STR_LIT:u>' ] [ <NUM_LIT:0> ] <EOL> except : pass <EOL> url = urlparse . urlparse ( url ) . path <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 . rsplit ( '<STR_LIT:/>' , <NUM_LIT:1> ) [ - <NUM_LIT:1> ] <EOL> url = self . episode_link % ( url , 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> result = '<STR_LIT>' <EOL> links = [ self . link_1 , self . link_2 , self . link_3 ] <EOL> for base_link in links : <EOL> result = client . source ( urlparse . urljoin ( base_link , url ) , headers = self . headers ) <EOL> if '<STR_LIT>' in str ( result ) : break <EOL> links = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:id>' : '<STR_LIT>' } ) <EOL> for i in links : <EOL> try : <EOL> lang = re . compile ( '<STR_LIT>' ) . findall ( i ) [ <NUM_LIT:1> ] <EOL> if not '<STR_LIT>' in lang : raise Exception ( ) <EOL> host = re . compile ( '<STR_LIT>' ) . findall ( i ) [ <NUM_LIT:0> ] <EOL> host = host . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> host = host . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:3> ] <EOL> host = host . strip ( ) . lower ( ) <EOL> host = client . replaceHTMLCodes ( host ) <EOL> host = host . encode ( '<STR_LIT:utf-8>' ) <EOL> if '<STR_LIT>' in i or '<STR_LIT>' in i : quality = '<STR_LIT>' <EOL> elif '<STR_LIT>' in i and host in hosthdDict : quality = '<STR_LIT>' <EOL> else : quality = '<STR_LIT>' <EOL> if quality == '<STR_LIT>' and not host in hosthdDict : raise Exception ( ) <EOL> if quality == '<STR_LIT>' and not host in hostDict : raise Exception ( ) <EOL> if '<STR_LIT>' in i : info = '<STR_LIT>' <EOL> else : info = '<STR_LIT>' <EOL> url = re . compile ( '<STR_LIT>' ) . findall ( i ) [ <NUM_LIT:0> ] <EOL> url = client . replaceHTMLCodes ( url ) <EOL> try : url = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ '<STR_LIT:u>' ] [ <NUM_LIT:0> ] <EOL> except : pass <EOL> if url . startswith ( '<STR_LIT:http>' ) : url = urlparse . urlparse ( url ) . path <EOL> if not url . startswith ( '<STR_LIT:http>' ) : url = urlparse . urljoin ( self . base_link , url ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> sources . append ( { '<STR_LIT:source>' : host , '<STR_LIT>' : quality , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : url , '<STR_LIT:info>' : info } ) <EOL> except : <EOL> pass <EOL> return sources <EOL> except : <EOL> return sources <EOL> def resolve ( self , url ) : <EOL> try : <EOL> url = urlparse . urlparse ( url ) . path <EOL> result = '<STR_LIT>' <EOL> links = [ self . link_1 , self . link_2 , self . link_3 ] <EOL> for base_link in links : <EOL> result = client . request ( urlparse . urljoin ( base_link , url ) , headers = self . headers ) <EOL> if '<STR_LIT>' in str ( result ) : break <EOL> url = re . compile ( '<STR_LIT>' ) . findall ( result ) [ <NUM_LIT:0> ] <EOL> url = client . replaceHTMLCodes ( url ) <EOL> print ( "<STR_LIT>" , url ) <EOL> try : url = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ '<STR_LIT:u>' ] [ <NUM_LIT:0> ] <EOL> except : pass <EOL> try : url = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ '<STR_LIT:url>' ] [ <NUM_LIT:0> ] <EOL> except : pass <EOL> print ( "<STR_LIT>" , url ) <EOL> url = resolvers . request ( url ) <EOL> print ( "<STR_LIT>" , url ) <EOL> return url <EOL> except : <EOL> return </s>
