| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 | #!/usr/bin/env python3  # -*- coding: utf-8 -*-  """@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.@AUTHOR: ASJRD018@NAME: AnsjerFormal@software: PyCharm@DATE: 2018/9/19 10:53@Version: python3.6@MODIFY DECORD:ansjer dev@file: oss.py@Contact: chanjunkai@163.com"""from oss2 import *from oss2.models import *import timefrom var_dump import var_dumpimport urllib###########host = "oss-cn-shenzhen.aliyuncs.com"  # just for example# host = "hlsvoda.zositech.cn"  # just for example# host = 'oss-eu-central-1.aliyuncs.com'accessid = 'LTAIyMkGfEdogyL9'accesskey = '71uIjpsqVOmF7DAITRyRuc259jHOjO'import oss2# 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。auth = Auth(accessid, accesskey)# Endpoint以杭州为例,其它Region请按实际情况填写。service = oss2.Service(auth, host)print([b.name for b in oss2.BucketIterator(service)])exit()bucket_name = "cnvod1"channel_name = "vod"auth = Auth(accessid, accesskey)bucket = Bucket(auth, host, bucket_name)####################### 缩略图url = bucket.sign_url('GET', 'VVDHCVBYDKFMJRWA111A/vod1/2019010315/1546498920/ts2.ts', 60 * 60, params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})# url = bucket.sign_url('GET', 'FTSLL8HM437Z38WU111A/vod4/2018121001/1543902118/1543902118.m3u8', 60 * 60, params={'x-oss-process': 'hls/sign'})# url = urllib.parse.unquote(url, encoding='utf-8', errors='replace')urllst = url.split('?')url_start = urllib.parse.unquote(urllst[0])url_end = urllst[1]vod_play_url = '{url_start}?{url_end}'.format(url_start=url_start, url_end=url_end)print(vod_play_url)exit()# 播放m3u8# m3list = bucket.post_vod_playlist(channel_name=channel_name, playlist_name='test.m3u8', start_time=1537336020119,#                                   end_time=1537336029318)exit()# 获取推流地址channel_cfg = LiveChannelInfo(target=LiveChannelInfoTarget(frag_count=10))channel = bucket.create_live_channel(channel_name, channel_cfg)publish_url = channel.publish_urlsigned_publish_url = bucket.sign_rtmp_url("vod", "playlist.m3u8", 3600)print(signed_publish_url)
 |