mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-11 17:40:03 -04:00
Update scripts
This commit is contained in:
parent
8a83f23243
commit
f1d2add19a
98 changed files with 2423 additions and 1499 deletions
14
scripts/models/blocked.ts
Normal file
14
scripts/models/blocked.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
type BlockedProps = {
|
||||
channel: string
|
||||
ref: string
|
||||
}
|
||||
|
||||
export class Blocked {
|
||||
channel: string
|
||||
ref: string
|
||||
|
||||
constructor({ ref, channel }: BlockedProps) {
|
||||
this.channel = channel
|
||||
this.ref = ref
|
||||
}
|
||||
}
|
14
scripts/models/category.ts
Normal file
14
scripts/models/category.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
type CategoryProps = {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export class Category {
|
||||
id: string
|
||||
name: string
|
||||
|
||||
constructor({ id, name }: CategoryProps) {
|
||||
this.id = id
|
||||
this.name = name
|
||||
}
|
||||
}
|
79
scripts/models/channel.ts
Normal file
79
scripts/models/channel.ts
Normal file
|
@ -0,0 +1,79 @@
|
|||
import { Collection } from '../core'
|
||||
|
||||
type ChannelProps = {
|
||||
id: string
|
||||
name: string
|
||||
alt_names: string[]
|
||||
network: string
|
||||
owners: string[]
|
||||
country: string
|
||||
subdivision: string
|
||||
city: string
|
||||
broadcast_area: string[]
|
||||
languages: string[]
|
||||
categories: string[]
|
||||
is_nsfw: boolean
|
||||
launched: string
|
||||
closed: string
|
||||
replaced_by: string
|
||||
website: string
|
||||
logo: string
|
||||
}
|
||||
|
||||
export class Channel {
|
||||
id: string
|
||||
name: string
|
||||
altNames: Collection
|
||||
network: string
|
||||
owners: Collection
|
||||
country: string
|
||||
subdivision: string
|
||||
city: string
|
||||
broadcastArea: Collection
|
||||
languages: Collection
|
||||
categories: Collection
|
||||
isNSFW: boolean
|
||||
launched: string
|
||||
closed: string
|
||||
replacedBy: string
|
||||
website: string
|
||||
logo: string
|
||||
|
||||
constructor({
|
||||
id,
|
||||
name,
|
||||
alt_names,
|
||||
network,
|
||||
owners,
|
||||
country,
|
||||
subdivision,
|
||||
city,
|
||||
broadcast_area,
|
||||
languages,
|
||||
categories,
|
||||
is_nsfw,
|
||||
launched,
|
||||
closed,
|
||||
replaced_by,
|
||||
website,
|
||||
logo
|
||||
}: ChannelProps) {
|
||||
this.id = id
|
||||
this.name = name
|
||||
this.altNames = new Collection(alt_names)
|
||||
this.network = network
|
||||
this.owners = new Collection(owners)
|
||||
this.country = country
|
||||
this.subdivision = subdivision
|
||||
this.city = city
|
||||
this.broadcastArea = new Collection(broadcast_area)
|
||||
this.languages = new Collection(languages)
|
||||
this.categories = new Collection(categories)
|
||||
this.isNSFW = is_nsfw
|
||||
this.launched = launched
|
||||
this.closed = closed
|
||||
this.replacedBy = replaced_by
|
||||
this.website = website
|
||||
this.logo = logo
|
||||
}
|
||||
}
|
20
scripts/models/country.ts
Normal file
20
scripts/models/country.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
type CountryProps = {
|
||||
code: string
|
||||
name: string
|
||||
languages: string[]
|
||||
flag: string
|
||||
}
|
||||
|
||||
export class Country {
|
||||
code: string
|
||||
name: string
|
||||
languages: string[]
|
||||
flag: string
|
||||
|
||||
constructor({ code, name, languages, flag }: CountryProps) {
|
||||
this.code = code
|
||||
this.name = name
|
||||
this.languages = languages
|
||||
this.flag = flag
|
||||
}
|
||||
}
|
9
scripts/models/index.ts
Normal file
9
scripts/models/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export * from './playlist'
|
||||
export * from './blocked'
|
||||
export * from './stream'
|
||||
export * from './category'
|
||||
export * from './channel'
|
||||
export * from './language'
|
||||
export * from './country'
|
||||
export * from './region'
|
||||
export * from './subdivision'
|
14
scripts/models/language.ts
Normal file
14
scripts/models/language.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
type LanguageProps = {
|
||||
code: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export class Language {
|
||||
code: string
|
||||
name: string
|
||||
|
||||
constructor({ code, name }: LanguageProps) {
|
||||
this.code = code
|
||||
this.name = name
|
||||
}
|
||||
}
|
28
scripts/models/playlist.ts
Normal file
28
scripts/models/playlist.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { Collection } from '../core'
|
||||
import { Stream } from '../models'
|
||||
|
||||
type PlaylistOptions = {
|
||||
public: boolean
|
||||
}
|
||||
|
||||
export class Playlist {
|
||||
streams: Collection
|
||||
options: {
|
||||
public: boolean
|
||||
}
|
||||
|
||||
constructor(streams: Collection, options?: PlaylistOptions) {
|
||||
this.streams = streams
|
||||
this.options = options || { public: false }
|
||||
}
|
||||
|
||||
toString() {
|
||||
let output = `#EXTM3U\n`
|
||||
|
||||
this.streams.forEach((stream: Stream) => {
|
||||
output += stream.toString(this.options) + `\n`
|
||||
})
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
19
scripts/models/region.ts
Normal file
19
scripts/models/region.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { Collection } from '../core'
|
||||
|
||||
type RegionProps = {
|
||||
code: string
|
||||
name: string
|
||||
countries: string[]
|
||||
}
|
||||
|
||||
export class Region {
|
||||
code: string
|
||||
name: string
|
||||
countries: Collection
|
||||
|
||||
constructor({ code, name, countries }: RegionProps) {
|
||||
this.code = code
|
||||
this.name = name
|
||||
this.countries = new Collection(countries)
|
||||
}
|
||||
}
|
177
scripts/models/stream.ts
Normal file
177
scripts/models/stream.ts
Normal file
|
@ -0,0 +1,177 @@
|
|||
import { URL, Collection } from '../core'
|
||||
import { Category, Language } from './index'
|
||||
|
||||
type StreamProps = {
|
||||
name: string
|
||||
url: string
|
||||
filepath: string
|
||||
line: number
|
||||
channel?: string
|
||||
httpReferrer?: string
|
||||
label?: string
|
||||
quality?: string
|
||||
userAgent?: string
|
||||
}
|
||||
|
||||
export class Stream {
|
||||
channel: string
|
||||
filepath: string
|
||||
line: number
|
||||
httpReferrer: string
|
||||
label: string
|
||||
name: string
|
||||
quality: string
|
||||
url: string
|
||||
userAgent: string
|
||||
logo: string
|
||||
broadcastArea: Collection
|
||||
categories: Collection
|
||||
languages: Collection
|
||||
isNSFW: boolean
|
||||
groupTitle: string
|
||||
|
||||
constructor({
|
||||
channel,
|
||||
filepath,
|
||||
line,
|
||||
httpReferrer,
|
||||
label,
|
||||
name,
|
||||
quality,
|
||||
url,
|
||||
userAgent
|
||||
}: StreamProps) {
|
||||
this.channel = channel || ''
|
||||
this.filepath = filepath
|
||||
this.line = line
|
||||
this.httpReferrer = httpReferrer || ''
|
||||
this.label = label || ''
|
||||
this.name = name
|
||||
this.quality = quality || ''
|
||||
this.url = url
|
||||
this.userAgent = userAgent || ''
|
||||
this.logo = ''
|
||||
this.broadcastArea = new Collection()
|
||||
this.categories = new Collection()
|
||||
this.languages = new Collection()
|
||||
this.isNSFW = false
|
||||
this.groupTitle = 'Undefined'
|
||||
}
|
||||
|
||||
normalizeURL() {
|
||||
const url = new URL(this.url)
|
||||
|
||||
this.url = url.normalize().toString()
|
||||
}
|
||||
|
||||
clone(): Stream {
|
||||
return Object.assign(Object.create(Object.getPrototypeOf(this)), this)
|
||||
}
|
||||
|
||||
hasName(): boolean {
|
||||
return !!this.name
|
||||
}
|
||||
|
||||
noName(): boolean {
|
||||
return !this.name
|
||||
}
|
||||
|
||||
hasChannel() {
|
||||
return !!this.channel
|
||||
}
|
||||
|
||||
hasCategories(): boolean {
|
||||
return this.categories.notEmpty()
|
||||
}
|
||||
|
||||
noCategories(): boolean {
|
||||
return this.categories.empty()
|
||||
}
|
||||
|
||||
hasCategory(category: Category): boolean {
|
||||
return this.categories.includes((_category: Category) => _category.id === category.id)
|
||||
}
|
||||
|
||||
noLanguages(): boolean {
|
||||
return this.languages.empty()
|
||||
}
|
||||
|
||||
hasLanguage(language: Language): boolean {
|
||||
return this.languages.includes((_language: Language) => _language.code === language.code)
|
||||
}
|
||||
|
||||
noBroadcastArea(): boolean {
|
||||
return this.broadcastArea.empty()
|
||||
}
|
||||
|
||||
isInternational(): boolean {
|
||||
return this.broadcastArea.includes('r/INT')
|
||||
}
|
||||
|
||||
isSFW(): boolean {
|
||||
return this.isNSFW === false
|
||||
}
|
||||
|
||||
getTitle(): string {
|
||||
let title = `${this.name}`
|
||||
|
||||
if (this.quality) {
|
||||
title += ` (${this.quality})`
|
||||
}
|
||||
|
||||
if (this.label) {
|
||||
title += ` [${this.label}]`
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
data() {
|
||||
return {
|
||||
channel: this.channel,
|
||||
filepath: this.filepath,
|
||||
httpReferrer: this.httpReferrer,
|
||||
label: this.label,
|
||||
name: this.name,
|
||||
quality: this.quality,
|
||||
url: this.url,
|
||||
userAgent: this.userAgent,
|
||||
line: this.line
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
channel: this.channel,
|
||||
url: this.url,
|
||||
http_referrer: this.httpReferrer || null,
|
||||
user_agent: this.userAgent || null
|
||||
}
|
||||
}
|
||||
|
||||
toString(options: { public: boolean }) {
|
||||
let output = `#EXTINF:-1 tvg-id="${this.channel}"`
|
||||
|
||||
if (options.public) {
|
||||
output += ` tvg-logo="${this.logo}" group-title="${this.groupTitle}"`
|
||||
}
|
||||
|
||||
if (this.userAgent) {
|
||||
output += ` user-agent="${this.userAgent}"`
|
||||
}
|
||||
|
||||
output += `,${this.getTitle()}`
|
||||
|
||||
if (this.httpReferrer) {
|
||||
output += `\n#EXTVLCOPT:http-referrer=${this.httpReferrer}`
|
||||
}
|
||||
|
||||
if (this.userAgent) {
|
||||
output += `\n#EXTVLCOPT:http-user-agent=${this.userAgent}`
|
||||
}
|
||||
|
||||
output += `\n${this.url}`
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
17
scripts/models/subdivision.ts
Normal file
17
scripts/models/subdivision.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
type SubdivisionProps = {
|
||||
code: string
|
||||
name: string
|
||||
country: string
|
||||
}
|
||||
|
||||
export class Subdivision {
|
||||
code: string
|
||||
name: string
|
||||
country: string
|
||||
|
||||
constructor({ code, name, country }: SubdivisionProps) {
|
||||
this.code = code
|
||||
this.name = name
|
||||
this.country = country
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue