mirror of
https://github.com/iptv-org/iptv
synced 2026-09-06 03:50:47 -04:00
Merge pull request #48471 from iptv-org/patch-2026.08.2
Patch 2026.08.2
This commit is contained in:
@@ -17,7 +17,7 @@ const { body, labels } = program.opts()
|
||||
|
||||
const logsStorage = new Storage(LOGS_DIR)
|
||||
let streams = new Collection<Stream>()
|
||||
const errors: string[] = []
|
||||
let errors: string[] = []
|
||||
|
||||
async function main() {
|
||||
const logger = new Logger()
|
||||
@@ -30,30 +30,89 @@ async function main() {
|
||||
|
||||
const data = parseIssueBody(body)
|
||||
if (labels.includes('streams:add')) {
|
||||
if (data.missing('stream_id')) {
|
||||
const streamId = data.getString('stream_id')
|
||||
if (!streamId) {
|
||||
errors.push('The request is missing the "Stream ID"')
|
||||
done()
|
||||
} else {
|
||||
errors = errors.concat(validateStreamId(streamId))
|
||||
}
|
||||
|
||||
const streamUrl = data.getString('stream_url')
|
||||
if (!streamUrl) {
|
||||
errors.push('The request is missing the "Stream URL"')
|
||||
done()
|
||||
} else if (!isURI(streamUrl) || !hasValidDomain(streamUrl)) {
|
||||
errors.push(`The stream URL "${streamUrl}" is invalid`)
|
||||
}
|
||||
} else {
|
||||
errors = errors.concat(validateStreamUrl(streamUrl))
|
||||
|
||||
if (streams.includes((_stream: Stream) => _stream.url === streamUrl)) {
|
||||
errors.push(`The stream with the URL "${streamUrl}" is already included in the playlists`)
|
||||
}
|
||||
}
|
||||
} else if (labels.includes('streams:remove')) {
|
||||
const streamUrls = data.getString('stream_url') || ''
|
||||
if (!streamUrls) {
|
||||
errors.push('The request is missing the "Stream URL"')
|
||||
done()
|
||||
}
|
||||
|
||||
streamUrls
|
||||
.split(/\r?\n/)
|
||||
.filter(Boolean)
|
||||
.forEach((link: string) => {
|
||||
errors = errors.concat(validateStreamUrl(link))
|
||||
|
||||
const found: Stream = streams.first((_stream: Stream) => _stream.url === link.trim())
|
||||
if (!found) {
|
||||
errors.push(`The stream with the URL "${link}" is missing from the playlists`)
|
||||
}
|
||||
})
|
||||
} else if (labels.includes('streams:edit')) {
|
||||
const streamUrl = data.getString('stream_url')
|
||||
|
||||
if (!streamUrl) {
|
||||
errors.push('The request is missing the "Stream URL"')
|
||||
done()
|
||||
} else {
|
||||
const stream: Stream = streams.first((_stream: Stream) => _stream.url === streamUrl)
|
||||
if (!stream) {
|
||||
errors.push(`The stream with the URL "${streamUrl}" is missing from the playlists`)
|
||||
}
|
||||
}
|
||||
|
||||
const streamId = data.getString('stream_id')
|
||||
if (streamId) {
|
||||
errors = errors.concat(validateStreamId(streamId))
|
||||
}
|
||||
}
|
||||
|
||||
done()
|
||||
}
|
||||
|
||||
function validateStreamUrl(streamUrl: string): string[] {
|
||||
const errors: string[] = []
|
||||
|
||||
if (!isURI(streamUrl) || !hasValidDomain(streamUrl)) {
|
||||
errors.push(`The stream URL "${streamUrl}" is invalid`)
|
||||
}
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
function validateStreamId(streamId: string): string[] {
|
||||
const errors: string[] = []
|
||||
|
||||
const streamId = data.getString('stream_id') || ''
|
||||
const [channelId, feedId] = streamId.split('@')
|
||||
|
||||
if (!channelId) {
|
||||
errors.push('The request is missing the channel ID')
|
||||
return errors
|
||||
} else {
|
||||
const channel: sdk.Models.Channel | undefined = apiData.channelsKeyById.get(channelId)
|
||||
if (!channel) {
|
||||
errors.push(`There is no channel with the ID "${channelId}" in the database`)
|
||||
done()
|
||||
return errors
|
||||
}
|
||||
}
|
||||
|
||||
const blocklistRecords: sdk.Models.BlocklistRecord[] | undefined =
|
||||
@@ -72,50 +131,18 @@ async function main() {
|
||||
})
|
||||
}
|
||||
|
||||
if (!feedId) {
|
||||
errors.push('The request is missing the feed ID')
|
||||
} else {
|
||||
const feed: sdk.Models.Feed | undefined = apiData.feedsKeyByStreamId.get(streamId)
|
||||
if (!feed) {
|
||||
errors.push(
|
||||
`There is no feed with the ID "${feedId}" for the "${channelId}" channel in the database`
|
||||
)
|
||||
}
|
||||
} else if (labels.includes('streams:remove')) {
|
||||
const streamUrls = data.getString('stream_url') || ''
|
||||
if (!streamUrls) {
|
||||
errors.push('The request is missing the "Stream URL"')
|
||||
done()
|
||||
}
|
||||
|
||||
streamUrls
|
||||
.split(/\r?\n/)
|
||||
.filter(Boolean)
|
||||
.forEach((link: string) => {
|
||||
if (!isURI(link) || !hasValidDomain(link)) {
|
||||
errors.push(`The stream URL "${link}" is invalid`)
|
||||
}
|
||||
|
||||
const found: Stream = streams.first((_stream: Stream) => _stream.url === link.trim())
|
||||
if (!found) {
|
||||
errors.push(`The stream with the URL "${link}" is missing from the playlists`)
|
||||
}
|
||||
})
|
||||
} else if (labels.includes('streams:edit')) {
|
||||
const streamUrl = data.getString('stream_url')
|
||||
|
||||
if (!streamUrl) {
|
||||
errors.push('The request is missing the "Stream URL"')
|
||||
done()
|
||||
} else if (!isURI(streamUrl) || !hasValidDomain(streamUrl)) {
|
||||
errors.push(`The stream URL "${streamUrl}" is invalid`)
|
||||
done()
|
||||
}
|
||||
|
||||
const stream: Stream = streams.first((_stream: Stream) => _stream.url === streamUrl)
|
||||
if (!stream) {
|
||||
errors.push(`The stream with the URL "${streamUrl}" is missing from the playlists`)
|
||||
}
|
||||
}
|
||||
|
||||
done()
|
||||
return errors
|
||||
}
|
||||
|
||||
function done() {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
The request contains error(s):
|
||||
- There is no feed with the ID "undefined" for the "ManoramaNews.in" channel in the database
|
||||
- The request is missing the feed ID
|
||||
@@ -1,2 +1,3 @@
|
||||
The request contains error(s):
|
||||
- The stream with the URL "https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8" is missing from the playlists
|
||||
- There is no channel with the ID "boo.us" in the database
|
||||
Reference in New Issue
Block a user