diff --git a/scripts/commands/database/update.js b/scripts/commands/database/update.js index 9cb79de380..a0555c0ee7 100644 --- a/scripts/commands/database/update.js +++ b/scripts/commands/database/update.js @@ -135,8 +135,10 @@ function parseStreams(streams) { .filter(s => s.codec_type === 'video') .reduce( (acc, curr) => { - if (curr.height > acc.height) - return { width: curr.width, height: curr.height, bitrate: curr.bitrate } + if (curr.height > acc.height) { + const bitrate = curr.tags.variant_bitrate ? parseInt(curr.tags.variant_bitrate) : 0 + return { width: curr.width, height: curr.height, bitrate } + } return acc }, { width: 0, height: 0, bitrate: 0 } diff --git a/tests/__data__/expected/database/db_update.streams.db b/tests/__data__/expected/database/db_update.streams.db index d0adf554a6..67fb3946d7 100644 --- a/tests/__data__/expected/database/db_update.streams.db +++ b/tests/__data__/expected/database/db_update.streams.db @@ -1,6 +1,6 @@ {"title":"ЛДПР ТВ","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":"","user_agent":"","cluster_id":1,"_id":"2ST8btby3mmsgPF0","is_online":false} {"title":"BBC News HD","channel":"BBCNews.uk","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","http_referrer":"","user_agent":"","cluster_id":3,"_id":"3TbieV1ptnZVCIdn","is_online":true} {"title":"ATV","channel":"AndorraTV.ad","filepath":"tests/__data__/output/channels/ad.m3u","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":"","user_agent":"","cluster_id":1,"_id":"I6cjG2xCBRFFP4sz","is_online":false} -{"title":"BBC News HD","channel":"BBCNewsHD.ad","filepath":"tests/__data__/output/channels/uk.m3u","url":"https://master.starmena-cloud.com/hls/libyas.m3u8","http_referrer":"","user_agent":"","cluster_id":3,"_id":"WTbieV1ptnZVCIdn","is_online":true,"width":1024,"height":576} +{"title":"BBC News HD","channel":"BBCNewsHD.ad","filepath":"tests/__data__/output/channels/uk.m3u","url":"https://master.starmena-cloud.com/hls/libyas.m3u8","http_referrer":"","user_agent":"","cluster_id":3,"_id":"WTbieV1ptnZVCIdn","is_online":true,"bitrate":0,"width":1024,"height":576} {"title":"Kayhan TV","channel":"KayhanTV.af","filepath":"channels/af.m3u","url":"http://208.93.117.113/live/Stream1/playlist.m3u8","http_referrer":"","user_agent":"","cluster_id":1,"_id":"cFFpFVzSn6xFMUF3","is_online":false} -{"title":"Sharq","channel":"Sharq.af","filepath":"channels/af.m3u","width":1280,"height":720,"url":"https://forerunnerrtmp.livestreamingcdn.com/output18/output18.stream/playlist.m3u8","http_referrer":"","user_agent":"","cluster_id":1,"_id":"u7iyA6cjtf1iWWAZ","is_online":true} +{"title":"Sharq","channel":"Sharq.af","filepath":"channels/af.m3u","bitrate":1226543,"width":1280,"height":720,"url":"https://forerunnerrtmp.livestreamingcdn.com/output18/output18.stream/playlist.m3u8","http_referrer":"","user_agent":"","cluster_id":1,"_id":"u7iyA6cjtf1iWWAZ","is_online":true} diff --git a/tests/__data__/input/database/db_update.streams.db b/tests/__data__/input/database/db_update.streams.db index 85e5cca505..9ba8279d50 100644 --- a/tests/__data__/input/database/db_update.streams.db +++ b/tests/__data__/input/database/db_update.streams.db @@ -2,5 +2,5 @@ {"title":"ATV","channel":"AndorraTV.ad","filepath":"tests/__data__/output/channels/ad.m3u","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":"","user_agent":"","cluster_id":1,"_id":"I6cjG2xCBRFFP4sz"} {"title":"BBC News HD","channel":"BBCNews.uk","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","http_referrer":"","user_agent":"","cluster_id":3,"_id":"3TbieV1ptnZVCIdn"} {"title":"Kayhan TV","channel":"KayhanTV.af","filepath":"channels/af.m3u","url":"http://208.93.117.113/live/Stream1/playlist.m3u8","http_referrer":"","user_agent":"","cluster_id":1,"_id":"cFFpFVzSn6xFMUF3"} -{"title":"Sharq","channel":"Sharq.af","filepath":"channels/af.m3u","bitrate":1226543,"width":1280,"height":720,"url":"http://51.210.199.50/hls/stream.m3u8","http_referrer":"","user_agent":"","cluster_id":1,"_id":"u7iyA6cjtf1iWWAZ"} +{"title":"Sharq","channel":"Sharq.af","filepath":"channels/af.m3u","url":"http://51.210.199.50/hls/stream.m3u8","http_referrer":"","user_agent":"","cluster_id":1,"_id":"u7iyA6cjtf1iWWAZ"} {"title":"BBC News HD","channel":"BBCNewsHD.ad","filepath":"tests/__data__/output/channels/uk.m3u","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","http_referrer":"","user_agent":"","cluster_id":3,"_id":"WTbieV1ptnZVCIdn"}