mirror of
https://github.com/iptv-org/database.git
synced 2025-05-09 19:20:01 -04:00
Update scripts
This commit is contained in:
parent
e2a5105e69
commit
4d5c6fee64
7 changed files with 140 additions and 104 deletions
|
@ -3,3 +3,5 @@ export * from './issueParser'
|
|||
export * from './issueLoader'
|
||||
export * from './csvParser'
|
||||
export * from './idCreator'
|
||||
export * from './issueData'
|
||||
export * from './issue'
|
||||
|
|
19
scripts/core/issue.ts
Normal file
19
scripts/core/issue.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { IssueData } from './'
|
||||
|
||||
type IssueProps = {
|
||||
number: number
|
||||
labels: string[]
|
||||
data: IssueData
|
||||
}
|
||||
|
||||
export class Issue {
|
||||
number: number
|
||||
labels: string[]
|
||||
data: IssueData
|
||||
|
||||
constructor({ number, labels, data }: IssueProps) {
|
||||
this.number = number
|
||||
this.labels = labels
|
||||
this.data = data
|
||||
}
|
||||
}
|
40
scripts/core/issueData.ts
Normal file
40
scripts/core/issueData.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
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 | undefined {
|
||||
return this.missing(key) ? undefined : this._data.get(key)
|
||||
}
|
||||
|
||||
getString(key: string): string | undefined {
|
||||
const deleteSymbol = '~'
|
||||
|
||||
return this.missing(key)
|
||||
? undefined
|
||||
: this._data.get(key) === deleteSymbol
|
||||
? ''
|
||||
: this._data.get(key)
|
||||
}
|
||||
|
||||
getArray(key: string): string[] | undefined {
|
||||
const deleteSymbol = '~'
|
||||
|
||||
return this.missing(key)
|
||||
? undefined
|
||||
: this._data.get(key) === deleteSymbol
|
||||
? []
|
||||
: this._data.get(key).split(';')
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { Dictionary } from '@freearhey/core'
|
||||
import { Issue } from '../models'
|
||||
import { IssueData, Issue } from '../core'
|
||||
|
||||
const FIELDS = new Dictionary({
|
||||
'Channel ID': 'channel_id',
|
||||
|
@ -52,7 +52,8 @@ export class IssueParser {
|
|||
if (!_label || !_value) return data
|
||||
|
||||
const id: string = FIELDS.get(_label)
|
||||
const value: string = _value === '_No response_' || _value === 'None' ? '' : _value
|
||||
const value: string | undefined =
|
||||
_value === '_No response_' || _value === 'None' ? undefined : _value
|
||||
|
||||
if (!id) return
|
||||
|
||||
|
@ -61,6 +62,6 @@ export class IssueParser {
|
|||
|
||||
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) })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue