Update scripts

This commit is contained in:
freearhey 2025-03-09 19:53:25 +03:00
parent a14ef9181a
commit 970b74aef2
5 changed files with 51 additions and 47 deletions

View file

@ -60,9 +60,9 @@ async function removeStreams(loader: IssueLoader) {
)
requests.forEach((issue: Issue) => {
const data = issue.data
if (data.missing('broken_links')) return
if (data.missing('brokenLinks')) return
const brokenLinks = data.getString('broken_links').split(/\r?\n/).filter(Boolean)
const brokenLinks = data.getString('brokenLinks').split(/\r?\n/).filter(Boolean)
let changed = false
brokenLinks.forEach(link => {
@ -84,20 +84,20 @@ async function editStreams(loader: IssueLoader) {
requests.forEach((issue: Issue) => {
const data = issue.data
if (data.missing('stream_url')) return
if (data.missing('streamUrl')) return
let stream = streams.first(
(_stream: Stream) => _stream.url === data.getString('stream_url')
(_stream: Stream) => _stream.url === data.getString('streamUrl')
) as Stream
if (!stream) return
if (data.has('channel_id')) {
const channel = groupedChannels.get(data.getString('channel_id'))
if (data.has('channelId')) {
const channel = groupedChannels.get(data.getString('channelId'))
if (!channel) return
stream.channel = data.getString('channel_id')
stream.channel = data.getString('channelId')
stream.filepath = `${channel.country.toLowerCase()}.m3u`
stream.line = -1
stream.name = channel.name
@ -105,8 +105,8 @@ async function editStreams(loader: IssueLoader) {
if (data.has('label')) stream.label = data.getString('label')
if (data.has('quality')) stream.quality = data.getString('quality')
if (data.has('user_agent')) stream.userAgent = data.getString('user_agent')
if (data.has('http_referrer')) stream.httpReferrer = data.getString('http_referrer')
if (data.has('httpUserAgent')) stream.httpUserAgent = data.getString('httpUserAgent')
if (data.has('httpReferrer')) stream.httpReferrer = data.getString('httpReferrer')
processedIssues.add(issue.number)
})
@ -118,24 +118,24 @@ async function addStreams(loader: IssueLoader) {
)
requests.forEach((issue: Issue) => {
const data = issue.data
if (data.missing('channel_id') || data.missing('stream_url')) return
if (streams.includes((_stream: Stream) => _stream.url === data.getString('stream_url'))) return
if (!validUrl.isUri(data.getString('stream_url'))) return
if (data.missing('channelId') || data.missing('streamUrl')) return
if (streams.includes((_stream: Stream) => _stream.url === data.getString('streamUrl'))) return
if (!validUrl.isUri(data.getString('streamUrl'))) return
const channel = groupedChannels.get(data.getString('channel_id'))
const channel = groupedChannels.get(data.getString('channelId'))
if (!channel) return
const stream = new Stream({
channel: data.getString('channel_id'),
url: data.getString('stream_url'),
channel: data.getString('channelId'),
url: data.getString('streamUrl'),
label: data.getString('label'),
quality: data.getString('quality'),
userAgent: data.getString('user_agent'),
httpReferrer: data.getString('http_referrer'),
httpUserAgent: data.getString('httpUserAgent'),
httpReferrer: data.getString('httpReferrer'),
filepath: `${channel.country.toLowerCase()}.m3u`,
line: -1,
name: data.getString('channel_name') || channel.name
name: data.getString('channelName') || channel.name
})
streams.add(stream)

View file

@ -38,8 +38,8 @@ async function main() {
const addRequests = issues.filter(issue => issue.labels.includes('streams:add'))
const addRequestsBuffer = new Dictionary()
addRequests.forEach((issue: Issue) => {
const channelId = issue.data.getString('channel_id') || undefined
const streamUrl = issue.data.getString('stream_url')
const channelId = issue.data.getString('channelId') || undefined
const streamUrl = issue.data.getString('streamUrl')
const result = new Dictionary({
issueNumber: issue.number,
@ -65,8 +65,8 @@ async function main() {
logger.info('checking streams:edit requests...')
const editRequests = issues.filter(issue => issue.labels.find(label => label === 'streams:edit'))
editRequests.forEach((issue: Issue) => {
const channelId = issue.data.getString('channel_id') || undefined
const streamUrl = issue.data.getString('stream_url') || undefined
const channelId = issue.data.getString('channelId') || undefined
const streamUrl = issue.data.getString('streamUrl') || undefined
const result = new Dictionary({
issueNumber: issue.number,
@ -88,7 +88,7 @@ async function main() {
issue.labels.find(label => label === 'broken stream')
)
brokenStreamReports.forEach((issue: Issue) => {
const brokenLinks = issue.data.getArray('broken_links') || []
const brokenLinks = issue.data.getArray('brokenLinks') || []
if (!brokenLinks.length) {
const result = new Dictionary({
@ -126,7 +126,7 @@ async function main() {
)
const channelSearchRequestsBuffer = new Dictionary()
channelSearchRequests.forEach((issue: Issue) => {
const channelId = issue.data.getString('channel_id')
const channelId = issue.data.getString('channelId')
const result = new Dictionary({
issueNumber: issue.number,

View file

@ -3,19 +3,19 @@ import { Issue } from '../models'
import { IssueData } from './issueData'
const FIELDS = new Dictionary({
'Channel ID': 'channel_id',
'Channel ID (required)': 'channel_id',
'Stream URL': 'stream_url',
'Stream URL (optional)': 'stream_url',
'Stream URL (required)': 'stream_url',
'Broken Link': 'broken_links',
'Broken Links': 'broken_links',
'Channel ID': 'channelId',
'Channel ID (required)': 'channelId',
'Stream URL': 'streamUrl',
'Stream URL (optional)': 'streamUrl',
'Stream URL (required)': 'streamUrl',
'Broken Link': 'brokenLinks',
'Broken Links': 'brokenLinks',
Label: 'label',
Quality: 'quality',
'Channel Name': 'channel_name',
'HTTP User-Agent': 'user_agent',
'HTTP User Agent': 'user_agent',
'HTTP Referrer': 'http_referrer',
'Channel Name': 'channelName',
'HTTP User-Agent': 'httpUserAgent',
'HTTP User Agent': 'httpUserAgent',
'HTTP Referrer': 'httpReferrer',
'What happened to the stream?': 'reason',
Reason: 'reason',
Notes: 'notes',

View file

@ -40,7 +40,7 @@ export class PlaylistParser {
line: item.line,
url: item.url,
httpReferrer: item.http.referrer,
userAgent: item.http['user-agent']
httpUserAgent: item.http['user-agent']
})
streams.add(stream)

View file

@ -8,9 +8,9 @@ type StreamProps = {
line: number
channel?: string
httpReferrer?: string
httpUserAgent?: string
label?: string
quality?: string
userAgent?: string
}
export class Stream {
@ -22,7 +22,7 @@ export class Stream {
name: string
quality: string
url: string
userAgent: string
httpUserAgent: string
logo: string
broadcastArea: Collection
categories: Collection
@ -40,7 +40,7 @@ export class Stream {
name,
quality,
url,
userAgent
httpUserAgent
}: StreamProps) {
this.channel = channel || ''
this.filepath = filepath
@ -50,7 +50,7 @@ export class Stream {
this.name = name
this.quality = quality || ''
this.url = url
this.userAgent = userAgent || ''
this.httpUserAgent = httpUserAgent || ''
this.logo = ''
this.broadcastArea = new Collection()
this.categories = new Collection()
@ -136,7 +136,7 @@ export class Stream {
name: this.name,
quality: this.quality,
url: this.url,
userAgent: this.userAgent,
httpUserAgent: this.httpUserAgent,
line: this.line
}
}
@ -145,8 +145,8 @@ export class Stream {
return {
channel: this.channel || null,
url: this.url,
http_referrer: this.httpReferrer || null,
user_agent: this.userAgent || null
referrer: this.httpReferrer || null,
user_agent: this.httpUserAgent || null
}
}
@ -157,8 +157,12 @@ export class Stream {
output += ` tvg-logo="${this.logo}" group-title="${this.groupTitle}"`
}
if (this.userAgent) {
output += ` user-agent="${this.userAgent}"`
if (this.httpReferrer) {
output += ` http-referrer="${this.httpReferrer}"`
}
if (this.httpUserAgent) {
output += ` http-user-agent="${this.httpUserAgent}"`
}
output += `,${this.getTitle()}`
@ -167,8 +171,8 @@ export class Stream {
output += `\n#EXTVLCOPT:http-referrer=${this.httpReferrer}`
}
if (this.userAgent) {
output += `\n#EXTVLCOPT:http-user-agent=${this.userAgent}`
if (this.httpUserAgent) {
output += `\n#EXTVLCOPT:http-user-agent=${this.httpUserAgent}`
}
output += `\n${this.url}`