Package: contentaiextractor
contentai-extractor-runtime-pythonThis is a python package used for implementing a custom extractor that runs on the ContentAI platform.https://pypi.org/project/contentaiextractor/UsageAPI DocumentationDependenciesDevelopChangesUsagepipinstallcontentaiextractorimportcontentaiextractorascontentai# download content locallycontent_path=contentai.download_content()# access metadata that was supplied when running a job# contentai run s3://bucket/video.mp4 -d '{ "input": "value" }'inputData=contentai.metadata()["input"]# get output from another extractorcsv=contentai.get("extractor","data.csv")json=contentai.get_json("extractor","data.json")# extract some dataoutputData=[]outputData.append({"frameNumber":1})# output data from this extractorcontentai.set("output",outputData)API DocumentationContentAIError ObjectsclassContentAIError(Exception)represents a contentai errorFieldsextractor_name- name of the extractor being runjob_id- current job idcontent_url- URL of the content the extractor is run againstcontent_path- local path where the extractor can access the contentresult_path- local path where the extractor should write the resultsrunning_in_contentai- boolean set toTrue; useful for testing code locallymetadata_json- raw string (orNoneif not set) for active extractor run (also, see parsedmetadata())Functionsdownload_contentdownload_content()download content to work with locallyreturns local path where content is writtenmetadatametadata()returns a dict containing input metadataexample:access metadata that was supplied when running a jobcontentairuns3://bucket/video.mp4-d'{ "input: "value" }'input=contentai.metadata()["input"]extractorsextractors()get list of all extractors executed against this content urlreturns a list of strings["extractor1","extractor2"],example:# get all data from all extractorsforextractorincontentai.extractors():forkeyincontentai.keys(extractor):data=contentai.get(extractor,key)keyskeys(extractor_name)get a list of keys for specified extractorreturns a dict containing a list of keys["data.json","data.csv","data.txt,"]example:keys=contentai.keys("azure_videoindexer")forkeyinkeys:data=contentai.get("azure_videoindexer",key)getget(extractor_name,key)get the contents of a particular keyexample:# get another extractor's outputdata=contentai.get("some_extractor","output.csv")get_jsonget_json(extractor_name,key)get the json contents of a particular keyexample:# get another extractor's outputdata=contentai.get_json("some_extractor","data.json")get_bytesget_bytes(extractor_name,key)get the contents of a particular key in raw bytesexample:# get another extractor's outputdata=contentai.get_bytes("some_extractor","output.bin")setset(key,value)set results data for this extractorcan be called multiple times with different keysvalue is a stringexample:contentai.set("output","hello world")set_jsonset_json(key,value)set results data for this extractorcan be called multiple times with different keysvalue can be anythingexample:data={}data["foo"]=barcontentai.set_json("output",data)set_bytesset_bytes(key,value)set results data for this extractorcan be called multiple times with different keysvalue is bytesexample:some_file=open("some-file","rb")contentai.set_bytes("output",some_file.read())save_resultssave_results()save results immediately, instead of waiting until process exitsparse_content_urlparse_content_url()extract details from content urlreturnssource_bucket_name- the s3 bucket name derived from content_urlsource_bucket_key- the s3 bucket key derived from content_urlsource_bucket_region- the s3 bucket region derived from content_urlthe followingcontent urlformats are supported:Simple (CLI) Format -s3://{bucket}/{key}Virtual Hosted Format -https://{bucket}.s3.amazonaws.com/{key}Virtual Hosted Format with Region -https://{bucket}.s3.{region}.amazonaws.com/{key}Dependenciespip install -r requirements.txtDevelopChoose a make command to run

  build    build package
  deploy   upload package to pypi
  docs     generates api docs in markdownReleaseTo publish a new release to pypi, increment the version number insetup.py, tag the commit and push it.Changes1.1.0addextractors()1.0.4updated changelog1.0.3fixes issue whereEXTRACTOR_METADATAenvvar was indavertently required1.0.2add safety to setting retrieval on local runsdocumentation updates1.0.1api docs for publish to pypi1.0.0initial release