Skip to content

Instantly share code, notes, and snippets.

@Sealjay
Created February 11, 2021 19:59
Show Gist options
  • Save Sealjay/5926069ebc632eb944db9da1521ad5ed to your computer and use it in GitHub Desktop.
Save Sealjay/5926069ebc632eb944db9da1521ad5ed to your computer and use it in GitHub Desktop.
teamsvid-asynctest

async def main(): video_indexer = await AsyncVideoIndexer.create( os.environ.get("VIDEO_INDEXER_ACCOUNT_ID"), os.environ.get("VIDEO_INDEXER_KEY"), os.environ.get("VIDEO_INDEXER_ACCOUNT_LOCATION"), )

video_to_upload = (
    "https://teamsvid011.blob.core.windows.net/videostoprocess/"
    + "204a9799-de7d-435f-90e0-40fcf116c5c0.mov?sv=2019-12-12&st="
    + "2021-01-11T01%3A17%3A00Z&se=2021-04-12T00%3A17%3A00Z&sr=b"
    + "&sp=r&sig=bpQ4sP4GqFKcZaSslR8mPmeLVlGpr2J9FPOfou8M8B4%3D"
)
# async with await video_indexer.upload_video_from_url(
#    "test video", "apple", "https://google.com", video_to_upload
# ) as response:
#    video_details = await response.json()
async with await video_indexer.get_video_id_by_external_id("apple") as response:
    video_id = await response.json()
async with await video_indexer.get_video_index(video_id) as response:
    video_details = await response.json()
    print(video_details["state"])
    print(json.dumps(video_details))
    thumbnail_id = video_details["videos"][0]["thumbnailId"]
async with await video_indexer.get_thumbnail(video_id, thumbnail_id) as response:
    video_details = await response.json()
    print(video_details)
    # print(video_details["state"])

if False:
    async with await video_indexer.get_video_index("5f029373e3") as response:
        video_details = await response.json()
    async with await video_indexer.get_video_access_token("5f029373e3") as response:
        video_access_token = await response.json()
    print(video_access_token)
    headers = {"Authorization": f"Bearer {video_access_token}"}
    async with await video_indexer.get_video_player_widget(
        video_details["id"], headers=headers
    ) as response:
        video_details = await response.text()
    print(video_details)

if name == "main": loop = asyncio.get_event_loop() loop.run_until_complete(main())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment