<s> '''<STR_LIT>''' <EOL> import os , re , urllib , zipfile , StringIO , datetime , base64 <EOL> try : <EOL> from sqlite3 import dbapi2 as database <EOL> except : <EOL> from pysqlite2 import dbapi2 as database <EOL> from resources . lib . libraries import control <EOL> from resources . lib . libraries import cleantitle <EOL> from resources . lib . libraries import client <EOL> class source : <EOL> def __init__ ( self ) : <EOL> self . data_link = '<STR_LIT>' <EOL> def get_movie ( self , imdb , title , year ) : <EOL> try : <EOL> url = '<STR_LIT>' % ( title , year ) <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 = tvshowtitle <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 = '<STR_LIT>' % ( url , int ( season ) , int ( episode ) ) <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> return <EOL> try : <EOL> sources = [ ] <EOL> if url == None : return sources <EOL> data = os . path . join ( control . dataPath , '<STR_LIT>' ) <EOL> download = True <EOL> try : download = abs ( datetime . datetime . fromtimestamp ( os . path . getmtime ( data ) ) - ( datetime . datetime . now ( ) ) ) > datetime . timedelta ( days = <NUM_LIT:7> ) <EOL> except : pass <EOL> if download == True : <EOL> result = client . source ( base64 . b64decode ( self . data_link ) ) <EOL> zip = zipfile . ZipFile ( StringIO . StringIO ( result ) ) <EOL> zip . extractall ( control . dataPath ) <EOL> zip . close ( ) <EOL> dbcon = database . connect ( data ) <EOL> dbcur = dbcon . cursor ( ) <EOL> content = re . compile ( '<STR_LIT>' ) . findall ( url ) <EOL> if len ( content ) == <NUM_LIT:0> : <EOL> title , year = re . compile ( '<STR_LIT>' ) . findall ( url ) [ <NUM_LIT:0> ] <EOL> title = cleantitle . movie ( title ) <EOL> dbcur . execute ( "<STR_LIT>" % year ) <EOL> result = dbcur . fetchone ( ) <EOL> result = eval ( result [ <NUM_LIT:1> ] . encode ( '<STR_LIT:utf-8>' ) ) <EOL> links = [ ( i , re . sub ( '<STR_LIT>' , '<STR_LIT>' , i ) ) for i in result ] <EOL> links = [ i [ <NUM_LIT:0> ] for i in links if title == cleantitle . movie ( os . path . basename ( i [ <NUM_LIT:1> ] ) ) ] <EOL> for i in links : <EOL> try : <EOL> url = client . replaceHTMLCodes ( i ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> if not url . endswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : raise Exception ( ) <EOL> fmt = re . sub ( '<STR_LIT>' , '<STR_LIT>' , i ) <EOL> fmt = re . split ( '<STR_LIT>' , fmt ) <EOL> fmt = [ x . lower ( ) for x in fmt ] <EOL> if '<STR_LIT>' in fmt : quality = '<STR_LIT>' <EOL> elif '<STR_LIT>' in fmt or '<STR_LIT>' in fmt : quality = '<STR_LIT>' <EOL> else : quality = '<STR_LIT>' <EOL> if '<STR_LIT>' in fmt : info = '<STR_LIT>' <EOL> else : info = '<STR_LIT>' <EOL> control . log ( '<STR_LIT>' ) <EOL> sources . append ( { '<STR_LIT:source>' : '<STR_LIT>' , '<STR_LIT>' : quality , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:url>' : url , '<STR_LIT:info>' : info } ) <EOL> except : <EOL> pass <EOL> else : <EOL> tvshowtitle , season , episode = re . compile ( '<STR_LIT>' ) . findall ( url ) [ <NUM_LIT:0> ] <EOL> tvshowtitle = cleantitle . tv ( tvshowtitle ) <EOL> dbcur . execute ( "<STR_LIT>" % tvshowtitle ) <EOL> result = dbcur . fetchone ( ) <EOL> result = eval ( result [ <NUM_LIT:1> ] . encode ( '<STR_LIT:utf-8>' ) ) <EOL> match = [ '<STR_LIT>' % ( season , episode ) , '<STR_LIT>' % ( season , episode ) ] <EOL> links = [ ( i , os . path . basename ( i ) ) for i in result ] <EOL> links = [ i [ <NUM_LIT:0> ] for i in links if any ( x in i [ <NUM_LIT:1> ] for x in match ) ] <EOL> for i in links : <EOL> try : <EOL> url = client . replaceHTMLCodes ( i ) <EOL> url = url . encode ( '<STR_LIT:utf-8>' ) <EOL> fmt = os . path . basename ( url ) . lower ( ) <EOL> if '<STR_LIT>' in fmt : quality = '<STR_LIT>' <EOL> elif '<STR_LIT>' in fmt or '<STR_LIT>' in fmt : quality = '<STR_LIT>' <EOL> else : quality = '<STR_LIT>' <EOL> sources . append ( { '<STR_LIT:source>' : '<STR_LIT>' , '<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> return <EOL> url = '<STR_LIT>' % ( url , urllib . quote_plus ( client . agent ( ) ) ) <EOL> return url </s>
