Sort similar links by status

This commit is contained in:
Aleksandr Statciuk 2022-02-24 22:18:10 +03:00
parent 63ce588aca
commit e8923a15de
3 changed files with 16 additions and 2 deletions

View File

@ -6,7 +6,12 @@ const _ = require('lodash')
async function main() { async function main() {
await db.streams.load() await db.streams.load()
let streams = await db.streams.find({}) let streams = await db.streams.find({})
streams = orderBy(streams, ['title', 'height', 'url'], ['asc', 'desc', 'asc']) const levels = { online: 1, blocked: 2, timeout: 3, error: 4, default: 5 }
streams = orderBy(
streams,
['title', s => levels[s.status] || levels['default'], 'height', 'url'],
['asc', 'asc', 'desc', 'asc']
)
const files = _.groupBy(streams, 'filepath') const files = _.groupBy(streams, 'filepath')
for (const filepath in files) { for (const filepath in files) {

View File

@ -1,3 +1,9 @@
#EXTM3U #EXTM3U
#EXTINF:-1 tvg-id="LDPRTV.ru" status="online",ЛДПР ТВ (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
#EXTINF:-1 tvg-id="LDPRTV.ru" status="blocked",ЛДПР ТВ (1080p)
http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8
#EXTINF:-1 tvg-id="LDPRTV.ru" status="timeout",ЛДПР ТВ (1080p)
http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8
#EXTINF:-1 tvg-id="LDPRTV.ru" status="error",ЛДПР ТВ (1080p)
http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8

View File

@ -1,4 +1,7 @@
{"title":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/streams/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":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/streams/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":"blocked","_id":"2ST8btby3mmsgPF0"}
{"title":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/streams/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":"timeout","_id":"2ST8btby3mmsgPF1"}
{"title":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/streams/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":"2ST8btby3mmsgPF2"}
{"title":"ЛДПР ТВ (1080p)","channel":"LDPRTV.ru","filepath":"tests/__data__/output/streams/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":"error","_id":"2ST8btby3mmsgPF3"}
{"title":"BBC News HD (720p) [Not 24/7]","channel":"BBCNews.uk","filepath":"tests/__data__/output/streams/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":"BBC News HD (720p) [Not 24/7]","channel":"BBCNews.uk","filepath":"tests/__data__/output/streams/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/streams/ad.m3u","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":"http://imn.iq","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148","height":720,"width":1280,"cluster_id":1,"status":"timeout","_id":"I6cjG2xCBRFFP4sz"} {"title":"ATV (720p) [Offline]","channel":"AndorraTV.ad","filepath":"tests/__data__/output/streams/ad.m3u","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":"http://imn.iq","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148","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/streams/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":"BBC News HD (480p) [Geo-blocked]","channel":"BBCNews.uk","filepath":"tests/__data__/output/streams/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"}