def S3_ServeVideoVersionMapForS3File(self, s3file, expiresin=10800): """ Create the URIs for serving different video versions of this file Returns OrderedDict { VideoVersion: aadict(src = ..., type=...) ... } """ # If there was an error, we can just return None if s3file.Input_Error: return None # File may have been updated in the TranscoderStatusCheck call if not s3file.IsTranscoded: return None OutputMap = OrderedDict() for version in s3file.GetVideoVersionList(): bucket, key = self.GetBucketAndKeyFromArn(version["Arn"]) OutputMap[version.VideoVersion] = aadict( src = S3.GetSignedUrl(self.Session, bucket, key, expiresin), type = version.HTML_Type, ) # App.Log(version) return OutputMap or None
def S3_UploadComplete(self, FileInfo): bucketname = FileInfo['Bucket'] key = FileInfo['Key'] objectarn = "arn:aws:s3:::{0}/{1}".format(bucketname, key) # Get the File object from DB s3file = AWS.S3_File.FindByESID(S3_File_ESID=FileInfo['S3_File_ESID']) s3file.Input_Arn = objectarn # Prepare job parameters jobparams = s3file.PrepareJobParameters(self) if s3file.Input_Type != 'Simple' else '' if jobparams: jobspec = jobparams.ToJSON() # Post message to SQS message = SQS.PostMessage(self.Session, self.Config.QueueUrl, jobspec) jobarn = "" else: jobspec = '{}' message = aadict({"message_id": ""}) jobarn = None # Now we can mark the file as finished uploading. # NOTE: we pass in an empty string for the JobArn so that the pending queries still work s3file.MarkAsEnded(JobArn=jobarn, ObjectArn=objectarn, JobSpecification=jobspec) # That's it. We're ready to return the message id return {"Message": message.message_id}
def S3_VideoStatus(self, S3_File_MNID): s3file = AWS.S3_File(S3_File_MNID) RVAL = aadict() RVAL.S3_File_MNID = s3file.S3_File_MNID if s3file.IsTranscoded: RVAL.Ready = True RVAL.Status = 'Video Processing Complete' elif s3file.Input_Error: RVAL.Ready = False RVAL.Status = 'Error Encountered During Video Processing' elif s3file.Input_EndTime is None: RVAL.Ready = False RVAL.Status = 'File Is Not Uploaded Yet or Error Encountered During Upload' else: RVAL.Ready = False RVAL.Status = 'Video Processing...' RVAL.FileName = s3file.Input_FileName return RVAL