Skip to content

Commit 48d45c2

Browse files
author
Taois
committed
feat: 支持免嗅探接口
1 parent 921d852 commit 48d45c2

File tree

3 files changed

+293
-14
lines changed

3 files changed

+293
-14
lines changed

dashboard/src/api/modules/module.js

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,24 @@ export const getVideoDetail = async (module, params) => {
173173
* @param {string} module - 模块名称
174174
* @param {object} params - 播放参数
175175
* @param {string} params.play - 播放地址或ID
176+
* @param {string} params.flag - 源标识(线路名称)
176177
* @param {string|object} params.extend - 接口数据扩展参数(对象类型会自动转换为JSON字符串)
177178
* @param {string} params.apiUrl - 可选的直接API地址
178179
* @returns {Promise} 播放数据
179180
*/
180181
export const getPlayData = async (module, params) => {
181-
const { play, extend, apiUrl } = params
182+
const { play, flag, extend, apiUrl } = params
182183

183184
const requestParams = {
184185
ac: MODULE_ACTIONS.PLAY,
185186
play
186187
}
187188

189+
// 添加flag参数支持
190+
if (flag) {
191+
requestParams.flag = flag
192+
}
193+
188194
const processedExtend = processExtendParam(extend)
189195
if (processedExtend) {
190196
requestParams.extend = processedExtend
@@ -199,6 +205,83 @@ export const getPlayData = async (module, params) => {
199205
return get(buildModuleUrl(module), requestParams)
200206
}
201207

208+
/**
209+
* 播放解析接口 - 专门用于选集播放解析
210+
* @param {string} module - 模块名称
211+
* @param {object} params - 播放参数
212+
* @param {string} params.play - 播放地址或ID(选集链接)
213+
* @param {string} params.flag - 源标识(线路名称)
214+
* @param {string|object} params.extend - 接口数据扩展参数
215+
* @param {string} params.apiUrl - 可选的直接API地址
216+
* @returns {Promise} 播放解析结果
217+
*/
218+
export const parsePlayUrl = async (module, params) => {
219+
try {
220+
console.log('T4播放解析请求:', { module, params })
221+
222+
const playData = await getPlayData(module, params)
223+
console.log('T4播放解析响应:', playData)
224+
225+
// 处理解析结果
226+
const result = {
227+
success: true,
228+
data: playData,
229+
// 解析播放类型
230+
playType: 'direct', // 默认直链
231+
url: '',
232+
needParse: false,
233+
needSniff: false,
234+
message: ''
235+
}
236+
237+
// 检查返回数据格式
238+
if (playData && typeof playData === 'object') {
239+
// 检查parse字段
240+
if (playData.parse === 0) {
241+
// 直链播放
242+
result.playType = 'direct'
243+
result.url = playData.url || playData.play_url || ''
244+
result.needParse = false
245+
result.needSniff = false
246+
result.message = '直链播放'
247+
} else if (playData.parse === 1) {
248+
// 需要嗅探
249+
result.playType = 'sniff'
250+
result.url = playData.url || playData.play_url || ''
251+
result.needSniff = true
252+
result.message = '需要嗅探才能播放,尽情期待'
253+
} else if (playData.jx === 1) {
254+
// 需要解析
255+
result.playType = 'parse'
256+
result.url = playData.url || playData.play_url || ''
257+
result.needParse = true
258+
result.message = '需要解析才能播放,尽情期待'
259+
} else {
260+
// 默认处理为直链
261+
result.url = playData.url || playData.play_url || playData
262+
result.message = '直链播放'
263+
}
264+
} else if (typeof playData === 'string') {
265+
// 如果返回的是字符串,直接作为播放地址
266+
result.url = playData
267+
result.message = '直链播放'
268+
}
269+
270+
return result
271+
} catch (error) {
272+
console.error('T4播放解析失败:', error)
273+
return {
274+
success: false,
275+
error: error.message || '播放解析失败',
276+
playType: 'error',
277+
url: '',
278+
needParse: false,
279+
needSniff: false,
280+
message: '播放解析失败: ' + (error.message || '未知错误')
281+
}
282+
}
283+
}
284+
202285
/**
203286
* 搜索接口
204287
* @param {string} module - 模块名称
@@ -350,6 +433,7 @@ export default {
350433
getCategoryData,
351434
getVideoDetail,
352435
getPlayData,
436+
parsePlayUrl,
353437
searchVideos,
354438
executeAction,
355439
refreshModule,

dashboard/src/api/services/video.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getCategoryData,
99
getVideoDetail,
1010
getPlayData,
11+
parsePlayUrl,
1112
searchVideos,
1213
refreshModule,
1314
executeAction
@@ -323,6 +324,52 @@ class VideoService {
323324
}
324325
}
325326

327+
/**
328+
* 解析选集播放地址 - T4接口专用
329+
* @param {string} module - 模块名称
330+
* @param {object} params - 播放参数
331+
* @param {string} params.play - 播放地址或ID(选集链接)
332+
* @param {string} params.flag - 源标识(线路名称)
333+
* @param {string} params.apiUrl - API地址
334+
* @param {string} params.extend - 扩展参数
335+
* @returns {Promise} 播放解析结果
336+
*/
337+
async parseEpisodePlayUrl(module, params) {
338+
if (!validateModule(module)) {
339+
throw new Error('无效的模块名称')
340+
}
341+
342+
const { play, flag, apiUrl, extend } = params
343+
344+
if (!play) {
345+
throw new Error('播放地址不能为空')
346+
}
347+
348+
try {
349+
console.log('VideoService: 开始解析选集播放地址', { module, params })
350+
351+
const parseParams = { play, extend }
352+
353+
// 添加flag参数(线路名称)
354+
if (flag) {
355+
parseParams.flag = flag
356+
}
357+
358+
// 添加API地址
359+
if (apiUrl) {
360+
parseParams.apiUrl = apiUrl
361+
}
362+
363+
const result = await parsePlayUrl(module, parseParams)
364+
console.log('VideoService: 选集播放解析结果', result)
365+
366+
return result
367+
} catch (error) {
368+
console.error('VideoService: 解析选集播放地址失败:', error)
369+
throw error
370+
}
371+
}
372+
326373
/**
327374
* 执行T4 Action动作
328375
* @param {string} module - 模块名称

0 commit comments

Comments
 (0)