diff --git a/src/components/IPTV.vue b/src/components/IPTV.vue index 5794cfc..42e6116 100644 --- a/src/components/IPTV.vue +++ b/src/components/IPTV.vue @@ -176,7 +176,7 @@ export default { }, watch: { view () { - if (this.view === 'IPTV') { + if (this.view === 'IPTV' && !this.checkAllChannelsLoading) { this.getChannelList() } }, @@ -289,6 +289,7 @@ export default { ele.channels.splice(ele.channels.findIndex(e => e.id === row.id), 1) channelList.remove(row.channelID) if (ele.channels.length) { + if (ele.channels.length === 1) ele.hasChildren = false channelList.add(ele) this.$set(this.$refs.iptvTable.store.states.lazyTreeNodeMap, ele.id, ele.channels) } @@ -350,16 +351,19 @@ export default { const playlist = fs.readFileSync(file, { encoding: 'utf-8' }) const result = parser.parse(playlist) result.items.forEach(ele => { - if (ele.name && ele.url && new URL.URL(ele.url).pathname.endsWith('.m3u8')) { // 网址可能带参数 - var doc = { - id: id, - name: ele.name, - url: ele.url, - isActive: true + const urls = ele.url.split('#').filter(e => e.startsWith('http')) // 网址带#时自动分割 + urls.forEach(url => { + if (ele.name && url && new URL.URL(url).pathname.endsWith('.m3u8')) { // 网址可能带参数 + var doc = { + id: id, + name: ele.name, + url: url, + isActive: true + } + id += 1 + docs.push(doc) } - id += 1 - docs.push(doc) - } + }) }) // 获取url不重复的列表 const uniqueList = [...new Map(docs.map(item => [item.url, item])).values()] @@ -465,8 +469,8 @@ export default { iptv.clear() // iptv默认清空状态 }) }, - getChannelList () { - channelList.all().then(res => { + async getChannelList () { + await channelList.all().then(res => { this.channelList = res this.getIptvList() }) @@ -512,6 +516,7 @@ export default { ele.channels.forEach((e, index) => { e.id = embedChannelID + index }) // 为避免混杂,给内置iptv重起id if (prefer) ele.prefer = prefer.id }) + if (ele.channels.length === 1) ele.hasChildren = false }) }, rowDrop () { @@ -545,13 +550,13 @@ export default { this.checkAllChannelsLoading = true this.stopFlag = false this.checkProgress = 0 - this.channelList.forEach(e => { e.status = ' '; e.hasCheckedNum = 0 }) + this.channelList.filter(e => e.channels.length).forEach(e => { e.status = ' '; e.hasCheckedNum = 0 }) const uncheckedList = this.iptvList.filter(e => e.status === undefined || e.status === ' ') // 未检测过的优先 const other = this.iptvList.filter(e => !uncheckedList.includes(e)) await this.checkChannelsBySite(uncheckedList) await this.checkChannelsBySite(other).then(res => { this.checkAllChannelsLoading = false - this.updateChannelList() + this.getChannelList() }) }, async checkChannelsBySite (channels) { @@ -573,6 +578,10 @@ export default { } }, async checkSingleChannel (channel) { + if (this.setting.allowPassWhenIptvCheck && !channel.isActive) { + this.checkProgress += 1 + return + } channel.status = ' ' const ele = this.channelList.find(e => e.id === channel.channelID) if (this.stopFlag) { @@ -587,12 +596,17 @@ export default { } else { channel.status = '失效' channel.isActive = false + if (this.setting.autocleanWhenIptvCheck) { + ele.channels.splice(ele.channels.findIndex(e => e.id === channel.id), 1) + ele.hasCheckedNum-- + } } if (ele.hasCheckedNum === ele.channels.length) { ele.status = ele.channels.some(channel => channel.status === '可用') ? '可用' : '失效' if (ele.status === '失效') ele.isActive = false channelList.remove(channel.channelID) - channelList.add(ele) + if (ele.channels.length === 1) ele.hasChildren = false + if (ele.channels.length) channelList.add(ele) } return channel.status }, @@ -610,8 +624,8 @@ export default { addEventListener('keydown', code => { if (code.keyCode === 16) this.shiftDown = true }) addEventListener('keyup', code => { if (code.keyCode === 16) this.shiftDown = false }) }, - created () { - this.getChannelList() + async created () { + await this.getChannelList() if (!this.channelList.length) this.resetChannelsEvent() } } diff --git a/src/components/Setting.vue b/src/components/Setting.vue index 4cca9f4..e657102 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -78,6 +78,12 @@