mirror of https://github.com/iptv-org/iptv
Update scripts
This commit is contained in:
parent
705f6ce28d
commit
1309696298
|
@ -4,7 +4,7 @@ import type { DataProcessorData } from '../../types/dataProcessor'
|
|||
import { Stream, Playlist, Channel, Issue } from '../../models'
|
||||
import type { DataLoaderData } from '../../types/dataLoader'
|
||||
import { DATA_DIR, STREAMS_DIR } from '../../constants'
|
||||
import validUrl from 'valid-url'
|
||||
import { isURI } from '../../utils'
|
||||
|
||||
let processedIssues = new Collection()
|
||||
|
||||
|
@ -158,7 +158,7 @@ async function addStreams({
|
|||
if (data.missing('streamId') || data.missing('streamUrl')) return
|
||||
if (streams.includes((_stream: Stream) => _stream.url === data.getString('streamUrl'))) return
|
||||
const streamUrl = data.getString('streamUrl') || ''
|
||||
if (!isUri(streamUrl)) return
|
||||
if (!isURI(streamUrl)) return
|
||||
|
||||
const streamId = data.getString('streamId') || ''
|
||||
const [channelId, feedId] = streamId.split('@')
|
||||
|
@ -192,7 +192,3 @@ async function addStreams({
|
|||
processedIssues.add(issue.number)
|
||||
})
|
||||
}
|
||||
|
||||
function isUri(string: string) {
|
||||
return validUrl.isUri(encodeURI(string))
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import { DataProcessorData } from '../../types/dataProcessor'
|
|||
import { DATA_DIR, STREAMS_DIR } from '../../constants'
|
||||
import { DataLoaderData } from '../../types/dataLoader'
|
||||
import { Issue, Stream } from '../../models'
|
||||
import { isURI } from '../../utils'
|
||||
|
||||
async function main() {
|
||||
const logger = new Logger()
|
||||
|
@ -44,7 +45,7 @@ async function main() {
|
|||
issue.labels.find((label: string) => label === 'streams:remove')
|
||||
)
|
||||
removeRequests.forEach((issue: Issue) => {
|
||||
const streamUrls = issue.data.has('streamUrl') ? issue.data.getArray('streamUrl') : []
|
||||
const streamUrls = issue.data.getArray('streamUrl') || []
|
||||
|
||||
if (!streamUrls.length) {
|
||||
const result = {
|
||||
|
@ -93,6 +94,7 @@ async function main() {
|
|||
|
||||
if (!channelId) result.status = 'missing_id'
|
||||
else if (!streamUrl) result.status = 'missing_link'
|
||||
else if (!isURI(streamUrl)) result.status = 'invalid_link'
|
||||
else if (blocklistRecordsGroupedByChannelId.has(channelId)) result.status = 'blocked'
|
||||
else if (channelsKeyById.missing(channelId)) result.status = 'wrong_id'
|
||||
else if (streamsGroupedByUrl.has(streamUrl)) result.status = 'on_playlist'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import validUrl from 'valid-url'
|
||||
|
||||
export function isURI(string: string) {
|
||||
return validUrl.isUri(encodeURI(string))
|
||||
}
|
Loading…
Reference in New Issue