Rumah > Soal Jawab > teks badan
Kali pertama transcoding PFOP berjaya
Ul penyegaran kedua berjaya
Transkod PFOP ketiga gagal,{"error":"no such bucket"}
Mana nak call
qiniuUtil = QiniuUtil()
qiniuUtil.transcode_low_m3u8("dz/msjt/xxx.mp4")
qiniuUtil.refresh_url("http://i.haierzhongyou.com/dz/msjt/xxx.mp4_low.m3u8")
qiniuUtil.transcode_low_m3u8("dz/msjt/xxx.mp4")
Kategori:
class QiniuUtil(object):
logging.basicConfig(level=logging.DEBUG,
format="%(asctime)s %(name)s %(levelname)s lineno:%(lineno)d %(message)s")
def __init__(self):
self.logger = logging.getLogger('qiniu')
self.access_key = setting.qiniu_access_key
self.secret_key = setting.qiniu_secret_key
self.bucket = setting.qiniu_video_bucket_name
self.pipeline = setting.pipeline
self.notify_url = setting.notify_url
# 视频转码
def transcode_low_m3u8(self, key):
# key 要转码的文件所在的空间和文件名。
default_fops = "avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1"
q = Auth(self.access_key, self.secret_key)
self.logger.debug(q)
fops = op_save(default_fops, self.bucket, key + '_low.m3u8')
self.logger.debug(fops)
pfop = PersistentFop(q, self.bucket, self.pipeline, self.notify_url)
ops = []
ops.append(fops)
self.logger.debug(ops)
ret, info = pfop.execute(key, ops, 1)
self.logger.info(info)
self.logger.info(ret)
return ret, info
# 刷新缓存
def refresh_url(self, url):
# url 要刷新的链接。
q = Auth(self.access_key, self.secret_key)
cdn_manager = CdnManager(q)
urls = [url]
ret, info = cdn_manager.refresh_urls(urls)
self.logger.info(info)
self.logger.info(ret)
return ret, info
Keluaran log adalah seperti berikut:
2017-05-11 18:32:51,045 qiniu DEBUG lineno:50 <qiniu.auth.Auth object at 0x000000000371EA90>
2017-05-11 18:32:51,045 qiniu DEBUG lineno:52 avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==
2017-05-11 18:32:51,045 qiniu DEBUG lineno:58 ['avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==']
2017-05-11 18:32:51,046 requests.packages.urllib3.util.retry DEBUG lineno:191 Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None)
2017-05-11 18:32:51,046 requests.packages.urllib3.connectionpool DEBUG lineno:207 Starting new HTTP connection (1): api.qiniu.com
2017-05-11 18:32:51,256 requests.packages.urllib3.connectionpool DEBUG lineno:395 http://api.qiniu.com:80 "POST /pfop HTTP/1.1" 200 46
2017-05-11 18:32:51,278 qiniu INFO lineno:61 exception:None, status_code:200, _ResponseInfo__response:<Response [200]>, text_body:{"persistentId":"z0.59143dc545a2650c99df9f34"}, req_id:7gkAAIB_6qyzhr0U, 7gkAAIB_6qyzhr0U, 7gkAAIB_6qyzhr0U, x_log:rs33_8.sel;rwro.get;RS:1;PFOPMQ:60;STATUS;PFOP:133;ZONEPROXY:134;APIS:135
2017-05-11 18:32:51,278 qiniu INFO lineno:62 {u'persistentId': u'z0.59143dc545a2650c99df9f34'}
2017-05-11 18:32:51,279 requests.packages.urllib3.connectionpool DEBUG lineno:207 Starting new HTTP connection (1): fusion.qiniuapi.com
2017-05-11 18:32:51,368 requests.packages.urllib3.connectionpool DEBUG lineno:395 http://fusion.qiniuapi.com:80 "POST /v2/tune/refresh HTTP/1.1" 200 181
2017-05-11 18:32:51,369 qiniu INFO lineno:73 exception:None, status_code:200, _ResponseInfo__response:<Response [200]>, text_body:{"code":200,"error":"success","requestId":"59143dc5e3ab3a25f0af784b","invalidUrls":null,"invalidDirs":null,"urlQuotaDay":500,"urlSurplusDay":481,"dirQuotaDay":10,"dirSurplusDay":10}, req_id:pT8AADMSLbuzhr0U, pT8AADMSLbuzhr0U, x_log:fusiondomain;fusionrefresh_v3:5;APIS:7
2017-05-11 18:32:51,369 qiniu INFO lineno:74 {u'code': 200, u'dirSurplusDay': 10, u'urlSurplusDay': 481, u'invalidDirs': None, u'invalidUrls': None, u'requestId': u'59143dc5e3ab3a25f0af784b', u'error': u'success', u'urlQuotaDay': 500, u'dirQuotaDay': 10}
2017-05-11 18:32:51,369 qiniu DEBUG lineno:50 <qiniu.auth.Auth object at 0x00000000037B62B0>
2017-05-11 18:32:51,369 qiniu DEBUG lineno:52 avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==
2017-05-11 18:32:51,369 qiniu DEBUG lineno:58 ['avthumb/m3u8/noDomain/1/segtime/10/vcodec/libx264/s/640x480/vb/500k/autoscale/1|saveas/dmlkZW90ZXN0OmR6L21zanQvMTE1M2JmMWItOWY1My00MTJkLTk2NTQtM2FlNThjOWE3MThkLm1wNF9sb3cubTN1OA==']
2017-05-11 18:32:51,411 requests.packages.urllib3.connectionpool DEBUG lineno:395 http://api.qiniu.com:80 "POST /pfop HTTP/1.1" 631 26
2017-05-11 18:32:51,413 qiniu INFO lineno:61 exception:None, status_code:631, _ResponseInfo__response:<Response [631]>, text_body:{"error":"no such bucket"}, req_id:JlEAAMz_vL2zhr0U, JlEAAMz_vL2zhr0U, error:no such bucket, x_log:TBLMGR:1/612;UC:3/612;CFGG:7/612;ZONEPROXY:8/631;APIS:8/631
2017-05-11 18:32:51,413 qiniu INFO lineno:62 None
PHP中文网2017-05-18 10:50:41
Nampaknya anda menggunakan Python SDK Qiniu Cloud Pertama sekali, anda dapat melihat dari ralat ini bahawa direktori yang sepadan belum dibuat pada Qiniu Cloud. Ia boleh difahami bahawa fail yang sepadan dengan alamat URL tidak wujud.