当前位置: 首页 > ai >正文

Node.js 检测视频链接是否可以播放(批量检测)

Node.js 检测视频链接是否可以播放(批量检测)

  • 运行 node check-video.js
//check-video.js
const sections = [{content_length_text: '01:42:37',content_length: 6157,index: 1,items: [{can_be_previewed: true,content_summary: '03:07',id: 42059630,title: 'What Is Social Media Marketing',object_index: 1,item_type: 'lecture',},{can_be_previewed: true,content_summary: '03:19',id: 42059642,title: 'Social Media Marketing - How to Use Social Platforms to Grow Your Business',object_index: 2,item_type: 'lecture',},{can_be_previewed: true,content_summary: '03:09',id: 42059658,title: 'Social Media Marketing Course - Top Social Platforms',object_index: 3,item_type: 'lecture',}],lecture_count: 21,title: 'Social Media Marketing',}]
// npm 安装依赖
const axios = require('axios')
function buildUrl(item, sitem) {const className = item.title // 一级目录const subClassName = sitem.title //二级标题return `/${className}/${subClassName}.mp4`
}async function checkVideoHead(url) {try {const response = await axios.head(url)if (response.status === 200 && response.headers['content-type'].startsWith('video/')) {return { url, playable: true }} else {return { url, playable: false }}} catch (err) {return { url, playable: false }}
};(async () => {const allResults = []let count = 0 ;for (const section of sections) {for (const sitem of section.items) {const url = buildUrl(section, sitem)const result = await checkVideoHead(url)allResults.push(result)count ++;console.log(count,`${result.playable ? '✅' : '❌'} ${url}`)}}
})()
http://www.xdnf.cn/news/13835.html

相关文章:

  • C++题解 P1525 Cantor表
  • (十四)自然语言处理中的深度学习:语言表征、模型架构与计算语言学基础
  • vue3 双容器自动扩展布局 根据 内容的多少 动态定义宽度
  • 【Pytorch】(1)Pytorch环境安装-②安装Pytorch
  • 激光雷达 + 视觉相机:高精度位姿测量方案详解
  • QCustomPlot 中实现拖动区域放大‌与恢复
  • Python打卡第53天
  • 【SAS求解多元回归方程】REG多元回归分析-多元二次回归
  • 论文略读:AutoG: Towards automatic graph construction from tabular data
  • 拍摄的照片模糊,有什么方法可以一键变清晰吗?
  • 头文件管理
  • 1.线性表的顺序存储-顺序表
  • FastAPI基础入门(四)
  • 【推荐算法课程二】推荐算法介绍-深度学习算法
  • cocos android打包 错误总结
  • QCoreApplication QApplication
  • 【2025】Ubuntu22.04深度学习环境搭建记录
  • Java常用类库大全(学习笔记)持续更新中
  • JS手写代码篇---手写sleep
  • fbx导入blender结构错乱,但在threejs中加载正常
  • 【Python打卡Day36】信贷项目的神经网络训练@浙大疏锦行
  • HALCON第三讲->特征提取
  • HTML常用标签(上)
  • 位运算基础
  • 强化微调技术与GRPO算法(2): 优势、应用场景与选择指南
  • python程序设计(2)
  • AI Agent的记忆体系与架构设计
  • QEMU源码全解析 —— 块设备虚拟化(27)
  • vue下的xlsx文件导出和导入的写法
  • 重要的城市(图论 最短路)