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