<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 . libraries import cache <EOL> from resources . lib import resolvers <EOL> class source : <EOL> def __init__ ( self ) : <EOL> self . base_link = '<STR_LIT>' <EOL> def dizibox_shows ( self ) : <EOL> try : <EOL> result = client . source ( self . base_link ) <EOL> result = client . parseDOM ( result , '<STR_LIT:input>' , { '<STR_LIT:id>' : '<STR_LIT>' } ) [ <NUM_LIT:0> ] <EOL> result = client . parseDOM ( result , '<STR_LIT>' ) <EOL> result = zip ( client . parseDOM ( result , '<STR_LIT:a>' , ret = '<STR_LIT>' ) , client . parseDOM ( result , '<STR_LIT:a>' ) ) <EOL> result = [ ( re . sub ( '<STR_LIT>' , '<STR_LIT:/>' , i [ <NUM_LIT:0> ] ) , cleantitle . tv ( i [ <NUM_LIT:1> ] ) ) for i in result ] <EOL> return result <EOL> except : <EOL> return <EOL> def get_show ( self , imdb , tvdb , tvshowtitle , year ) : <EOL> try : <EOL> result = cache . get ( self . dizibox_shows , <NUM_LIT> ) <EOL> tvshowtitle = cleantitle . tv ( tvshowtitle ) <EOL> result = [ i [ <NUM_LIT:0> ] for i in result if tvshowtitle == i [ <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> try : <EOL> if url == None : return <EOL> url = urlparse . urljoin ( self . base_link , url ) <EOL> season , episode = '<STR_LIT>' % int ( season ) , '<STR_LIT>' % int ( episode ) <EOL> result = client . source ( url ) <EOL> if not season == '<STR_LIT:1>' : <EOL> url = client . parseDOM ( result , '<STR_LIT:a>' , ret = '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> url = [ i for i in url if '<STR_LIT>' % season in i ] [ <NUM_LIT:0> ] <EOL> result = client . source ( url ) <EOL> result = client . parseDOM ( result , '<STR_LIT:a>' , ret = '<STR_LIT>' ) <EOL> result = [ i for i in result if '<STR_LIT>' % ( season , episode ) in i ] [ <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_sources ( self , url , hosthdDict , hostDict , locDict ) : <EOL> try : <EOL> sources = [ ] <EOL> if url == None : return sources <EOL> sources_url = urlparse . urljoin ( self . base_link , url ) <EOL> result = client . source ( sources_url , close = False ) <EOL> result = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , result ) <EOL> result = re . compile ( '<STR_LIT>' , re . DOTALL ) . findall ( result ) <EOL> result = [ ( client . parseDOM ( i , '<STR_LIT>' , ret = '<STR_LIT>' ) , client . parseDOM ( i , '<STR_LIT>' , ret = '<STR_LIT:value>' ) , client . parseDOM ( i , '<STR_LIT>' ) ) for i in result ] <EOL> result = [ i [ <NUM_LIT:0> ] + i [ <NUM_LIT:1> ] for i in result if len ( i [ <NUM_LIT:2> ] ) > <NUM_LIT:0> and i [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] == '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> url = urlparse . urljoin ( self . base_link , result ) <EOL> result = client . source ( url , close = False ) <EOL> url = client . parseDOM ( result , '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) [ <NUM_LIT:0> ] <EOL> url = client . parseDOM ( url , '<STR_LIT>' , ret = '<STR_LIT:src>' ) [ <NUM_LIT:0> ] <EOL> url = client . replaceHTMLCodes ( url ) <EOL> result = client . source ( url , close = False ) <EOL> try : <EOL> r = re . compile ( '<STR_LIT>' ) . findall ( result ) <EOL> if r == [ ] : raise Exception ( ) <EOL> r = [ ( i [ <NUM_LIT:0> ] . replace ( '<STR_LIT>' , '<STR_LIT:/>' ) . replace ( '<STR_LIT>' , '<STR_LIT:&>' ) . decode ( '<STR_LIT>' ) , int ( i [ <NUM_LIT:1> ] ) ) for i in r ] <EOL> u = [ ( '<STR_LIT>' % ( i [ <NUM_LIT:0> ] , urllib . quote_plus ( client . agent ( ) ) , urllib . quote_plus ( sources_url ) ) , i [ <NUM_LIT:1> ] , '<STR_LIT>' ) for i in r if not '<STR_LIT>' in i [ <NUM_LIT:0> ] ] <EOL> u += [ ( i [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] , '<STR_LIT>' ) for i in r if '<STR_LIT>' in i [ <NUM_LIT:0> ] ] <EOL> try : sources . append ( { '<STR_LIT:source>' : [ i [ <NUM_LIT:2> ] for i in u if i [ <NUM_LIT:1> ] >= <NUM_LIT> ] [ <NUM_LIT:0> ] , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : [ i [ <NUM_LIT:0> ] for i in u if i [ <NUM_LIT:1> ] >= <NUM_LIT> ] [ <NUM_LIT:0> ] } ) <EOL> except : pass <EOL> try : sources . append ( { '<STR_LIT:source>' : [ i [ <NUM_LIT:2> ] for i in u if <NUM_LIT> <= i [ <NUM_LIT:1> ] < <NUM_LIT> ] [ <NUM_LIT:0> ] , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : [ i [ <NUM_LIT:0> ] for i in u if <NUM_LIT> <= i [ <NUM_LIT:1> ] < <NUM_LIT> ] [ <NUM_LIT:0> ] } ) <EOL> except : pass <EOL> try : sources . append ( { '<STR_LIT:source>' : [ i [ <NUM_LIT:2> ] for i in u if i [ <NUM_LIT:1> ] < <NUM_LIT> ] [ <NUM_LIT:0> ] , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : [ i [ <NUM_LIT:0> ] for i in u if i [ <NUM_LIT:1> ] < <NUM_LIT> ] [ <NUM_LIT:0> ] } ) <EOL> except : pass <EOL> return sources <EOL> except : <EOL> pass <EOL> try : <EOL> if '<STR_LIT>' in url : url = re . compile ( '<STR_LIT>' ) . findall ( result ) [ <NUM_LIT:0> ] <EOL> host = urlparse . urlparse ( url ) . netloc <EOL> host = host . replace ( '<STR_LIT>' , '<STR_LIT>' ) . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] . lower ( ) <EOL> strm = resolvers . request ( url ) <EOL> if strm == url or strm == None : raise Exception ( ) <EOL> if type ( strm ) == list : <EOL> for i in strm : sources . append ( { '<STR_LIT:source>' : host , '<STR_LIT>' : i [ '<STR_LIT>' ] , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : i [ '<STR_LIT:url>' ] } ) <EOL> else : <EOL> sources . append ( { '<STR_LIT:source>' : host , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : strm } ) <EOL> return sources <EOL> except : <EOL> pass <EOL> except : <EOL> return sources <EOL> def resolve ( self , url ) : <EOL> try : <EOL> if not '<STR_LIT>' in url : return url <EOL> if url . startswith ( '<STR_LIT>' ) : return url <EOL> url = client . request ( url , output = '<STR_LIT>' ) <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> return </s>
