mirror of
https://github.com/iptv-org/iptv
synced 2026-10-21 18:46:20 -04:00
Update scripts
This commit is contained in:
1 parent
9902121ac0
commit
9d7cac7bda
21 files changed
+129
-55
No files matched your search
@@ -2,17 +2,18 @@ import { Collection } from '@freearhey/core'
|
||||
import * as sdk from '@iptv-org/sdk'
|
||||
import { Stream } from '../models'
|
||||
|
||||
type PlaylistOptions = {
|
||||
export type PlaylistOptions = {
|
||||
public?: boolean
|
||||
raw?: boolean
|
||||
}
|
||||
|
||||
export class Playlist {
|
||||
streams: Collection<Stream>
|
||||
public: boolean
|
||||
options?: PlaylistOptions
|
||||
|
||||
constructor(streams: Collection<Stream>, options?: PlaylistOptions) {
|
||||
this.streams = streams
|
||||
this.public = options?.public === true
|
||||
this.options = options
|
||||
}
|
||||
|
||||
getGuides(): Collection<sdk.Models.Guide> {
|
||||
@@ -59,7 +60,7 @@ export class Playlist {
|
||||
output += '\r\n'
|
||||
|
||||
this.streams.forEach((stream: Stream) => {
|
||||
output += stream.toString({ public: this.public }) + '\r\n'
|
||||
output += stream.toString(this.options) + '\r\n'
|
||||
})
|
||||
|
||||
return output
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as sdk from '@iptv-org/sdk'
|
||||
import { DataSet } from '../core'
|
||||
import { data } from '../api'
|
||||
import path from 'node:path'
|
||||
import { PlaylistOptions } from './playlist'
|
||||
|
||||
export class Stream extends sdk.Models.Stream {
|
||||
filepath?: string
|
||||
@@ -16,6 +17,12 @@ export class Stream extends sdk.Models.Stream {
|
||||
guides = new Collection<sdk.Models.Guide>()
|
||||
isNot247?: boolean
|
||||
isGeoBlocked?: boolean
|
||||
hasMainFeed?: boolean = false
|
||||
hasUniqueName?: boolean = false
|
||||
channelName?: string
|
||||
feedName?: string
|
||||
countryName?: string
|
||||
channelUniqueName?: string
|
||||
|
||||
setGuides(guides?: sdk.Models.Guide[]) {
|
||||
this.guides = new Collection(guides)
|
||||
@@ -113,6 +120,17 @@ export class Stream extends sdk.Models.Stream {
|
||||
stream.isNot247 = labels.includes('Not 24/7')
|
||||
stream.isGeoBlocked = labels.includes('Geo-blocked')
|
||||
|
||||
const feed = stream.getFeed()
|
||||
stream.hasMainFeed = feed?.is_main
|
||||
stream.feedName = feed?.name
|
||||
|
||||
const channel = stream.getChannel()
|
||||
stream.channelName = channel?.name
|
||||
|
||||
const country = channel?.getCountry()
|
||||
stream.countryName = country?.name
|
||||
stream.channelUniqueName = `${channel?.name} (${country?.name})`
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
@@ -316,6 +334,14 @@ export class Stream extends sdk.Models.Stream {
|
||||
return false
|
||||
}
|
||||
|
||||
hasChannel(): boolean {
|
||||
return !!this.channel && !!this.getChannel()
|
||||
}
|
||||
|
||||
hasFeed(): boolean {
|
||||
return !!this.feed && !!this.getFeed()
|
||||
}
|
||||
|
||||
hasCategory(category: sdk.Models.Category): boolean {
|
||||
const channel = this.getChannel()
|
||||
|
||||
@@ -418,8 +444,25 @@ export class Stream extends sdk.Models.Stream {
|
||||
return logo ? logo.url : ''
|
||||
}
|
||||
|
||||
getFullTitle(): string {
|
||||
let title = `${this.title}`
|
||||
getTitle(options: PlaylistOptions): string {
|
||||
const raw = options.raw || false
|
||||
let title = ''
|
||||
if (raw) {
|
||||
title += this.title
|
||||
} else {
|
||||
if (!this.hasUniqueName) {
|
||||
title += this.channelUniqueName
|
||||
} else {
|
||||
title += this.channelName
|
||||
}
|
||||
if (this.feedName && !this.hasMainFeed) title += ' ' + this.feedName
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
getFullTitle(options: PlaylistOptions): string {
|
||||
let title = this.getTitle(options)
|
||||
|
||||
if (this.quality) {
|
||||
title += ` (${this.quality})`
|
||||
@@ -447,8 +490,8 @@ export class Stream extends sdk.Models.Stream {
|
||||
return labels
|
||||
}
|
||||
|
||||
toString(options: { public?: boolean } = {}) {
|
||||
options = { ...{ public: false }, ...options }
|
||||
toString(options: PlaylistOptions = {}) {
|
||||
options = { ...{ public: false, raw: false }, ...options }
|
||||
|
||||
let output = `#EXTINF:-1 tvg-id="${this.getTvgId()}"`
|
||||
|
||||
@@ -466,7 +509,7 @@ export class Stream extends sdk.Models.Stream {
|
||||
output += ` group-title="${this.groupTitle}"`
|
||||
}
|
||||
|
||||
output += `,${this.getFullTitle()}`
|
||||
output += `,${this.getFullTitle(options)}`
|
||||
|
||||
if (this.referrer) {
|
||||
output += `\r\n#EXTVLCOPT:http-referrer=${this.referrer}`
|
||||
|
||||
Reference in new issue
Block a user