<s> '''<STR_LIT>''' <EOL> import re , urllib , urlparse , json <EOL> from resources . lib . libraries import cleantitle <EOL> from resources . lib . libraries import client2 <EOL> from resources . lib . libraries import client <EOL> from resources . lib . libraries import control <EOL> from resources . lib import resolvers <EOL> class source : <EOL> def __init__ ( self ) : <EOL> self . base_link = '<STR_LIT>' <EOL> self . search_link = '<STR_LIT>' <EOL> def get_movie ( self , imdb , title , year ) : <EOL> try : <EOL> query = self . search_link % urllib . quote ( title ) <EOL> query = urlparse . urljoin ( self . base_link , query ) <EOL> result = client2 . http_get ( query ) <EOL> title = cleantitle . movie ( title ) <EOL> years = [ '<STR_LIT:%s>' % str ( year ) , '<STR_LIT:%s>' % str ( int ( year ) + <NUM_LIT:1> ) , '<STR_LIT:%s>' % str ( int ( year ) - <NUM_LIT:1> ) ] <EOL> r = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> r = [ ( client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT>' ) , client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT:title>' ) ) for i in r ] <EOL> r = [ ( i [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] [ - <NUM_LIT:1> ] ) for i in r if len ( i [ <NUM_LIT:0> ] ) > <NUM_LIT:0> and len ( i [ <NUM_LIT:1> ] ) > <NUM_LIT:0> ] <EOL> r = [ ( re . sub ( '<STR_LIT>' , '<STR_LIT>' , i [ <NUM_LIT:0> ] ) , i [ <NUM_LIT:1> ] ) for i in r ] <EOL> r = [ ( '<STR_LIT:/>' . join ( i [ <NUM_LIT:0> ] . split ( '<STR_LIT:/>' ) [ : <NUM_LIT:2> ] ) , i [ <NUM_LIT:1> ] ) for i in r ] <EOL> r = [ x for y , x in enumerate ( r ) if x not in r [ : y ] ] <EOL> r = [ i for i in r if title == cleantitle . movie ( i [ <NUM_LIT:1> ] ) ] <EOL> u = [ i [ <NUM_LIT:0> ] for i in r ] [ <NUM_LIT:0> ] <EOL> url = urlparse . urljoin ( self . base_link , u ) <EOL> url = urlparse . urlparse ( url ) . path <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> url = '<STR_LIT>' % ( tvshowtitle , year ) <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> try : <EOL> tvshowtitle , year = re . compile ( '<STR_LIT>' ) . findall ( url ) [ <NUM_LIT:0> ] <EOL> query = self . search_link % urllib . quote ( tvshowtitle ) <EOL> query = urlparse . urljoin ( self . base_link , query ) <EOL> result = client . source ( query ) <EOL> tvshowtitle = cleantitle . tv ( tvshowtitle ) <EOL> season = '<STR_LIT>' % int ( season ) <EOL> episode = '<STR_LIT>' % int ( episode ) <EOL> years = [ '<STR_LIT:%s>' % str ( year ) , '<STR_LIT:%s>' % str ( int ( year ) + <NUM_LIT:1> ) , '<STR_LIT:%s>' % str ( int ( year ) - <NUM_LIT:1> ) ] <EOL> result = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> result = [ ( client . parseDOM ( i , '<STR_LIT:a>' , ret = '<STR_LIT>' ) , client . parseDOM ( i , '<STR_LIT>' ) , re . compile ( '<STR_LIT>' ) . findall ( i ) ) for i in result ] <EOL> result = [ ( i [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , i [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ) for i in result if len ( i [ <NUM_LIT:0> ] ) > <NUM_LIT:0> and len ( i [ <NUM_LIT:1> ] ) > <NUM_LIT:0> and len ( i [ <NUM_LIT:2> ] ) > <NUM_LIT:0> ] <EOL> result = [ ( i [ <NUM_LIT:0> ] , re . compile ( '<STR_LIT>' ) . findall ( i [ <NUM_LIT:1> ] ) , i [ <NUM_LIT:2> ] ) for i in result ] <EOL> result = [ ( i [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , i [ <NUM_LIT:2> ] ) for i in result if len ( i [ <NUM_LIT:1> ] ) > <NUM_LIT:0> ] <EOL> result = [ i for i in result if tvshowtitle == cleantitle . tv ( i [ <NUM_LIT:1> ] ) ] <EOL> result = [ i for i in result if season == i [ <NUM_LIT:2> ] ] <EOL> result = [ ( i [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] , str ( int ( i [ <NUM_LIT:3> ] ) - int ( i [ <NUM_LIT:2> ] ) + <NUM_LIT:1> ) ) for i in result ] <EOL> result = [ i [ <NUM_LIT:0> ] for i in result if any ( x in i [ <NUM_LIT:2> ] for x in years ) ] [ <NUM_LIT:0> ] <EOL> result += '<STR_LIT>' % ( int ( season ) , int ( episode ) ) <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_sources ( self , url , hosthdDict , hostDict , locDict ) : <EOL> sources = [ ] <EOL> try : <EOL> r = urlparse . urljoin ( self . base_link , url ) <EOL> result = client2 . http_get ( r ) <EOL> r = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) [ <NUM_LIT:0> ] <EOL> r = re . compile ( '<STR_LIT>' ) . findall ( r ) <EOL> if len ( r ) > <NUM_LIT:0> : <EOL> t = urlparse . urljoin ( self . base_link , r [ <NUM_LIT:0> ] ) <EOL> r2 = client2 . http_get ( t ) <EOL> r3 = re . compile ( '<STR_LIT>' ) . findall ( r2 ) <EOL> for i in r3 : <EOL> try : <EOL> sources . append ( { '<STR_LIT:source>' : '<STR_LIT>' , '<STR_LIT>' : client . googletag ( i ) [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : i } ) <EOL> except : <EOL> pass <EOL> r4 = client . parseDOM ( r2 , '<STR_LIT:a>' , ret = '<STR_LIT>' ) <EOL> for i in r4 : <EOL> try : <EOL> url = resolvers . request ( i ) <EOL> sources . append ( { '<STR_LIT:source>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<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> if '<STR_LIT>' in url : url = url . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : url = url . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return url <EOL> except : <EOL> pass </s>
