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