mirror of
https://github.com/iptv-org/iptv
synced 2026-09-09 05:17:04 -04:00
Update scripts
This commit is contained in:
@@ -114,11 +114,12 @@ async function main() {
|
|||||||
streams = streams.sortBy(
|
streams = streams.sortBy(
|
||||||
[
|
[
|
||||||
(stream: Stream) => stream.title,
|
(stream: Stream) => stream.title,
|
||||||
|
(stream: Stream) => (stream.isGeoBlocked ? -1 : 0),
|
||||||
|
(stream: Stream) => (stream.isNot247 ? -1 : 0),
|
||||||
(stream: Stream) => stream.getVerticalResolution(),
|
(stream: Stream) => stream.getVerticalResolution(),
|
||||||
(stream: Stream) => stream.label,
|
|
||||||
(stream: Stream) => stream.url
|
(stream: Stream) => stream.url
|
||||||
],
|
],
|
||||||
['asc', 'desc', 'asc', 'asc']
|
['asc', 'desc', 'desc', 'desc', 'asc']
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info('saving...')
|
logger.info('saving...')
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ async function main() {
|
|||||||
streams = streams.sortBy(
|
streams = streams.sortBy(
|
||||||
[
|
[
|
||||||
(stream: Stream) => stream.getId(),
|
(stream: Stream) => stream.getId(),
|
||||||
(stream: Stream) => stream.getVerticalResolution(),
|
(stream: Stream) => (stream.isGeoBlocked ? -1 : 0),
|
||||||
(stream: Stream) => stream.label
|
(stream: Stream) => (stream.isNot247 ? -1 : 0),
|
||||||
|
(stream: Stream) => stream.getVerticalResolution()
|
||||||
],
|
],
|
||||||
['asc', 'desc', 'desc']
|
['asc', 'desc', 'desc', 'desc', 'asc']
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info('filtering streams...')
|
logger.info('filtering streams...')
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async function runTest(stream: Stream) {
|
|||||||
stream.statusCode = result.status.code
|
stream.statusCode = result.status.code
|
||||||
|
|
||||||
if (stream.statusCode === 'OK') return
|
if (stream.statusCode === 'OK') return
|
||||||
if (errorStatusCodes.includes(stream.statusCode) && !stream.label) {
|
if (errorStatusCodes.includes(stream.statusCode) && !stream.getLabels().length) {
|
||||||
errors++
|
errors++
|
||||||
} else {
|
} else {
|
||||||
warnings++
|
warnings++
|
||||||
@@ -128,7 +128,7 @@ function drawTable() {
|
|||||||
{ name: '', alignment: 'center', minLen: 3, maxLen: 3 },
|
{ name: '', alignment: 'center', minLen: 3, maxLen: 3 },
|
||||||
{ name: 'tvg-id', alignment: 'left', color: 'green', minLen: 25, maxLen: 25 },
|
{ name: 'tvg-id', alignment: 'left', color: 'green', minLen: 25, maxLen: 25 },
|
||||||
{ name: 'url', alignment: 'left', color: 'green', minLen: 100, maxLen: 100 },
|
{ name: 'url', alignment: 'left', color: 'green', minLen: 100, maxLen: 100 },
|
||||||
{ name: 'label', alignment: 'left', color: 'yellow', minLen: 13, maxLen: 13 },
|
{ name: 'labels', alignment: 'left', color: 'yellow', minLen: 13, maxLen: 13 },
|
||||||
{ name: 'status', alignment: 'left', minLen: 25, maxLen: 25 }
|
{ name: 'status', alignment: 'left', minLen: 25, maxLen: 25 }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -137,14 +137,14 @@ function drawTable() {
|
|||||||
const tvgId = truncate(stream.getTvgId(), 25)
|
const tvgId = truncate(stream.getTvgId(), 25)
|
||||||
const url = truncate(stream.url, 100)
|
const url = truncate(stream.url, 100)
|
||||||
const color = getColor(stream)
|
const color = getColor(stream)
|
||||||
const label = stream.label || ''
|
const labels = stream.getLabels().join(';')
|
||||||
const status = stream.statusCode || 'PENDING'
|
const status = stream.statusCode || 'PENDING'
|
||||||
|
|
||||||
const row = {
|
const row = {
|
||||||
'': index,
|
'': index,
|
||||||
'tvg-id': chalk[color](tvgId),
|
'tvg-id': chalk[color](tvgId),
|
||||||
url: chalk[color](url),
|
url: chalk[color](url),
|
||||||
label: chalk[color](label),
|
labels: chalk[color](labels),
|
||||||
status: chalk[color](status)
|
status: chalk[color](status)
|
||||||
}
|
}
|
||||||
table.append(row)
|
table.append(row)
|
||||||
@@ -208,14 +208,14 @@ function getColor(stream: Stream): string {
|
|||||||
if (!stream.statusCode) return 'gray'
|
if (!stream.statusCode) return 'gray'
|
||||||
if (stream.statusCode === 'LOADING...') return 'white'
|
if (stream.statusCode === 'LOADING...') return 'white'
|
||||||
if (stream.statusCode === 'OK') return 'green'
|
if (stream.statusCode === 'OK') return 'green'
|
||||||
if (errorStatusCodes.includes(stream.statusCode) && !stream.label) return 'red'
|
if (errorStatusCodes.includes(stream.statusCode) && !stream.getLabels().length) return 'red'
|
||||||
|
|
||||||
return 'yellow'
|
return 'yellow'
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBroken(stream: Stream): boolean {
|
function isBroken(stream: Stream): boolean {
|
||||||
if (!stream.statusCode) return false
|
if (!stream.statusCode) return false
|
||||||
if (stream.label) return false
|
if (stream.getLabels().length) return false
|
||||||
if (!errorStatusCodes.includes(stream.statusCode)) return false
|
if (!errorStatusCodes.includes(stream.statusCode)) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -261,9 +261,12 @@ async function addStream(issue: Issue) {
|
|||||||
user_agent: httpUserAgent,
|
user_agent: httpUserAgent,
|
||||||
referrer: httpReferrer,
|
referrer: httpReferrer,
|
||||||
quality,
|
quality,
|
||||||
label: data.getString('label') || ''
|
label: null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
stream.isNot247 = data.has('live_247') ? !data.getBoolean('live_247') : false
|
||||||
|
stream.isGeoBlocked = data.has('geo_blocked') ? data.getBoolean('geo_blocked') : false
|
||||||
|
|
||||||
stream.updateTitle().updateFilepath()
|
stream.updateTitle().updateFilepath()
|
||||||
|
|
||||||
stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))
|
stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ export class DataSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
missing(key: string): boolean {
|
missing(key: string): boolean {
|
||||||
return this._data.missing(key) || this._data.get(key) === undefined
|
const keys = Array.isArray(key) ? key : [key]
|
||||||
|
|
||||||
|
return keys.every(_key => this._data.get(_key) === undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
isDeleted(key: string): boolean {
|
isDeleted(key: string): boolean {
|
||||||
@@ -20,8 +22,10 @@ export class DataSet {
|
|||||||
return this._data.get(key) === deleteSymbol
|
return this._data.get(key) === deleteSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
getBoolean(key: string): boolean {
|
getBoolean(key: string): boolean | undefined {
|
||||||
return Boolean(this._data.get(key))
|
if (this.missing(key)) return undefined
|
||||||
|
|
||||||
|
return this._data.get(key) === 'TRUE' ? true : false
|
||||||
}
|
}
|
||||||
|
|
||||||
getString(key: string): string | undefined {
|
getString(key: string): string | undefined {
|
||||||
|
|||||||
+45
-22
@@ -14,6 +14,8 @@ export class Stream extends sdk.Models.Stream {
|
|||||||
tvgId?: string
|
tvgId?: string
|
||||||
statusCode?: string
|
statusCode?: string
|
||||||
guides = new Collection<sdk.Models.Guide>()
|
guides = new Collection<sdk.Models.Guide>()
|
||||||
|
isNot247?: boolean
|
||||||
|
isGeoBlocked?: boolean
|
||||||
|
|
||||||
setGuides(guides?: sdk.Models.Guide[]) {
|
setGuides(guides?: sdk.Models.Guide[]) {
|
||||||
this.guides = new Collection(guides)
|
this.guides = new Collection(guides)
|
||||||
@@ -48,47 +50,51 @@ export class Stream extends sdk.Models.Stream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const live247 = dataSet.getBoolean('live_247')
|
||||||
label: dataSet.isDeleted('label') ? '' : dataSet.getString('label'),
|
const geoBlocked = dataSet.getBoolean('geo_blocked')
|
||||||
quality: dataSet.isDeleted('quality') ? '' : dataSet.getString('quality'),
|
|
||||||
httpUserAgent: dataSet.isDeleted('http_user_agent')
|
|
||||||
? ''
|
|
||||||
: dataSet.getString('http_user_agent'),
|
|
||||||
httpReferrer: dataSet.isDeleted('http_referrer') ? '' : dataSet.getString('http_referrer')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.label !== undefined) this.label = data.label
|
if (live247) this.isNot247 = live247
|
||||||
if (data.quality !== undefined) this.quality = data.quality
|
if (geoBlocked) this.isGeoBlocked = geoBlocked
|
||||||
if (data.httpUserAgent !== undefined) this.user_agent = data.httpUserAgent
|
|
||||||
if (data.httpReferrer !== undefined) this.referrer = data.httpReferrer
|
const quality = dataSet.isDeleted('quality') ? '' : dataSet.getString('quality')
|
||||||
|
const httpUserAgent = dataSet.isDeleted('http_user_agent')
|
||||||
|
? ''
|
||||||
|
: dataSet.getString('http_user_agent')
|
||||||
|
const httpReferrer = dataSet.isDeleted('http_referrer')
|
||||||
|
? ''
|
||||||
|
: dataSet.getString('http_referrer')
|
||||||
|
|
||||||
|
if (quality !== undefined) this.quality = quality
|
||||||
|
if (httpUserAgent !== undefined) this.user_agent = httpUserAgent
|
||||||
|
if (httpReferrer !== undefined) this.referrer = httpReferrer
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromPlaylistItem(data: parser.PlaylistItem): Stream {
|
static fromPlaylistItem(data: parser.PlaylistItem): Stream {
|
||||||
function escapeRegExp(text) {
|
function escapeRegExp(text: string) {
|
||||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
|
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseName(name: string): {
|
function parseName(name: string): {
|
||||||
title: string
|
title: string
|
||||||
label: string
|
labels: string[]
|
||||||
quality: string
|
quality: string
|
||||||
} {
|
} {
|
||||||
let title = name
|
let title = name
|
||||||
const [, label] = title.match(/ \[(.*)\]$/) || [null, '']
|
const [, labels] = title.match(/ \[(.*)\]$/) || [null, '']
|
||||||
title = title.replace(new RegExp(` \\[${escapeRegExp(label)}\\]$`), '')
|
title = title.replace(new RegExp(` \\[${escapeRegExp(labels)}\\]$`), '')
|
||||||
const [, quality] = title.match(/ \(([0-9]+[p|i])\)$/) || [null, '']
|
const [, quality] = title.match(/ \(([0-9]+[p|i])\)$/) || [null, '']
|
||||||
title = title.replace(new RegExp(` \\(${quality}\\)$`), '')
|
title = title.replace(new RegExp(` \\(${quality}\\)$`), '')
|
||||||
|
|
||||||
return { title, label, quality }
|
return { title, labels: labels.split(';'), quality }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.name) throw new Error('"name" property is required')
|
if (!data.name) throw new Error('"name" property is required')
|
||||||
if (!data.url) throw new Error('"url" property is required')
|
if (!data.url) throw new Error('"url" property is required')
|
||||||
|
|
||||||
const [channelId, feedId] = data.tvg.id.split('@')
|
const [channelId, feedId] = data.tvg.id.split('@')
|
||||||
const { title, label, quality } = parseName(data.name)
|
const { title, labels, quality } = parseName(data.name)
|
||||||
|
|
||||||
const stream = new Stream({
|
const stream = new Stream({
|
||||||
channel: channelId || null,
|
channel: channelId || null,
|
||||||
@@ -98,11 +104,13 @@ export class Stream extends sdk.Models.Stream {
|
|||||||
url: data.url,
|
url: data.url,
|
||||||
referrer: data.http.referrer || null,
|
referrer: data.http.referrer || null,
|
||||||
user_agent: data.http['user-agent'] || null,
|
user_agent: data.http['user-agent'] || null,
|
||||||
label: label || null
|
label: null
|
||||||
})
|
})
|
||||||
|
|
||||||
stream.tvgId = data.tvg.id
|
stream.tvgId = data.tvg.id
|
||||||
stream.line = data.line
|
stream.line = data.line
|
||||||
|
stream.isNot247 = labels.includes('Not 24/7')
|
||||||
|
stream.isGeoBlocked = labels.includes('Geo-blocked')
|
||||||
|
|
||||||
return stream
|
return stream
|
||||||
}
|
}
|
||||||
@@ -416,13 +424,28 @@ export class Stream extends sdk.Models.Stream {
|
|||||||
title += ` (${this.quality})`
|
title += ` (${this.quality})`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.label) {
|
const labels = this.getLabels()
|
||||||
title += ` [${this.label}]`
|
|
||||||
|
if (labels.length) {
|
||||||
|
title += ` [${labels.join(';')}]`
|
||||||
}
|
}
|
||||||
|
|
||||||
return title
|
return title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLabels(): string[] {
|
||||||
|
let labels: string[] = []
|
||||||
|
if (this.isNot247 === true) {
|
||||||
|
labels.push('Not 24/7')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isGeoBlocked === true) {
|
||||||
|
labels.push('Geo-blocked')
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels
|
||||||
|
}
|
||||||
|
|
||||||
toString(options: { public?: boolean } = {}) {
|
toString(options: { public?: boolean } = {}) {
|
||||||
options = { ...{ public: false }, ...options }
|
options = { ...{ public: false }, ...options }
|
||||||
|
|
||||||
@@ -470,7 +493,7 @@ export class Stream extends sdk.Models.Stream {
|
|||||||
title: this.title,
|
title: this.title,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
quality: this.quality,
|
quality: this.quality,
|
||||||
label: this.label,
|
labels: this.getLabels(),
|
||||||
user_agent: this.user_agent,
|
user_agent: this.user_agent,
|
||||||
referrer: this.referrer
|
referrer: this.referrer
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -200,7 +200,8 @@ export function parseIssueBody(body: string): DataSet {
|
|||||||
'Channel ID': 'channel_id',
|
'Channel ID': 'channel_id',
|
||||||
'Feed ID': 'feed_id',
|
'Feed ID': 'feed_id',
|
||||||
'Stream URL': 'stream_url',
|
'Stream URL': 'stream_url',
|
||||||
Label: 'label',
|
'Live 24/7': 'live_247',
|
||||||
|
'Geo-blocked': 'geo_blocked',
|
||||||
Quality: 'quality',
|
Quality: 'quality',
|
||||||
'HTTP User-Agent': 'http_user_agent',
|
'HTTP User-Agent': 'http_user_agent',
|
||||||
'HTTP User Agent': 'http_user_agent',
|
'HTTP User Agent': 'http_user_agent',
|
||||||
@@ -223,7 +224,16 @@ export function parseIssueBody(body: string): DataSet {
|
|||||||
if (!_label || !_value) return data
|
if (!_label || !_value) return data
|
||||||
|
|
||||||
const id = FIELDS.get(_label)
|
const id = FIELDS.get(_label)
|
||||||
const value: string = _value === '_No response_' || _value === 'None' ? '' : _value
|
let value: string = ''
|
||||||
|
if (_value === '_No response_' || _value === 'None') {
|
||||||
|
value = ''
|
||||||
|
} else if (_value === 'Yes') {
|
||||||
|
value = 'TRUE'
|
||||||
|
} else if (_value === 'No') {
|
||||||
|
value = 'FALSE'
|
||||||
|
} else {
|
||||||
|
value = _value
|
||||||
|
}
|
||||||
|
|
||||||
if (!id) return
|
if (!id) return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user