mirror of https://github.com/iptv-org/iptv
Update scripts
parent
e18bdc87ab
commit
59133e92e8
@ -1,6 +1,6 @@
|
|||||||
import { Dictionary } from '@freearhey/core'
|
import { Dictionary } from '@freearhey/core'
|
||||||
|
|
||||||
export class IssueData {
|
export class DataSet {
|
||||||
_data: Dictionary<string>
|
_data: Dictionary<string>
|
||||||
constructor(data: Dictionary<string>) {
|
constructor(data: Dictionary<string>) {
|
||||||
this._data = data
|
this._data = data
|
||||||
@ -1,37 +0,0 @@
|
|||||||
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods'
|
|
||||||
import { paginateRest } from '@octokit/plugin-paginate-rest'
|
|
||||||
import { TESTING, OWNER, REPO } from '../constants'
|
|
||||||
import { Collection } from '@freearhey/core'
|
|
||||||
import { Octokit } from '@octokit/core'
|
|
||||||
import { IssueParser } from './'
|
|
||||||
|
|
||||||
const CustomOctokit = Octokit.plugin(paginateRest, restEndpointMethods)
|
|
||||||
const octokit = new CustomOctokit()
|
|
||||||
|
|
||||||
export class IssueLoader {
|
|
||||||
async load(props?: { labels: string | string[] }) {
|
|
||||||
let labels = ''
|
|
||||||
if (props && props.labels) {
|
|
||||||
labels = Array.isArray(props.labels) ? props.labels.join(',') : props.labels
|
|
||||||
}
|
|
||||||
let issues: object[] = []
|
|
||||||
if (TESTING) {
|
|
||||||
issues = (await import('../../tests/__data__/input/issues.js')).default
|
|
||||||
} else {
|
|
||||||
issues = await octokit.paginate(octokit.rest.issues.listForRepo, {
|
|
||||||
owner: OWNER,
|
|
||||||
repo: REPO,
|
|
||||||
per_page: 100,
|
|
||||||
labels,
|
|
||||||
status: 'open',
|
|
||||||
headers: {
|
|
||||||
'X-GitHub-Api-Version': '2022-11-28'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const parser = new IssueParser()
|
|
||||||
|
|
||||||
return new Collection(issues).map(parser.parse)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
import { Dictionary } from '@freearhey/core'
|
|
||||||
import { IssueData } from './issueData'
|
|
||||||
import { Issue } from '../models'
|
|
||||||
|
|
||||||
const FIELDS = new Dictionary({
|
|
||||||
'Stream ID': 'stream_id',
|
|
||||||
'Channel ID': 'channel_id',
|
|
||||||
'Feed ID': 'feed_id',
|
|
||||||
'Stream URL': 'stream_url',
|
|
||||||
Label: 'label',
|
|
||||||
Quality: 'quality',
|
|
||||||
'HTTP User-Agent': 'http_user_agent',
|
|
||||||
'HTTP User Agent': 'http_user_agent',
|
|
||||||
'HTTP Referrer': 'http_referrer',
|
|
||||||
'What happened to the stream?': 'reason',
|
|
||||||
Reason: 'reason',
|
|
||||||
Notes: 'notes'
|
|
||||||
})
|
|
||||||
|
|
||||||
export class IssueParser {
|
|
||||||
parse(issue: { number: number; body: string; labels: { name: string }[] }): Issue {
|
|
||||||
const fields = typeof issue.body === 'string' ? issue.body.split('###') : []
|
|
||||||
|
|
||||||
const data = new Dictionary<string>()
|
|
||||||
fields.forEach((field: string) => {
|
|
||||||
const parsed = typeof field === 'string' ? field.split(/\r?\n/).filter(Boolean) : []
|
|
||||||
let _label = parsed.shift()
|
|
||||||
_label = _label ? _label.replace(/ \(optional\)| \(required\)/, '').trim() : ''
|
|
||||||
let _value = parsed.join('\r\n')
|
|
||||||
_value = _value ? _value.trim() : ''
|
|
||||||
|
|
||||||
if (!_label || !_value) return data
|
|
||||||
|
|
||||||
const id = FIELDS.get(_label)
|
|
||||||
const value: string = _value === '_No response_' || _value === 'None' ? '' : _value
|
|
||||||
|
|
||||||
if (!id) return
|
|
||||||
|
|
||||||
data.set(id, value)
|
|
||||||
})
|
|
||||||
|
|
||||||
const labels = issue.labels.map(label => label.name)
|
|
||||||
|
|
||||||
return new Issue({ number: issue.number, labels, data: new IssueData(data) })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
import { DataSet } from '../core'
|
||||||
|
|
||||||
|
type DiscussionProps = {
|
||||||
|
number: number
|
||||||
|
category: string
|
||||||
|
data: DataSet
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Discussion {
|
||||||
|
number: number
|
||||||
|
category: string
|
||||||
|
data: DataSet
|
||||||
|
|
||||||
|
constructor({ number, category, data }: DiscussionProps) {
|
||||||
|
this.number = number
|
||||||
|
this.category = category
|
||||||
|
this.data = data
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
export * from './issue'
|
export * from './issue'
|
||||||
export * from './playlist'
|
export * from './playlist'
|
||||||
export * from './stream'
|
export * from './stream'
|
||||||
|
export * from './discussion'
|
||||||
|
|||||||
Loading…
Reference in New Issue