edit-icon download-icon

Query media - Use OSS file address

Last Updated: Jan 02, 2018

If you do not know the media ID (a live video converted to an on-demand video using the media workflow), you can use the media input URL to query the media information over QueryMediaListByURL.

  1. import json
  2. from aliyunsdkmts.request.v20140618 import QueryMediaListByURLRequest
  3. from aliyunsdkcore import client
  4. import urllib
  5. region = '<region>'
  6. access_key_id = '<accessKeyId>'
  7. access_key_secret = '<accessKeySecret>'
  8. def queryMediaListByURL():
  9. global client
  10. client = client.AcsClient(access_key_id, access_key_secret, region)
  11. request = QueryMediaListByURLRequest.QueryMediaListByURLRequest()
  12. ossDomain = 'http://<input-bucket>.<region>.aliyuncs.com/';
  13. #Encode ossObject
  14. ossObject = encodeByRFC3986("test/The Legend of the Swordsman.mp4")
  15. request.set_FileURLs(ossDomain + ossObject)
  16. response = client.do_action_with_exception(request);
  17. json_response = json.loads(response)
  18. print json_response
  19. def encodeByRFC3986(ossObject):
  20. return urllib.quote(ossObject)
  21. if __name__ == "__main__":
  22. queryMediaListByURL()
Thank you! We've received your feedback.