Update src/

This commit is contained in:
freearhey 2025-04-30 04:06:54 +03:00
parent e411cec545
commit 2a893a827b
33 changed files with 416 additions and 186 deletions

View file

@ -1,10 +1,10 @@
import type { JsonDataViewerField } from '~/types/jsonDataViewerField'
import type { StreamData, StreamSerializedData } from '~/types/stream'
import type { HTMLPreviewField } from '~/types/htmlPreviewField'
import type { Dictionary } from '@freearhey/core/browser'
import { Link } from 'iptv-playlist-generator'
import type { Category } from './category'
import type { Channel } from './channel'
import type { Feed } from './feed'
import type { Category } from './category'
export class Stream {
channelId?: string
@ -54,31 +54,6 @@ export class Stream {
return `${this.channelId}@${this.feedId}`
}
toJSON() {
return {
channel: this.channelId,
feed: this.feedId,
url: this.url,
referrer: this.referrer,
user_agent: this.userAgent,
quality: this.quality
}
}
getFieldset(): JsonDataViewerField[] {
let fieldset = []
const data = this.toJSON()
for (let key in data) {
fieldset.push({
name: key,
value: data[key]
})
}
return fieldset
}
getQuality(): string {
if (!this.quality) return ''
@ -89,7 +64,7 @@ export class Stream {
return parseInt(this.getQuality().replace(/p|i/, ''))
}
getTitle(): string {
getDisplayName(): string {
if (!this.channel) return ''
if (!this.feed) return this.channel.name
@ -101,7 +76,7 @@ export class Stream {
const link = new Link(this.url)
link.title = this.getTitle()
link.title = this.getDisplayName()
link.attrs = {
'tvg-id': this.getId(),
'tvg-logo': this.channel.logoUrl,
@ -125,6 +100,21 @@ export class Stream {
return link
}
getFieldset(): HTMLPreviewField[] {
return [
{ name: 'url', type: 'string', value: this.url, title: this.url },
this.referrer
? { name: 'referrer', type: 'string', value: this.referrer, title: this.referrer }
: null,
this.userAgent
? { name: 'user_agent', type: 'string', value: this.userAgent, title: this.userAgent }
: null,
this.quality
? { name: 'quality', type: 'string', value: this.quality, title: this.quality }
: null
]
}
serialize(): StreamSerializedData {
return {
channelId: this.channelId,