diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index e616005..5ebbb66 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -173,9 +173,9 @@ export default { }, getFilters () { const groups = [...new Set(this.sites.map(site => site.group))] - const filters = [] + var filters = [] groups.forEach(g => { - const doc = { + var doc = { text: g, value: g } @@ -327,8 +327,8 @@ export default { if (!this.checkSiteKey()) { return false } - const randomstring = require('randomstring') - const doc = { + var randomstring = require('randomstring') + var doc = { key: this.dialogType === 'edit' ? this.siteInfo.key : this.siteInfo.key ? this.siteInfo.key : randomstring.generate(6), id: this.dialogType === 'edit' ? this.siteInfo.id : this.sites.length ? this.sites[this.sites.length - 1].id + 1 : 1, name: this.siteInfo.name, @@ -387,7 +387,7 @@ export default { remote.dialog.showOpenDialog(options).then(result => { if (!result.canceled) { result.filePaths.forEach(file => { - const str = fs.readFileSync(file) + var str = fs.readFileSync(file) const json = JSON.parse(str) json.forEach(ele => { if (ele.api && this.sites.filter(x => x.key === ele.key).length === 0 && this.sites.filter(x => x.name === ele.name && x.api === ele.api).length === 0) { @@ -436,7 +436,7 @@ export default { sites.add(row) }, resetId (inArray) { - const id = 1 + var id = 1 inArray.forEach(ele => { ele.id = id id += 1 @@ -446,7 +446,7 @@ export default { // 因为el-table的数据是单向绑定,我们先同步el-table里的数据和其绑定的数据 this.syncTableData() sites.clear().then(res => { - const id = 1 + var id = 1 this.sites.forEach(ele => { ele.id = id id += 1 @@ -467,7 +467,7 @@ export default { return false } const tbody = document.getElementById('sites-table').querySelector('.el-table__body-wrapper tbody') - const _this = this + var _this = this Sortable.create(tbody, { onEnd ({ newIndex, oldIndex }) { const currRow = _this.sites.splice(oldIndex, 1)[0] diff --git a/src/components/Film.vue b/src/components/Film.vue index 76ba273..a83fbd2 100644 --- a/src/components/Film.vue +++ b/src/components/Film.vue @@ -535,7 +535,7 @@ export default { return a.localeCompare(b, 'zh') }, dateFormat (row, column) { - const date = row[column.property] + var date = row[column.property] if (date === undefined) { return '' } @@ -609,7 +609,7 @@ export default { // 屏蔽主分类 const classToHide = ['电影', '电影片', '电视剧', '连续剧', '综艺', '动漫'] zy.class(key).then(res => { - const allClass = [{ name: '最新', tid: 0 }] + var allClass = [{ name: '最新', tid: 0 }] res.class.forEach(element => { if (!this.setting.excludeRootClasses || !classToHide.includes(element.name)) { if (this.setting.excludeR18Films) { @@ -629,7 +629,7 @@ export default { }) }, containsR18Keywords (name) { - const containKeyWord = false + var containKeyWord = false if (!name) { return containKeyWord } @@ -750,8 +750,8 @@ export default { }) }, querySearch (queryString, cb) { - const searchList = this.searchList.slice(0, -1) - const results = queryString ? searchList.filter(this.createFilter(queryString)) : this.searchList + var searchList = this.searchList.slice(0, -1) + var results = queryString ? searchList.filter(this.createFilter(queryString)) : this.searchList // 调用 callback 返回建议列表的数据 cb(results) }, diff --git a/src/components/History.vue b/src/components/History.vue index 7bc3a0b..c929476 100644 --- a/src/components/History.vue +++ b/src/components/History.vue @@ -298,7 +298,7 @@ export default { remote.dialog.showOpenDialog(options).then(result => { if (!result.canceled) { result.filePaths.forEach(file => { - const str = fs.readFileSync(file) + var str = fs.readFileSync(file) const json = JSON.parse(str) history.bulkAdd(json).then(res => { this.$message.success('导入成功') @@ -319,7 +319,7 @@ export default { }) }, getSiteName (key) { - const site = this.sites.find(e => e.key === key) + var site = this.sites.find(e => e.key === key) if (site) { return site.name } @@ -333,7 +333,7 @@ export default { }, updateDatabase () { history.clear().then(res => { - const id = length + var id = length this.history.forEach(ele => { ele.id = id id -= 1 diff --git a/src/components/IPTV.vue b/src/components/IPTV.vue index 4a422d7..d0832e8 100644 --- a/src/components/IPTV.vue +++ b/src/components/IPTV.vue @@ -168,9 +168,9 @@ export default { }, getFilters () { const groups = [...new Set(this.channelList.map(iptv => iptv.group))] - const filters = [] + var filters = [] groups.forEach(g => { - const doc = { + var doc = { text: g, value: g } @@ -257,7 +257,7 @@ export default { }, mergeChannel () { if (this.inputContent && this.multipleSelection.length) { - const channels = [] + var channels = [] const id = this.multipleSelection[0].id this.multipleSelection.forEach(ele => { channels = channels.concat(ele.channels) @@ -320,7 +320,7 @@ export default { remote.dialog.showSaveDialog(options).then(result => { if (!result.canceled) { if (result.filePath.endsWith('m3u')) { - const writer = require('m3u').extendedWriter() + var writer = require('m3u').extendedWriter() this.iptvList.forEach(e => { writer.file(e.url, -1, e.name) }) @@ -364,7 +364,7 @@ export default { const urls = ele.url.split('#').filter(e => e.startsWith('http')) // 网址带#时自动分割 urls.forEach(url => { if (ele.name && url && new URL.URL(url).pathname.endsWith('.m3u8')) { // 网址可能带参数 - const doc = { + var doc = { id: id, name: ele.name, url: url, @@ -438,12 +438,12 @@ export default { res = res.filter(o => !this.iptvList.find(e => o.url === e.url)) const resClone = JSON.parse(JSON.stringify(res)) const uniqueChannelName = {} - for (const i = 0; i < resClone.length; i++) { - const channelName = resClone[i].name.trim().replace(/[- ]?(1080p|蓝光|超清|高清|标清|hd|cq|4k)(\d{1,2})?$/i, '') + for (var i = 0; i < resClone.length; i++) { + var channelName = resClone[i].name.trim().replace(/[- ]?(1080p|蓝光|超清|高清|标清|hd|cq|4k)(\d{1,2})?$/i, '') if (channelName.match(/cctv/i)) channelName = channelName.replace('-', '') if (Object.keys(uniqueChannelName).some(name => channelName.match(new RegExp(`${name}(1080p|4k|(?!\\d))`, 'i')))) continue // 避免重复 const matchRule = new RegExp(`${channelName}(1080p|4k|(?!\\d))`, 'i') - for (const j = i; j < resClone.length; j++) { + for (var j = i; j < resClone.length; j++) { if (resClone[j].name.match(/cctv/i)) { resClone[j].name = resClone[j].name.replace('-', '') } @@ -513,7 +513,7 @@ export default { }) }, resetId (channelList) { - const id = 1 + var id = 1 channelList.forEach(ele => { ele.id = id id += 1 @@ -575,7 +575,7 @@ export default { }) }, async checkChannelsBySite (channels) { - const siteList = {} + var siteList = {} channels.forEach(channel => { const site = channel.url.split('/')[2] if (siteList[site]) { diff --git a/src/components/Play.vue b/src/components/Play.vue index f241a7f..41dbb1f 100644 --- a/src/components/Play.vue +++ b/src/components/Play.vue @@ -529,7 +529,7 @@ export default { const index = this.video.info.index || 0 const db = await history.find({ site: this.video.key, ids: this.video.info.id }) const key = this.video.key + '@' + this.video.info.id - const time = this.video.info.time + var time = this.video.info.time this.xg.removeAllProgressDot() this.startPosition = this.endPosition = { min: '00', sec: '00' } if (db) { @@ -752,9 +752,9 @@ export default { }, prevEvent () { if (this.video.iptv) { - const index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID) + var index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID) if (index >= 1) { - const channel = this.channelList[index - 1] + var channel = this.channelList[index - 1] this.playChannel(channel) } else { this.$message.warning('这已经是第一个频道了。') @@ -770,9 +770,9 @@ export default { }, nextEvent () { if (this.video.iptv) { - const index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID) + var index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID) if (index < (this.channelList.length - 1)) { - const channel = this.channelList[index + 1] + var channel = this.channelList[index + 1] this.playChannel(channel) } else { this.$message.warning('这已经是最后一个频道了。') @@ -904,7 +904,7 @@ export default { playWithExternalPalyerEvent () { const fs = require('fs') if (this.video.iptv) { - const externalPlayer = this.setting.externalPlayer + var externalPlayer = this.setting.externalPlayer if (!externalPlayer) { this.$message.error('请设置第三方播放器路径') return @@ -917,12 +917,12 @@ export default { return } this.fetchPlaylist().then(playlistUrls => { - const externalPlayer = this.setting.externalPlayer + var externalPlayer = this.setting.externalPlayer if (!externalPlayer) { this.$message.error('请设置第三方播放器路径') // 在线播放该视频 if (playlistUrls[this.video.info.index].endsWith('.m3u8')) { - const link = 'https://www.m3u8play.com/?play=' + playlistUrls[this.video.info.index] + var link = 'https://www.m3u8play.com/?play=' + playlistUrls[this.video.info.index] const open = require('open') open(link) } @@ -945,11 +945,11 @@ export default { const path = require('path') const os = require('os') const fs = require('fs') - const filePath = path.join(os.tmpdir(), fileName + '.m3u') + var filePath = path.join(os.tmpdir(), fileName + '.m3u') if (fs.existsSync(filePath)) { fs.unlinkSync(filePath) } - const str = '#EXTM3U' + os.EOL + var str = '#EXTM3U' + os.EOL for (let ind = startIndex; ind < m3u8Arr.length; ind++) { str += `#EXTINF: -1, 第${ind + 1}集` + os.EOL str += m3u8Arr[ind] + os.EOL @@ -1017,7 +1017,7 @@ export default { }, listItemEvent (n) { if (this.video.iptv) { - const channel = this.channelList[n] + var channel = this.channelList[n] // 是直播源,直接播放 this.playChannel(channel) } else { @@ -1381,7 +1381,7 @@ export default { this.channelTree = [] const groups = [...new Set(this.channelList.map(iptv => iptv.group))] groups.forEach(g => { - const doc = { + var doc = { label: g, children: this.channelList.filter(x => x.group === g).map(i => { return { label: i.name, channel: i } }) } @@ -1468,7 +1468,7 @@ export default { this.videoStop() return } - const historyItem = this.right.history[0] + var historyItem = this.right.history[0] this.video = { key: historyItem.site, info: { id: historyItem.ids, name: historyItem.name, index: historyItem.index } } } else if (this.video.iptv && !this.isLive) { this.playChannel(this.video.iptv) diff --git a/src/components/Recommendation.vue b/src/components/Recommendation.vue index b2c40dc..6ce52c0 100644 --- a/src/components/Recommendation.vue +++ b/src/components/Recommendation.vue @@ -190,7 +190,7 @@ export default { } }, filteredRecommendations () { - const filteredData = this.recommendations.filter(x => (this.selectedAreas.length === 0) || this.selectedAreas.includes(x.detail.area)) + var filteredData = this.recommendations.filter(x => (this.selectedAreas.length === 0) || this.selectedAreas.includes(x.detail.area)) filteredData = filteredData.filter(x => (this.selectedTypes.length === 0) || this.selectedTypes.includes(x.detail.type)) return filteredData } diff --git a/src/components/Setting.vue b/src/components/Setting.vue index bf13090..bcff144 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -337,7 +337,7 @@ export default { } remote.dialog.showOpenDialog(options).then(result => { if (!result.canceled) { - const playerPath = result.filePaths[0].replace(/\\/g, '/') + var playerPath = result.filePaths[0].replace(/\\/g, '/') this.$message.success('设定第三方播放器路径为:' + result.filePaths[0]) this.d.externalPlayer = playerPath this.updateSettingEvent() diff --git a/src/components/Star.vue b/src/components/Star.vue index 9e2ceff..5feb45a 100644 --- a/src/components/Star.vue +++ b/src/components/Star.vue @@ -308,7 +308,7 @@ export default { }, updateEvent (e) { zy.detail(e.key, e.ids).then(detailRes => { - const doc = { + var doc = { id: e.id, key: e.key, ids: e.ids, @@ -320,7 +320,7 @@ export default { star.get(e.id).then(resStar => { if (!e.hasUpdate && e.detail.last !== detailRes.last) { doc.hasUpdate = true - const msg = `同步"${e.name}"成功, 检查到更新。` + var msg = `同步"${e.name}"成功, 检查到更新。` this.$message.success(msg) } else { this.numNoUpdate += 1 @@ -329,7 +329,7 @@ export default { this.getFavorites() }) }).catch(err => { - const msg = `同步"${e.name}"失败, 请重试。` + var msg = `同步"${e.name}"失败, 请重试。` this.$message.warning(msg, err) }) }, @@ -370,7 +370,7 @@ export default { if (row.site) { return row.site.name } else { - const site = this.sites.find(e => e.key === row.key) + var site = this.sites.find(e => e.key === row.key) if (site) { return site.name } @@ -422,10 +422,10 @@ export default { } remote.dialog.showOpenDialog(options).then(result => { if (!result.canceled) { - const starList = Array.from(this.list) - const id = this.list.length + 1 + var starList = Array.from(this.list) + var id = this.list.length + 1 result.filePaths.forEach(file => { - const str = fs.readFileSync(file) + var str = fs.readFileSync(file) const json = JSON.parse(str) json.reverse().forEach(ele => { const starExists = starList.some(x => x.key === ele.key && x.ids === ele.ids) @@ -440,7 +440,7 @@ export default { last: ele.last, note: ele.note } - const doc = { + var doc = { id: id, key: ele.key, ids: ele.ids, @@ -473,7 +473,7 @@ export default { updateDatabase () { this.syncTableData() star.clear().then(res => { - const id = this.list.length + var id = this.list.length this.list.forEach(ele => { ele.id = id id -= 1 diff --git a/src/lib/site/onlineVideo.js b/src/lib/site/onlineVideo.js index 4c87e84..2f923da 100644 --- a/src/lib/site/onlineVideo.js +++ b/src/lib/site/onlineVideo.js @@ -35,29 +35,29 @@ const onlineVideo = { }, playVideoOnBde4 (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `https://bde4.com/search/${videoName}` + var url = `https://bde4.com/search/${videoName}` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('div.search-list') - const searchResult = $(e).find('div>div>div>div>a').toArray() + var e = $('div.search-list') + var searchResult = $(e).find('div>div>div>div>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).attr('title') + var title = $(searchResult[0]).attr('title') if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { - const detailPageFullLink = 'https://bde4.com/' + detailPageLink + var detailPageFullLink = 'https://bde4.com/' + detailPageLink // 解析详情页面 axios.get(detailPageFullLink).then(res => { const $ = cheerio.load(res.data) - const e = $('div.info1') - const videoList = $(e).find('a').toArray() - let videoFullLink = detailPageFullLink + var e = $('div.info1') + var videoList = $(e).find('a').toArray() + var videoFullLink = detailPageFullLink // 获取index视频链接 if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') if (indexVideoLink.includes('.htm')) { videoFullLink = 'https://bde4.com' + indexVideoLink } @@ -69,31 +69,31 @@ const onlineVideo = { }, playVideoOnK1080 (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `https://k1080.net/vodsearch123/-------------.html?wd=${videoName}&submit=` + var url = `https://k1080.net/vodsearch123/-------------.html?wd=${videoName}&submit=` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('#searchList') - const searchResult = $(e).find('li>div>a').toArray() + var e = $('#searchList') + var searchResult = $(e).find('li>div>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).attr('title') + var title = $(searchResult[0]).attr('title') if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = 'https://k1080.net' + detailPageLink + var detailPageFullLink = 'https://k1080.net' + detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('#playlist1') + var e = $('#playlist1') // 获取所有视频链接 - const videoList = $(e).find('div>ul>li>a').toArray() - let videoFullLink = detailPageFullLink + var videoList = $(e).find('div>ul>li>a').toArray() + var videoFullLink = detailPageFullLink // 获取index视频链接 if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') if (indexVideoLink.includes('.htm')) { videoFullLink = 'https://k1080.net' + indexVideoLink } @@ -105,31 +105,31 @@ const onlineVideo = { }, playVideoOnSubaibai (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `https://www.subaibai.com/xssearch?q=${videoName}` + var url = `https://www.subaibai.com/xssearch?q=${videoName}` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('div.search_list') - const searchResult = $(e).find('div>ul>li>h3>a').toArray() + var e = $('div.search_list') + var searchResult = $(e).find('div>ul>li>h3>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).text() + var title = $(searchResult[0]).text() if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = detailPageLink + var detailPageFullLink = detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('div.paly_list_btn') + var e = $('div.paly_list_btn') // 获取所有视频链接 - const videoList = $(e).find('a').toArray() + var videoList = $(e).find('a').toArray() // 获取index视频链接 - let videoFullLink = detailPageFullLink + var videoFullLink = detailPageFullLink if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') if (indexVideoLink.includes('.htm')) { videoFullLink = indexVideoLink } @@ -141,31 +141,31 @@ const onlineVideo = { }, playVideoOnYhdm (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `http://www.yhdm.tv/search/${videoName}` + var url = `http://www.yhdm.tv/search/${videoName}` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('div.lpic') - const searchResult = $(e).find('div>ul>li>h2>a').toArray() + var e = $('div.lpic') + var searchResult = $(e).find('div>ul>li>h2>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).attr('title') + var title = $(searchResult[0]).attr('title') if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = 'http://www.yhdm.tv/' + detailPageLink + var detailPageFullLink = 'http://www.yhdm.tv/' + detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('div.movurl') + var e = $('div.movurl') // 获取所有视频链接 - const videoList = $(e).find('div>ul>li>a').toArray() + var videoList = $(e).find('div>ul>li>a').toArray() // 获取index视频链接 - let videoFullLink = detailPageFullLink + var videoFullLink = detailPageFullLink if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') if (indexVideoLink.includes('.htm')) { videoFullLink = 'http://www.yhdm.tv/' + indexVideoLink } @@ -177,31 +177,31 @@ const onlineVideo = { }, playVideoOndmdm2020 (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `http://www.dmdm2020.com/dongmansearch.html?wd=${videoName}&submit=` + var url = `http://www.dmdm2020.com/dongmansearch.html?wd=${videoName}&submit=` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('#searchList') - const searchResult = $(e).find('ul>li>div>h4>a').toArray() + var e = $('#searchList') + var searchResult = $(e).find('ul>li>div>h4>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).text() + var title = $(searchResult[0]).text() if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = 'http://www.dmdm2020.com' + detailPageLink + var detailPageFullLink = 'http://www.dmdm2020.com' + detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('#playlist1') + var e = $('#playlist1') // 获取所有视频链接 - const videoList = $(e).find('div>ul>li>a').toArray() + var videoList = $(e).find('div>ul>li>a').toArray() // 获取index视频链接 - let videoFullLink = detailPageFullLink + var videoFullLink = detailPageFullLink if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') if (indexVideoLink.includes('.htm')) { videoFullLink = 'http://www.dmdm2020.com' + indexVideoLink } @@ -213,31 +213,31 @@ const onlineVideo = { }, playVideoOnSyrme (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `https://syrme.top/searchs?q=${videoName}` + var url = `https://syrme.top/searchs?q=${videoName}` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('ul.MovieList') - const searchResult = $(e).find('ul>li>article>a').toArray() + var e = $('ul.MovieList') + var searchResult = $(e).find('ul>li>article>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).find('a>h2').text() + var title = $(searchResult[0]).find('a>h2').text() if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = 'https://syrme.top' + detailPageLink + var detailPageFullLink = 'https://syrme.top' + detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('#categories-2') + var e = $('#categories-2') // 获取所有视频链接 - const videoList = $(e).find('div>ul>li>a').toArray() + var videoList = $(e).find('div>ul>li>a').toArray() // 获取index视频链接 - let videoFullLink = detailPageFullLink + var videoFullLink = detailPageFullLink if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') videoFullLink = 'https://syrme.top' + indexVideoLink } open(videoFullLink) @@ -247,31 +247,31 @@ const onlineVideo = { }, playVideoOnJpysvip (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `https://www.jpysvip.net/vodsearch/-------------.html?wd=${videoName}&submit=` + var url = `https://www.jpysvip.net/vodsearch/-------------.html?wd=${videoName}&submit=` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('#searchList') - const searchResult = $(e).find('ul>li>div>a').toArray() + var e = $('#searchList') + var searchResult = $(e).find('ul>li>div>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).attr('title') + var title = $(searchResult[0]).attr('title') if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = 'https://www.jpysvip.net' + detailPageLink + var detailPageFullLink = 'https://www.jpysvip.net' + detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('#playlist1') + var e = $('#playlist1') // 获取所有视频链接 - const videoList = $(e).find('div>ul>li>a').toArray() + var videoList = $(e).find('div>ul>li>a').toArray() // 获取index视频链接 - let videoFullLink = detailPageFullLink + var videoFullLink = detailPageFullLink if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') videoFullLink = 'https://www.jpysvip.net/' + indexVideoLink } open(videoFullLink) @@ -281,31 +281,31 @@ const onlineVideo = { }, playVideoOnXhkan (videoName, videoIndex) { videoName = videoName.replace(/\s/g, '') - const url = `https://www.xhkan.com/vodsearch.html?wd=${videoName}&submit=` + var url = `https://www.xhkan.com/vodsearch.html?wd=${videoName}&submit=` axios.get(url).then(res => { const $ = cheerio.load(res.data) - const e = $('#searchList') - const searchResult = $(e).find('ul>li>div>a').toArray() + var e = $('#searchList') + var searchResult = $(e).find('ul>li>div>a').toArray() // 获取第一个搜索结果的视频链接 - const detailPageLink = $(searchResult[0]).attr('href') + var detailPageLink = $(searchResult[0]).attr('href') // 获取第一个搜索结果的title - const title = $(searchResult[0]).attr('title') + var title = $(searchResult[0]).attr('title') if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { // 如果第一个搜索结果不符合,打开搜索页面 open(url) } else { // 解析详情页面 - const detailPageFullLink = detailPageLink + var detailPageFullLink = detailPageLink axios.get(detailPageFullLink).then(res2 => { const $ = cheerio.load(res2.data) // 获取playlist1 - const e = $('#playlist1') + var e = $('#playlist1') // 获取所有视频链接 - const videoList = $(e).find('div>ul>li>a').toArray() + var videoList = $(e).find('div>ul>li>a').toArray() // 获取index视频链接 - let videoFullLink = detailPageFullLink + var videoFullLink = detailPageFullLink if (videoIndex < videoList.length) { - const indexVideoLink = $(videoList[videoIndex]).attr('href') + var indexVideoLink = $(videoList[videoIndex]).attr('href') videoFullLink = indexVideoLink } open(videoFullLink) diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index e769ecf..74207ac 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -7,12 +7,12 @@ import { Parser as M3u8Parser } from 'm3u8-parser' // axios使用系统代理 https://evandontje.com/2020/04/02/automatic-system-proxy-configuration-for-electron-applications/ // xgplayer使用chromium代理设置,浏览器又默认使用系统代理 https://www.chromium.org/developers/design-documents/network-settings // 要在设置中添加代理设置,可参考https://stackoverflow.com/questions/37393248/how-connect-to-proxy-in-electron-webview -const http = require('http') -const https = require('http') +var http = require('http') +var https = require('http') const { remote } = require('electron') -const win = remote.getCurrentWindow() -const session = win.webContents.session -const ElectronProxyAgent = require('electron-proxy-agent') +var win = remote.getCurrentWindow() +var session = win.webContents.session +var ElectronProxyAgent = require('electron-proxy-agent') // 请求超时时限 // axios.defaults.timeout = 10000 // 可能使用代理,增长超时 @@ -42,7 +42,7 @@ axios.interceptors.response.use(function (response) { }, function (err) { // 请求错误时做些事 // 请求超时的之后,抛出 err.code = ECONNABORTED的错误..错误信息是 timeout of xxx ms exceeded if (err.code === 'ECONNABORTED' && err.message.indexOf('timeout') !== -1) { - const config = err.config + var config = err.config config.__retryCount = config.__retryCount || 0 if (config.__retryCount >= config.retry) { @@ -52,7 +52,7 @@ axios.interceptors.response.use(function (response) { config.__retryCount += 1 - const backoff = new Promise(function (resolve) { + var backoff = new Promise(function (resolve) { setTimeout(function () { resolve() }, config.retryDelay || 1) @@ -204,7 +204,7 @@ const zy = { this.getSite(key).then(res => { const site = res wd = encodeURI(wd) - const url = `${site.api}?wd=${wd}` + var url = `${site.api}?wd=${wd}` axios.post(url, { timeout: 3000 }).then(res => { const data = res.data const json = parser.parse(data, this.xmlConfig) @@ -237,7 +237,7 @@ const zy = { const jsondata = json.rss === undefined ? json : json.rss const videoList = jsondata.list.video // Parse m3u8List - let m3u8List = [] + var m3u8List = [] let mp4List = [] const dd = videoList.dl.dd const type = Object.prototype.toString.call(dd) @@ -285,7 +285,7 @@ const zy = { const jsondata = json.rss === undefined ? json : json.rss const videoList = jsondata.list.video // Parse m3u8List - let m3u8List = [] + var m3u8List = [] const dd = videoList.dl.dd const type = Object.prototype.toString.call(dd) if (type === '[object Array]') { @@ -332,10 +332,10 @@ const zy = { return new Promise((resolve, reject) => { axios.get(channel).then(res => { const manifest = res.data - const parser = new M3u8Parser() + var parser = new M3u8Parser() parser.push(manifest) parser.end() - const parsedManifest = parser.manifest + var parsedManifest = parser.manifest if (parsedManifest.segments.length) { resolve(true) } else { @@ -355,16 +355,16 @@ const zy = { doubanLink (name, year) { return new Promise((resolve, reject) => { // 豆瓣搜索链接 - const nameToSearch = name.replace(/\s/g, '') - const doubanSearchLink = 'https://www.douban.com/search?q=' + nameToSearch + var nameToSearch = name.replace(/\s/g, '') + var doubanSearchLink = 'https://www.douban.com/search?q=' + nameToSearch axios.get(doubanSearchLink).then(res => { const $ = cheerio.load(res.data) // 查询所有搜索结果, 看名字和年代是否相符 - let link = '' + var link = '' $('div.result').each(function () { - const linkInDouban = $(this).find('div>div>h3>a').first() - const nameInDouban = linkInDouban.text().replace(/\s/g, '') - const subjectCast = $(this).find('span.subject-cast').text() + var linkInDouban = $(this).find('div>div>h3>a').first() + var nameInDouban = linkInDouban.text().replace(/\s/g, '') + var subjectCast = $(this).find('span.subject-cast').text() if (nameToSearch === nameInDouban && subjectCast && subjectCast.includes(year)) { link = linkInDouban.attr('href') } @@ -388,14 +388,14 @@ const zy = { */ doubanRate (name, year) { return new Promise((resolve, reject) => { - const nameToSearch = name.replace(/\s/g, '') + var nameToSearch = name.replace(/\s/g, '') this.doubanLink(nameToSearch, year).then(link => { if (link.includes('https://www.douban.com/search')) { resolve('暂无评分') } else { axios.get(link).then(response => { const parsedHtml = cheerio.load(response.data) - const rating = parsedHtml('body').find('#interest_sectl').first().find('strong').first() + var rating = parsedHtml('body').find('#interest_sectl').first().find('strong').first() if (rating.text()) { resolve(rating.text().replace(/\s/g, '')) } else {