腾讯云云点播通过videoid获取视频详情nodejs版

客官°小女子只卖身不卖艺 2022-09-09 15:59 419阅读 0赞

首先,安装express框架,目的,使用express框架请求,方便快捷

参考 https://www.npmjs.com/package/express

创建 index.js

  1. const express = require('express')
  2. const app = express()
  3. const txSdk = require('./txsdk')
  4. app.get('/getTxMediaInfo', function (req, res) {
  5. txSdk.getTxMediaInfo(req.query.videoid, function (result) {
  6. res.send(result)
  7. })
  8. })
  9. app.listen(81)

txsdk.js

  1. const secretId="";
  2. const secretKey="";
  3. const region="ap-beijing";
  4. const tencentcloud = require("tencentcloud-sdk-nodejs");
  5. // 导入对应产品模块的client models。
  6. const VodClient = tencentcloud.vod.v20180717.Client
  7. const clientConfig = {
  8. // 腾讯云认证信息
  9. credential: {
  10. secretId: secretId,
  11. secretKey: secretKey,
  12. },
  13. // 产品地域
  14. region: region,
  15. // 可选配置实例
  16. profile: {
  17. signMethod: "HmacSHA256", // 签名方法
  18. httpProfile: {
  19. reqMethod: "POST", // 请求方法
  20. reqTimeout: 30, // 请求超时时间,默认60s
  21. },
  22. },
  23. }
  24. // 实例化要请求产品(以cvm为例)的client对象
  25. const client = new VodClient(clientConfig)
  26. // 通过client对象调用想要访问的接口,需要传入请求对象以及响应回调函数
  27. /**
  28. * 获取媒体详细信息
  29. * @param videoId
  30. */
  31. const getTxMediaInfo = function (videoId,callback) {
  32. client.DescribeMediaInfos({
  33. FileIds: [videoId]
  34. }, function (err, response) {
  35. if (err) {
  36. // console.error("error", err)
  37. callback(response)
  38. } else {
  39. // console.log(response)
  40. callback(response)
  41. }
  42. })
  43. }
  44. module.exports = {
  45. getTxMediaInfo
  46. }

访问域名:81/getTxMediaInfo?videoid=

发表评论

表情:
评论列表 (有 0 条评论,419人围观)

还没有评论,来说两句吧...

相关阅读