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

View file

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

View file

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

View file

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

View file

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