mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 18:37:17 -05:00
Update scripts
This commit is contained in:
@@ -73,7 +73,7 @@ export default async function main(filepath: string) {
|
|||||||
logger.info('creating search index...')
|
logger.info('creating search index...')
|
||||||
const items = channels.map((channel: Channel) => channel.getSearchable()).all()
|
const items = channels.map((channel: Channel) => channel.getSearchable()).all()
|
||||||
const searchIndex = sjs.createIndex(items, {
|
const searchIndex = sjs.createIndex(items, {
|
||||||
searchable: ['name', 'altNames', 'guideNames', 'streamNames', 'feedFullNames']
|
searchable: ['name', 'altNames', 'guideNames', 'streamTitles', 'feedFullNames']
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.info('starting...\n')
|
logger.info('starting...\n')
|
||||||
@@ -100,7 +100,7 @@ async function selectChannel(
|
|||||||
feedsGroupedByChannelId: Dictionary,
|
feedsGroupedByChannelId: Dictionary,
|
||||||
channelsKeyById: Dictionary
|
channelsKeyById: Dictionary
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const query = escapeRegex(stream.getName())
|
const query = escapeRegex(stream.getTitle())
|
||||||
const similarChannels = searchIndex
|
const similarChannels = searchIndex
|
||||||
.search(query)
|
.search(query)
|
||||||
.map((item: ChannelSearchableData) => channelsKeyById.get(item.id))
|
.map((item: ChannelSearchableData) => channelsKeyById.get(item.id))
|
||||||
@@ -108,7 +108,7 @@ async function selectChannel(
|
|||||||
const url = stream.url.length > 50 ? stream.url.slice(0, 50) + '...' : stream.url
|
const url = stream.url.length > 50 ? stream.url.slice(0, 50) + '...' : stream.url
|
||||||
|
|
||||||
const selected: ChoiceValue = await select({
|
const selected: ChoiceValue = await select({
|
||||||
message: `Select channel ID for "${stream.name}" (${url}):`,
|
message: `Select channel ID for "${stream.title}" (${url}):`,
|
||||||
choices: getChannelChoises(new Collection(similarChannels)),
|
choices: getChannelChoises(new Collection(similarChannels)),
|
||||||
pageSize: 10
|
pageSize: 10
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ async function main() {
|
|||||||
logger.info('sorting links...')
|
logger.info('sorting links...')
|
||||||
streams = streams.orderBy(
|
streams = streams.orderBy(
|
||||||
[
|
[
|
||||||
(stream: Stream) => stream.name,
|
(stream: Stream) => stream.title,
|
||||||
(stream: Stream) => stream.getVerticalResolution(),
|
(stream: Stream) => stream.getVerticalResolution(),
|
||||||
(stream: Stream) => stream.getLabel(),
|
(stream: Stream) => stream.getLabel(),
|
||||||
(stream: Stream) => stream.url
|
(stream: Stream) => stream.url
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ async function editStreams({
|
|||||||
.withChannel(channelsKeyById)
|
.withChannel(channelsKeyById)
|
||||||
.withFeed(feedsGroupedByChannelId)
|
.withFeed(feedsGroupedByChannelId)
|
||||||
.updateId()
|
.updateId()
|
||||||
.updateName()
|
.updateTitle()
|
||||||
.updateFilepath()
|
.updateFilepath()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,11 +173,11 @@ async function addStreams({
|
|||||||
const directives = data.getArray('directives') || []
|
const directives = data.getArray('directives') || []
|
||||||
|
|
||||||
const stream = new Stream({
|
const stream = new Stream({
|
||||||
channel: channelId,
|
channelId,
|
||||||
feed: feedId,
|
feedId,
|
||||||
name: data.getString('channelName') || channel.name,
|
title: channel.name,
|
||||||
url: streamUrl,
|
url: streamUrl,
|
||||||
user_agent: httpUserAgent,
|
userAgent: httpUserAgent,
|
||||||
referrer: httpReferrer,
|
referrer: httpReferrer,
|
||||||
directives,
|
directives,
|
||||||
quality,
|
quality,
|
||||||
@@ -185,7 +185,7 @@ async function addStreams({
|
|||||||
})
|
})
|
||||||
.withChannel(channelsKeyById)
|
.withChannel(channelsKeyById)
|
||||||
.withFeed(feedsGroupedByChannelId)
|
.withFeed(feedsGroupedByChannelId)
|
||||||
.updateName()
|
.updateTitle()
|
||||||
.updateFilepath()
|
.updateFilepath()
|
||||||
|
|
||||||
streams.add(stream)
|
streams.add(stream)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export class IssueLoader {
|
|||||||
repo: REPO,
|
repo: REPO,
|
||||||
per_page: 100,
|
per_page: 100,
|
||||||
labels,
|
labels,
|
||||||
|
status: 'open',
|
||||||
headers: {
|
headers: {
|
||||||
'X-GitHub-Api-Version': '2022-11-28'
|
'X-GitHub-Api-Version': '2022-11-28'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ const FIELDS = new Dictionary({
|
|||||||
'New Stream URL': 'newStreamUrl',
|
'New Stream URL': 'newStreamUrl',
|
||||||
Label: 'label',
|
Label: 'label',
|
||||||
Quality: 'quality',
|
Quality: 'quality',
|
||||||
'Channel Name': 'channelName',
|
|
||||||
'HTTP User-Agent': 'httpUserAgent',
|
'HTTP User-Agent': 'httpUserAgent',
|
||||||
'HTTP User Agent': 'httpUserAgent',
|
'HTTP User Agent': 'httpUserAgent',
|
||||||
'HTTP Referrer': 'httpReferrer',
|
'HTTP Referrer': 'httpReferrer',
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ export class Channel {
|
|||||||
return streams
|
return streams
|
||||||
}
|
}
|
||||||
|
|
||||||
getStreamNames(): Collection {
|
getStreamTitles(): Collection {
|
||||||
return this.getStreams()
|
return this.getStreams()
|
||||||
.map((stream: Stream) => stream.getName())
|
.map((stream: Stream) => stream.getTitle())
|
||||||
.uniq()
|
.uniq()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ export class Channel {
|
|||||||
name: this.name,
|
name: this.name,
|
||||||
altNames: this.altNames.all(),
|
altNames: this.altNames.all(),
|
||||||
guideNames: this.getGuideNames().all(),
|
guideNames: this.getGuideNames().all(),
|
||||||
streamNames: this.getStreamNames().all(),
|
streamTitles: this.getStreamTitles().all(),
|
||||||
feedFullNames: this.getFeedFullNames().all()
|
feedFullNames: this.getFeedFullNames().all()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { IssueData } from '../core'
|
|||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
export class Stream {
|
export class Stream {
|
||||||
name?: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
id?: string
|
id?: string
|
||||||
channelId?: string
|
channelId?: string
|
||||||
@@ -28,16 +28,17 @@ export class Stream {
|
|||||||
constructor(data?: StreamData) {
|
constructor(data?: StreamData) {
|
||||||
if (!data) return
|
if (!data) return
|
||||||
|
|
||||||
const id = data.channel && data.feed ? [data.channel, data.feed].join('@') : data.channel
|
const id =
|
||||||
|
data.channelId && data.feedId ? [data.channelId, data.feedId].join('@') : data.channelId
|
||||||
const { verticalResolution, isInterlaced } = parseQuality(data.quality)
|
const { verticalResolution, isInterlaced } = parseQuality(data.quality)
|
||||||
|
|
||||||
this.id = id || undefined
|
this.id = id || undefined
|
||||||
this.channelId = data.channel || undefined
|
this.channelId = data.channelId || undefined
|
||||||
this.feedId = data.feed || undefined
|
this.feedId = data.feedId || undefined
|
||||||
this.name = data.name || undefined
|
this.title = data.title || undefined
|
||||||
this.url = data.url
|
this.url = data.url
|
||||||
this.referrer = data.referrer || undefined
|
this.referrer = data.referrer || undefined
|
||||||
this.userAgent = data.user_agent || undefined
|
this.userAgent = data.userAgent || undefined
|
||||||
this.verticalResolution = verticalResolution || undefined
|
this.verticalResolution = verticalResolution || undefined
|
||||||
this.isInterlaced = isInterlaced || undefined
|
this.isInterlaced = isInterlaced || undefined
|
||||||
this.label = data.label || undefined
|
this.label = data.label || undefined
|
||||||
@@ -65,17 +66,18 @@ export class Stream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fromPlaylistItem(data: parser.PlaylistItem): this {
|
fromPlaylistItem(data: parser.PlaylistItem): this {
|
||||||
function parseTitle(title: string): {
|
function parseName(name: string): {
|
||||||
name: string
|
title: string
|
||||||
label: string
|
label: string
|
||||||
quality: string
|
quality: string
|
||||||
} {
|
} {
|
||||||
|
let title = name
|
||||||
const [, label] = title.match(/ \[(.*)\]$/) || [null, '']
|
const [, label] = title.match(/ \[(.*)\]$/) || [null, '']
|
||||||
title = title.replace(new RegExp(` \\[${escapeRegExp(label)}\\]$`), '')
|
title = title.replace(new RegExp(` \\[${escapeRegExp(label)}\\]$`), '')
|
||||||
const [, quality] = title.match(/ \(([0-9]+p)\)$/) || [null, '']
|
const [, quality] = title.match(/ \(([0-9]+p)\)$/) || [null, '']
|
||||||
title = title.replace(new RegExp(` \\(${quality}\\)$`), '')
|
title = title.replace(new RegExp(` \\(${quality}\\)$`), '')
|
||||||
|
|
||||||
return { name: title, label, quality }
|
return { title, label, quality }
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDirectives(string: string) {
|
function parseDirectives(string: string) {
|
||||||
@@ -100,7 +102,7 @@ export class Stream {
|
|||||||
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 { name, label, quality } = parseTitle(data.name)
|
const { title, label, quality } = parseName(data.name)
|
||||||
const { verticalResolution, isInterlaced } = parseQuality(quality)
|
const { verticalResolution, isInterlaced } = parseQuality(quality)
|
||||||
|
|
||||||
this.id = data.tvg.id || undefined
|
this.id = data.tvg.id || undefined
|
||||||
@@ -108,7 +110,7 @@ export class Stream {
|
|||||||
this.channelId = channelId || undefined
|
this.channelId = channelId || undefined
|
||||||
this.line = data.line
|
this.line = data.line
|
||||||
this.label = label || undefined
|
this.label = label || undefined
|
||||||
this.name = name
|
this.title = title
|
||||||
this.verticalResolution = verticalResolution || undefined
|
this.verticalResolution = verticalResolution || undefined
|
||||||
this.isInterlaced = isInterlaced || undefined
|
this.isInterlaced = isInterlaced || undefined
|
||||||
this.url = data.url
|
this.url = data.url
|
||||||
@@ -241,12 +243,12 @@ export class Stream {
|
|||||||
return parseInt(this.getQuality().replace(/p|i/, ''))
|
return parseInt(this.getQuality().replace(/p|i/, ''))
|
||||||
}
|
}
|
||||||
|
|
||||||
updateName(): this {
|
updateTitle(): this {
|
||||||
if (!this.channel) return this
|
if (!this.channel) return this
|
||||||
|
|
||||||
this.name = this.channel.name
|
this.title = this.channel.name
|
||||||
if (this.feed && !this.feed.isMain) {
|
if (this.feed && !this.feed.isMain) {
|
||||||
this.name += ` ${this.feed.name}`
|
this.title += ` ${this.feed.name}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
@@ -375,12 +377,12 @@ export class Stream {
|
|||||||
return logo ? logo.url : ''
|
return logo ? logo.url : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
getName(): string {
|
getTitle(): string {
|
||||||
return this.name || ''
|
return this.title || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
getTitle(): string {
|
getFullTitle(): string {
|
||||||
let title = `${this.getName()}`
|
let title = `${this.getTitle()}`
|
||||||
|
|
||||||
if (this.getQuality()) {
|
if (this.getQuality()) {
|
||||||
title += ` (${this.getQuality()})`
|
title += ` (${this.getQuality()})`
|
||||||
@@ -405,6 +407,7 @@ export class Stream {
|
|||||||
return {
|
return {
|
||||||
channel: this.channelId || null,
|
channel: this.channelId || null,
|
||||||
feed: this.feedId || null,
|
feed: this.feedId || null,
|
||||||
|
title: this.title,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
referrer: this.referrer || null,
|
referrer: this.referrer || null,
|
||||||
user_agent: this.userAgent || null,
|
user_agent: this.userAgent || null,
|
||||||
@@ -427,7 +430,7 @@ export class Stream {
|
|||||||
output += ` http-user-agent="${this.userAgent}"`
|
output += ` http-user-agent="${this.userAgent}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
output += `,${this.getTitle()}`
|
output += `,${this.getFullTitle()}`
|
||||||
|
|
||||||
this.directives.forEach((prop: string) => {
|
this.directives.forEach((prop: string) => {
|
||||||
output += `\r\n${prop}`
|
output += `\r\n${prop}`
|
||||||
|
|||||||
2
scripts/types/channel.d.ts
vendored
2
scripts/types/channel.d.ts
vendored
@@ -45,6 +45,6 @@ export type ChannelSearchableData = {
|
|||||||
name: string
|
name: string
|
||||||
altNames: string[]
|
altNames: string[]
|
||||||
guideNames: string[]
|
guideNames: string[]
|
||||||
streamNames: string[]
|
streamTitles: string[]
|
||||||
feedFullNames: string[]
|
feedFullNames: string[]
|
||||||
}
|
}
|
||||||
|
|||||||
8
scripts/types/stream.d.ts
vendored
8
scripts/types/stream.d.ts
vendored
@@ -1,10 +1,10 @@
|
|||||||
export type StreamData = {
|
export type StreamData = {
|
||||||
channel: string | null
|
channelId: string | null
|
||||||
feed: string | null
|
feedId: string | null
|
||||||
name: string | null
|
title: string | null
|
||||||
url: string
|
url: string
|
||||||
referrer: string | null
|
referrer: string | null
|
||||||
user_agent: string | null
|
userAgent: string | null
|
||||||
quality: string | null
|
quality: string | null
|
||||||
label: string | null
|
label: string | null
|
||||||
directives: string[]
|
directives: string[]
|
||||||
|
|||||||
Reference in New Issue
Block a user