mirror of
https://github.com/iptv-org/iptv.git
synced 2024-12-26 17:37:02 +00:00
Update scripts
This commit is contained in:
parent
e0a2cb295a
commit
62fac80172
|
@ -13,7 +13,7 @@ async function main() {
|
|||
let streams = await parser.parse(files)
|
||||
streams = streams
|
||||
.map(data => new Stream(data))
|
||||
.orderBy((stream: Stream) => stream.channel)
|
||||
.orderBy([(stream: Stream) => stream.channel, (stream: Stream) => stream.timeshift])
|
||||
.map((stream: Stream) => stream.toJSON())
|
||||
|
||||
logger.info(`found ${streams.count()} streams`)
|
||||
|
|
|
@ -37,7 +37,7 @@ async function main() {
|
|||
logger.info('loading streams...')
|
||||
let streams = await loadStreams({ channels, categories, languages })
|
||||
let totalStreams = streams.count()
|
||||
streams = streams.uniqBy((stream: Stream) => stream.channel || _.uniqueId())
|
||||
streams = streams.uniqBy((stream: Stream) => (stream.channel || _.uniqueId()) + stream.timeshift)
|
||||
logger.info(`found ${totalStreams} streams (including ${streams.count()} unique)`)
|
||||
|
||||
const generatorsLogger = new Logger({
|
||||
|
@ -104,7 +104,15 @@ async function loadStreams({
|
|||
let streams = await parser.parse(files)
|
||||
|
||||
streams = streams
|
||||
.orderBy([(stream: Stream) => stream.channel, (stream: Stream) => stream.url], ['asc', 'asc'])
|
||||
.orderBy(
|
||||
[
|
||||
(stream: Stream) => stream.channel,
|
||||
(stream: Stream) => stream.timeshift,
|
||||
(stream: Stream) => parseInt(stream.quality.replace('p', '')),
|
||||
(stream: Stream) => stream.label
|
||||
],
|
||||
['asc', 'asc', 'desc', 'asc']
|
||||
)
|
||||
.map((stream: Stream) => {
|
||||
const channel: Channel | undefined = groupedChannels.get(stream.channel)
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ async function editStreams(loader: IssueLoader) {
|
|||
if (data.has('channel_name')) stream.name = data.get('channel_name')
|
||||
if (data.has('label')) stream.label = data.get('label')
|
||||
if (data.has('quality')) stream.quality = data.get('quality')
|
||||
if (data.has('timeshift')) stream.timeshift = data.get('timeshift')
|
||||
if (data.has('user_agent')) stream.userAgent = data.get('user_agent')
|
||||
if (data.has('http_referrer')) stream.httpReferrer = data.get('http_referrer')
|
||||
if (data.has('channel_name')) stream.name = data.get('channel_name')
|
||||
|
@ -114,6 +115,7 @@ async function addStreams(loader: IssueLoader) {
|
|||
url: data.get('stream_url'),
|
||||
label: data.get('label'),
|
||||
quality: data.get('quality'),
|
||||
timeshift: data.get('timeshift'),
|
||||
userAgent: data.get('user_agent'),
|
||||
httpReferrer: data.get('http_referrer'),
|
||||
filepath: `${channel.country.toLowerCase()}.m3u`,
|
||||
|
|
|
@ -10,6 +10,8 @@ const FIELDS = new Dictionary({
|
|||
'Broken Link': 'stream_url',
|
||||
Label: 'label',
|
||||
Quality: 'quality',
|
||||
Timeshift: 'timeshift',
|
||||
'Timeshift (optional)': 'timeshift',
|
||||
'Channel Name': 'channel_name',
|
||||
'HTTP User-Agent': 'user_agent',
|
||||
'HTTP Referrer': 'http_referrer',
|
||||
|
|
|
@ -40,7 +40,8 @@ export class PlaylistParser {
|
|||
line: item.line,
|
||||
url: item.url,
|
||||
httpReferrer: item.http.referrer,
|
||||
userAgent: item.http['user-agent']
|
||||
userAgent: item.http['user-agent'],
|
||||
timeshift: item.tvg.shift
|
||||
})
|
||||
|
||||
streams.add(stream)
|
||||
|
|
|
@ -11,6 +11,7 @@ type StreamProps = {
|
|||
label?: string
|
||||
quality?: string
|
||||
userAgent?: string
|
||||
timeshift?: string
|
||||
}
|
||||
|
||||
export class Stream {
|
||||
|
@ -30,6 +31,7 @@ export class Stream {
|
|||
isNSFW: boolean
|
||||
groupTitle: string
|
||||
removed: boolean = false
|
||||
timeshift: string
|
||||
|
||||
constructor({
|
||||
channel,
|
||||
|
@ -40,7 +42,8 @@ export class Stream {
|
|||
name,
|
||||
quality,
|
||||
url,
|
||||
userAgent
|
||||
userAgent,
|
||||
timeshift
|
||||
}: StreamProps) {
|
||||
this.channel = channel || ''
|
||||
this.filepath = filepath
|
||||
|
@ -57,6 +60,7 @@ export class Stream {
|
|||
this.languages = new Collection()
|
||||
this.isNSFW = false
|
||||
this.groupTitle = 'Undefined'
|
||||
this.timeshift = timeshift || ''
|
||||
}
|
||||
|
||||
normalizeURL() {
|
||||
|
@ -145,6 +149,7 @@ export class Stream {
|
|||
return {
|
||||
channel: this.channel,
|
||||
url: this.url,
|
||||
timeshift: this.timeshift || null,
|
||||
http_referrer: this.httpReferrer || null,
|
||||
user_agent: this.userAgent || null
|
||||
}
|
||||
|
@ -153,6 +158,10 @@ export class Stream {
|
|||
toString(options: { public: boolean }) {
|
||||
let output = `#EXTINF:-1 tvg-id="${this.channel}"`
|
||||
|
||||
if (this.timeshift) {
|
||||
output += ` tvg-shift="${this.timeshift}"`
|
||||
}
|
||||
|
||||
if (options.public) {
|
||||
output += ` tvg-logo="${this.logo}" group-title="${this.groupTitle}"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue