mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-05 11:22:37 +08:00
Introduce searchFirstDetail
This commit is contained in:
@@ -343,11 +343,9 @@ export default {
|
||||
if (recommendations) {
|
||||
this.info.recommendations = []
|
||||
recommendations.forEach(element => {
|
||||
zy.search(this.detail.key, element).then(res => {
|
||||
if (res) {
|
||||
zy.detail(this.detail.key, res[0].id).then(detailRes => {
|
||||
this.info.recommendations.push(detailRes)
|
||||
})
|
||||
zy.searchFirstDetail(this.detail.key, element).then(detailRes => {
|
||||
if (detailRes) {
|
||||
this.info.recommendations.push(detailRes)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -264,20 +264,18 @@ export default {
|
||||
axios.get(doubleUrl).then(res => {
|
||||
if (res.data) {
|
||||
res.data.subjects.forEach(element => {
|
||||
zy.search(this.sites[0].key, element.title).then(res => {
|
||||
if (res && res[0] && res[0].name === element.title) {
|
||||
zy.detail(this.sites[0].key, res[0].id).then(detailRes => {
|
||||
const doc = {
|
||||
key: this.sites[0].key,
|
||||
ids: res[0].id,
|
||||
site: this.sites[0],
|
||||
name: res[0].name,
|
||||
detail: detailRes,
|
||||
rate: element.rate
|
||||
}
|
||||
this.recommendationsDoubanMovie.push(doc)
|
||||
this.recommendations.push(doc)
|
||||
})
|
||||
zy.searchFirstDetail(this.sites[0].key, element.title).then(detailRes => {
|
||||
if (detailRes) {
|
||||
const doc = {
|
||||
key: this.sites[0].key,
|
||||
ids: detailRes.id,
|
||||
site: this.sites[0],
|
||||
name: detailRes.name,
|
||||
detail: detailRes,
|
||||
rate: element.rate
|
||||
}
|
||||
this.recommendationsDoubanMovie.push(doc)
|
||||
this.recommendations.push(doc)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -294,20 +292,20 @@ export default {
|
||||
axios.get(doubleUrl).then(res => {
|
||||
if (res.data) {
|
||||
res.data.subjects.forEach(element => {
|
||||
zy.search(this.sites[0].key, element.title).then(res => {
|
||||
if (res && res[0] && res[0].name === element.title) {
|
||||
zy.detail(this.sites[0].key, res[0].id).then(detailRes => {
|
||||
const doc = {
|
||||
key: this.sites[0].key,
|
||||
ids: res[0].id,
|
||||
site: this.sites[0],
|
||||
name: res[0].name,
|
||||
detail: detailRes,
|
||||
rate: element.rate
|
||||
}
|
||||
this.recommendationsDoubanTV.push(doc)
|
||||
this.recommendations.push(doc)
|
||||
})
|
||||
console.log('searching ' + element.title)
|
||||
zy.searchFirstDetail(this.sites[0].key, element.title).then(detailRes => {
|
||||
console.log(detailRes)
|
||||
if (detailRes) {
|
||||
const doc = {
|
||||
key: this.sites[0].key,
|
||||
ids: detailRes.id,
|
||||
site: this.sites[0],
|
||||
name: detailRes.name,
|
||||
detail: detailRes,
|
||||
rate: element.rate
|
||||
}
|
||||
this.recommendationsDoubanTV.push(doc)
|
||||
this.recommendations.push(doc)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -240,6 +240,43 @@ const zy = {
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 搜索资源详情
|
||||
* @param {*} key 资源网 key
|
||||
* @param {*} wd 搜索关键字
|
||||
* @returns
|
||||
*/
|
||||
searchFirstDetail (key, wd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getSite(key).then(res => {
|
||||
const site = res
|
||||
const url = `${site.api}?wd=${encodeURI(wd)}`
|
||||
axios.get(url, { timeout: 3000 }).then(res => {
|
||||
const data = res.data
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const jsondata = json?.rss === undefined ? json : json.rss
|
||||
if (json && jsondata && jsondata.list) {
|
||||
let videoList = jsondata.list.video
|
||||
if (Object.prototype.toString.call(videoList) === '[object Object]') videoList = [].concat(videoList)
|
||||
videoList = videoList?.filter(e => e.name.toLowerCase().includes(wd.toLowerCase()))
|
||||
if (videoList?.length) {
|
||||
this.detail(key, videoList[0].id).then(detailRes => {
|
||||
resolve(detailRes)
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取资源详情
|
||||
* @param {*} key 资源网 key
|
||||
|
||||
Reference in New Issue
Block a user