#NEWLINE# def prepare( self , **kwargs ) : #NEWLINE# #INDENT# if re . search ( 'imgur\\.com/a/' , self . url ) : #NEWLINE# #INDENT# content = get_content ( self . url ) #NEWLINE# album = ( match1 ( content , 'album\\s*:\\s*({.*}),' ) or match1 ( content , 'image\\s*:\\s*({.*}),' ) ) #NEWLINE# album = json . loads ( album ) #NEWLINE# count = album [ 'album_images' ] [ 'count' ] #NEWLINE# images = album [ 'album_images' ] [ 'images' ] #NEWLINE# ext = images [ 0 ] [ 'ext' ] #NEWLINE# self . streams = { #NEWLINE# #INDENT# 'original' : { #NEWLINE# #INDENT# 'src' : [ ( 'http://i.imgur.com/%s%s' % ( i [ 'hash' ] , ext ) ) for i in images ] , #NEWLINE# 'size' : sum ( [ i [ 'size' ] for i in images ] ) , #NEWLINE# 'container' : ext [ 1 : ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'thumbnail' : { #NEWLINE# #INDENT# 'src' : [ ( 'http://i.imgur.com/%ss%s' % ( i [ 'hash' ] , '.jpg' ) ) for i in images ] , #NEWLINE# 'container' : 'jpg' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . title = album [ 'title' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if re . search ( 'i\\.imgur\\.com/' , self . url ) : #NEWLINE# #INDENT# ( _ , container , size ) = url_info ( self . url ) #NEWLINE# self . streams = { #NEWLINE# #INDENT# 'original' : { #NEWLINE# #INDENT# 'src' : [ self . url ] , #NEWLINE# 'size' : size , #NEWLINE# 'container' : container , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . title = r1 ( 'i\\.imgur\\.com/([^./]*)' , kwargs . url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# content = get_content ( self . url ) #NEWLINE# image = json . loads ( match1 ( content , 'image\\s*:\\s*({.*}),' ) ) #NEWLINE# ext = image [ 'ext' ] #NEWLINE# self . streams = { #NEWLINE# #INDENT# 'original' : { #NEWLINE# #INDENT# 'src' : [ ( 'http://i.imgur.com/%s%s' % ( image [ 'hash' ] , ext ) ) ] , #NEWLINE# 'size' : image [ 'size' ] , #NEWLINE# 'container' : ext [ 1 : ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'thumbnail' : { #NEWLINE# #INDENT# 'src' : [ ( 'http://i.imgur.com/%ss%s' % ( image [ 'hash' ] , '.jpg' ) ) ] , #NEWLINE# 'container' : 'jpg' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . title = image [ 'title' ]