#NEWLINE# def encode( self , profiles = [ ] ) : #NEWLINE# #INDENT# '\n        Encode and upload media using asynchronous Celery tasks. If\n        ``profiles`` are specified, encode with that list of\n        ``EncodeProfile`` primary keys; otherwise, encode with all\n        associated ``EncodeProfile``s.\n        ' #NEWLINE# from . tasks import encode_media , upload_media #NEWLINE# if ( not profiles ) : #NEWLINE# #INDENT# profiles = list ( self . profiles . values_list ( 'pk' , flat = True ) ) #NEWLINE# #UNINDENT# for profile_id in profiles : #NEWLINE# #INDENT# ( encode_media . s ( self . id , profile_id ) | upload_media . s ( self . id , profile_id ) ) . apply_async ( )