mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Update scripts
This commit is contained in:
parent
96cb43c398
commit
9b4c7325ee
6 changed files with 63 additions and 29 deletions
|
@ -56,7 +56,7 @@ async function removeStreams(loader: IssueLoader) {
|
||||||
const data = issue.data
|
const data = issue.data
|
||||||
if (data.missing('broken_links')) return
|
if (data.missing('broken_links')) return
|
||||||
|
|
||||||
const brokenLinks = data.get('broken_links').split(/\r?\n/).filter(Boolean)
|
const brokenLinks = data.getString('broken_links').split(/\r?\n/).filter(Boolean)
|
||||||
|
|
||||||
let changed = false
|
let changed = false
|
||||||
brokenLinks.forEach(link => {
|
brokenLinks.forEach(link => {
|
||||||
|
@ -79,27 +79,27 @@ async function editStreams(loader: IssueLoader) {
|
||||||
if (data.missing('stream_url')) return
|
if (data.missing('stream_url')) return
|
||||||
|
|
||||||
let stream = streams.first(
|
let stream = streams.first(
|
||||||
(_stream: Stream) => _stream.url === data.get('stream_url')
|
(_stream: Stream) => _stream.url === data.getString('stream_url')
|
||||||
) as Stream
|
) as Stream
|
||||||
|
|
||||||
if (!stream) return
|
if (!stream) return
|
||||||
|
|
||||||
if (data.has('channel_id')) {
|
if (data.has('channel_id')) {
|
||||||
const channel = groupedChannels.get(data.get('channel_id'))
|
const channel = groupedChannels.get(data.getString('channel_id'))
|
||||||
|
|
||||||
if (!channel) return
|
if (!channel) return
|
||||||
|
|
||||||
stream.channel = data.get('channel_id')
|
stream.channel = data.getString('channel_id')
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.has('label')) stream.label = data.get('label')
|
if (data.has('label')) stream.label = data.getString('label')
|
||||||
if (data.has('quality')) stream.quality = data.get('quality')
|
if (data.has('quality')) stream.quality = data.getString('quality')
|
||||||
if (data.has('timeshift')) stream.timeshift = data.get('timeshift')
|
if (data.has('timeshift')) stream.timeshift = data.getString('timeshift')
|
||||||
if (data.has('user_agent')) stream.userAgent = data.get('user_agent')
|
if (data.has('user_agent')) stream.userAgent = data.getString('user_agent')
|
||||||
if (data.has('http_referrer')) stream.httpReferrer = data.get('http_referrer')
|
if (data.has('http_referrer')) stream.httpReferrer = data.getString('http_referrer')
|
||||||
|
|
||||||
processedIssues.add(issue.number)
|
processedIssues.add(issue.number)
|
||||||
})
|
})
|
||||||
|
@ -110,24 +110,24 @@ async function addStreams(loader: IssueLoader) {
|
||||||
issues.forEach((issue: Issue) => {
|
issues.forEach((issue: Issue) => {
|
||||||
const data = issue.data
|
const data = issue.data
|
||||||
if (data.missing('channel_id') || data.missing('stream_url')) return
|
if (data.missing('channel_id') || data.missing('stream_url')) return
|
||||||
if (streams.includes((_stream: Stream) => _stream.url === data.get('stream_url'))) return
|
if (streams.includes((_stream: Stream) => _stream.url === data.getString('stream_url'))) return
|
||||||
if (!validUrl.isUri(data.get('stream_url'))) return
|
if (!validUrl.isUri(data.getString('stream_url'))) return
|
||||||
|
|
||||||
const channel = groupedChannels.get(data.get('channel_id'))
|
const channel = groupedChannels.get(data.getString('channel_id'))
|
||||||
|
|
||||||
if (!channel) return
|
if (!channel) return
|
||||||
|
|
||||||
const stream = new Stream({
|
const stream = new Stream({
|
||||||
channel: data.get('channel_id'),
|
channel: data.getString('channel_id'),
|
||||||
url: data.get('stream_url'),
|
url: data.getString('stream_url'),
|
||||||
label: data.get('label'),
|
label: data.getString('label'),
|
||||||
quality: data.get('quality'),
|
quality: data.getString('quality'),
|
||||||
timeshift: data.get('timeshift'),
|
timeshift: data.getString('timeshift'),
|
||||||
userAgent: data.get('user_agent'),
|
userAgent: data.getString('user_agent'),
|
||||||
httpReferrer: data.get('http_referrer'),
|
httpReferrer: data.getString('http_referrer'),
|
||||||
filepath: `${channel.country.toLowerCase()}.m3u`,
|
filepath: `${channel.country.toLowerCase()}.m3u`,
|
||||||
line: -1,
|
line: -1,
|
||||||
name: data.get('channel_name') || channel.name
|
name: data.getString('channel_name') || channel.name
|
||||||
})
|
})
|
||||||
|
|
||||||
streams.add(stream)
|
streams.add(stream)
|
||||||
|
|
|
@ -35,8 +35,8 @@ async function main() {
|
||||||
const addRequests = await loader.load({ labels: ['streams:add'] })
|
const addRequests = await loader.load({ labels: ['streams:add'] })
|
||||||
const buffer = new Dictionary()
|
const buffer = new Dictionary()
|
||||||
addRequests.forEach((issue: Issue) => {
|
addRequests.forEach((issue: Issue) => {
|
||||||
const channelId = issue.data.get('channel_id') || undefined
|
const channelId = issue.data.getString('channel_id') || undefined
|
||||||
const streamUrl = issue.data.get('stream_url') || undefined
|
const streamUrl = issue.data.getString('stream_url')
|
||||||
|
|
||||||
const result = new Dictionary({
|
const result = new Dictionary({
|
||||||
issueNumber: issue.number,
|
issueNumber: issue.number,
|
||||||
|
@ -61,8 +61,8 @@ async function main() {
|
||||||
logger.info('checking streams:edit requests...')
|
logger.info('checking streams:edit requests...')
|
||||||
const editRequests = await loader.load({ labels: ['streams:edit'] })
|
const editRequests = await loader.load({ labels: ['streams:edit'] })
|
||||||
editRequests.forEach((issue: Issue) => {
|
editRequests.forEach((issue: Issue) => {
|
||||||
const channelId = issue.data.get('channel_id') || undefined
|
const channelId = issue.data.getString('channel_id') || undefined
|
||||||
const streamUrl = issue.data.get('stream_url') || undefined
|
const streamUrl = issue.data.getString('stream_url') || undefined
|
||||||
|
|
||||||
const result = new Dictionary({
|
const result = new Dictionary({
|
||||||
issueNumber: issue.number,
|
issueNumber: issue.number,
|
||||||
|
@ -82,7 +82,7 @@ async function main() {
|
||||||
logger.info('checking broken streams reports...')
|
logger.info('checking broken streams reports...')
|
||||||
const brokenStreamReports = await loader.load({ labels: ['broken stream'] })
|
const brokenStreamReports = await loader.load({ labels: ['broken stream'] })
|
||||||
brokenStreamReports.forEach((issue: Issue) => {
|
brokenStreamReports.forEach((issue: Issue) => {
|
||||||
const brokenLinks = issue.data.get('broken_links') || undefined
|
const brokenLinks = issue.data.getString('broken_links') || undefined
|
||||||
|
|
||||||
const result = new Dictionary({
|
const result = new Dictionary({
|
||||||
issueNumber: issue.number,
|
issueNumber: issue.number,
|
||||||
|
|
|
@ -6,3 +6,4 @@ export * from './issueLoader'
|
||||||
export * from './issueParser'
|
export * from './issueParser'
|
||||||
export * from './htmlTable'
|
export * from './htmlTable'
|
||||||
export * from './apiClient'
|
export * from './apiClient'
|
||||||
|
export * from './issueData'
|
||||||
|
|
32
scripts/core/issueData.ts
Normal file
32
scripts/core/issueData.ts
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import { Dictionary } from '@freearhey/core'
|
||||||
|
|
||||||
|
export class IssueData {
|
||||||
|
_data: Dictionary
|
||||||
|
constructor(data: Dictionary) {
|
||||||
|
this._data = data
|
||||||
|
}
|
||||||
|
|
||||||
|
has(key: string): boolean {
|
||||||
|
return this._data.has(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
missing(key: string): boolean {
|
||||||
|
return this._data.missing(key) || this._data.get(key) === undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
getBoolean(key: string): boolean {
|
||||||
|
return Boolean(this._data.get(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
getString(key: string): string {
|
||||||
|
const deleteSymbol = '~'
|
||||||
|
|
||||||
|
return this._data.get(key) === deleteSymbol ? '' : this._data.get(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
getArray(key: string): string[] {
|
||||||
|
const deleteSymbol = '~'
|
||||||
|
|
||||||
|
return this._data.get(key) === deleteSymbol ? [] : this._data.get(key).split(';')
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import { Dictionary } from '@freearhey/core'
|
import { Dictionary } from '@freearhey/core'
|
||||||
import { Issue } from '../models'
|
import { Issue } from '../models'
|
||||||
|
import { IssueData } from './issueData'
|
||||||
|
|
||||||
const FIELDS = new Dictionary({
|
const FIELDS = new Dictionary({
|
||||||
'Channel ID': 'channel_id',
|
'Channel ID': 'channel_id',
|
||||||
|
@ -46,6 +47,6 @@ export class IssueParser {
|
||||||
|
|
||||||
const labels = issue.labels.map(label => label.name)
|
const labels = issue.labels.map(label => label.name)
|
||||||
|
|
||||||
return new Issue({ number: issue.number, labels, data })
|
return new Issue({ number: issue.number, labels, data: new IssueData(data) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { Dictionary } from '@freearhey/core'
|
import { IssueData } from '../core'
|
||||||
|
|
||||||
type IssueProps = {
|
type IssueProps = {
|
||||||
number: number
|
number: number
|
||||||
labels: string[]
|
labels: string[]
|
||||||
data: Dictionary
|
data: IssueData
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Issue {
|
export class Issue {
|
||||||
number: number
|
number: number
|
||||||
labels: string[]
|
labels: string[]
|
||||||
data: Dictionary
|
data: IssueData
|
||||||
|
|
||||||
constructor({ number, labels, data }: IssueProps) {
|
constructor({ number, labels, data }: IssueProps) {
|
||||||
this.number = number
|
this.number = number
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue