Update playlist/update.js
This commit is contained in:
parent
76f18168c4
commit
6344531489
|
@ -4,16 +4,49 @@ const _ = require('lodash')
|
||||||
const playlist = {}
|
const playlist = {}
|
||||||
|
|
||||||
class Playlist {
|
class Playlist {
|
||||||
constructor() {
|
constructor(items = [], options = {}) {
|
||||||
|
this.header = {}
|
||||||
|
if (options.public) {
|
||||||
|
let guides = items
|
||||||
|
.map(item => (item.guides.length ? item.guides[0].url : null))
|
||||||
|
.filter(i => i)
|
||||||
|
this.header['x-tvg-url'] = _.uniq(guides).sort().join(',')
|
||||||
|
}
|
||||||
|
|
||||||
this.links = []
|
this.links = []
|
||||||
}
|
for (const item of items) {
|
||||||
|
const stream = store.create(item)
|
||||||
|
|
||||||
setHeader(attrs = {}) {
|
let attrs
|
||||||
this.header = attrs
|
if (options.public) {
|
||||||
}
|
attrs = {
|
||||||
|
'tvg-id': stream.get('tvg_id'),
|
||||||
|
'tvg-country': stream.get('tvg_country'),
|
||||||
|
'tvg-language': stream.get('tvg_language'),
|
||||||
|
'tvg-logo': stream.get('tvg_logo'),
|
||||||
|
'user-agent': stream.get('http.user-agent') || undefined,
|
||||||
|
'group-title': stream.get('group_title')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attrs = {
|
||||||
|
'tvg-id': stream.get('tvg_id'),
|
||||||
|
status: stream.get('status'),
|
||||||
|
'user-agent': stream.get('http.user-agent') || undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add(url, title, attrs, vlcOpts) {
|
const vlcOpts = {
|
||||||
this.links.push({ url, title, attrs, vlcOpts })
|
'http-referrer': stream.get('http.referrer') || undefined,
|
||||||
|
'http-user-agent': stream.get('http.user-agent') || undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
this.links.push({
|
||||||
|
url: stream.get('url'),
|
||||||
|
title: stream.get('title'),
|
||||||
|
attrs,
|
||||||
|
vlcOpts
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
@ -48,43 +81,8 @@ class Playlist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.create = function (items = [], options = {}) {
|
playlist.create = function (items, options) {
|
||||||
const p = new Playlist()
|
return new Playlist(items, options)
|
||||||
|
|
||||||
const header = {}
|
|
||||||
if (options.public) {
|
|
||||||
let guides = items.map(item => (item.guides.length ? item.guides[0].url : null)).filter(i => i)
|
|
||||||
header['x-tvg-url'] = _.uniq(guides).sort().join(',')
|
|
||||||
}
|
|
||||||
p.setHeader(header)
|
|
||||||
|
|
||||||
for (const item of items) {
|
|
||||||
const stream = store.create(item)
|
|
||||||
|
|
||||||
let attrs
|
|
||||||
if (options.public) {
|
|
||||||
attrs = {
|
|
||||||
'tvg-id': stream.get('tvg_id'),
|
|
||||||
'tvg-country': stream.get('tvg_country'),
|
|
||||||
'tvg-language': stream.get('tvg_language'),
|
|
||||||
'tvg-logo': stream.get('tvg_logo'),
|
|
||||||
'user-agent': stream.get('http.user-agent') || undefined,
|
|
||||||
'group-title': stream.get('group_title')
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attrs = {
|
|
||||||
'tvg-id': stream.get('tvg_id'),
|
|
||||||
'user-agent': stream.get('http.user-agent') || undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.add(stream.get('url'), stream.get('title'), attrs, {
|
|
||||||
'http-referrer': stream.get('http.referrer') || undefined,
|
|
||||||
'http-user-agent': stream.get('http.user-agent') || undefined
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = playlist
|
module.exports = playlist
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#EXTM3U
|
#EXTM3U
|
||||||
#EXTINF:-1 tvg-id="AndorraTV.ad",ATV (720p) [Offline]
|
#EXTINF:-1 tvg-id="AndorraTV.ad" status="timeout",ATV (720p) [Offline]
|
||||||
https://iptv-all.lanesh4d0w.repl.co/andorra/atv
|
https://iptv-all.lanesh4d0w.repl.co/andorra/atv
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#EXTM3U
|
#EXTM3U
|
||||||
#EXTINF:-1 tvg-id="LDPRTV.ru",ЛДПР ТВ (1080p)
|
#EXTINF:-1 tvg-id="LDPRTV.ru" status="online",ЛДПР ТВ (1080p)
|
||||||
http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8
|
http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#EXTM3U
|
#EXTM3U
|
||||||
#EXTINF:-1 tvg-id="BBCNews.uk",BBC News HD (480p) [Geo-blocked]
|
#EXTINF:-1 tvg-id="BBCNews.uk" status="online",BBC News HD (480p) [Geo-blocked]
|
||||||
http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/playlist.m3u8
|
http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/playlist.m3u8
|
||||||
#EXTINF:-1 tvg-id="BBCNews.uk",BBC News HD (720p) [Not 24/7]
|
#EXTINF:-1 tvg-id="BBCNews.uk" status="error",BBC News HD (720p) [Not 24/7]
|
||||||
http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8
|
http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{"title":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/channels/ru.m3u","url":"http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8","http_referrer":null,"user_agent":null,"height":1080,"width":1920,"cluster_id":1,"_id":"2ST8btby3mmsgPF0"}
|
{"title":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/channels/ru.m3u","url":"http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8","http_referrer":null,"user_agent":null,"height":1080,"width":1920,"cluster_id":1,"status":"online","_id":"2ST8btby3mmsgPF0"}
|
||||||
{"title":"BBC News HD (720p) [Not 24/7]","channel":"BBCNews.uk","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":3,"_id":"3TbieV1ptnZVCIdn"}
|
{"title":"BBC News HD (720p) [Not 24/7]","channel":"BBCNews.uk","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":3,"status":"error","_id":"3TbieV1ptnZVCIdn"}
|
||||||
{"title":"ATV (720p) [Offline]","channel":"AndorraTV.ad","filepath":"tests/__data__/output/channels/ad.m3u","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":1,"_id":"I6cjG2xCBRFFP4sz"}
|
{"title":"ATV (720p) [Offline]","channel":"AndorraTV.ad","filepath":"tests/__data__/output/channels/ad.m3u","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":1,"status":"timeout","_id":"I6cjG2xCBRFFP4sz"}
|
||||||
{"title":"BBC News HD (480p) [Geo-blocked]","channel":"BBCNews.uk","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/playlist.m3u8","http_referrer":null,"user_agent":null,"height":480,"width":640,"cluster_id":3,"_id":"WTbieV1ptnZVCIdn"}
|
{"title":"BBC News HD (480p) [Geo-blocked]","channel":"BBCNews.uk","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/playlist.m3u8","http_referrer":null,"user_agent":null,"height":480,"width":640,"cluster_id":3,"status":"online","_id":"WTbieV1ptnZVCIdn"}
|
||||||
{"title":"Kayhan TV","channel":"KayhanTV.af","filepath":"tests/__data__/output/channels/af.m3u","url":"http://208.93.117.113/live/Stream1/playlist.m3u8","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":1,"_id":"cFFpFVzSn6xFMUF3"}
|
{"title":"Kayhan TV","channel":"KayhanTV.af","filepath":"tests/__data__/output/channels/af.m3u","url":"http://208.93.117.113/live/Stream1/playlist.m3u8","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":1,"status":"blocked","_id":"cFFpFVzSn6xFMUF3"}
|
||||||
{"title":"Sharq","channel":"Sharq.af","filepath":"tests/__data__/output/channels/af.m3u","url":"http://51.210.199.50/hls/stream.m3u8","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":1,"_id":"u7iyA6cjtf1iWWAZ"}
|
{"title":"Sharq","channel":"Sharq.af","filepath":"tests/__data__/output/channels/af.m3u","url":"http://51.210.199.50/hls/stream.m3u8","http_referrer":null,"user_agent":null,"height":720,"width":1280,"cluster_id":1,"status":"online","_id":"u7iyA6cjtf1iWWAZ"}
|
||||||
|
|
Loading…
Reference in New Issue