From b6f3c4c048b629af79565066fdbf7202a56be505 Mon Sep 17 00:00:00 2001 From: He4eT Date: Mon, 25 Dec 2023 16:13:44 +0100 Subject: [PATCH] index.js: sort channels --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a210001..e28b70b 100755 --- a/index.js +++ b/index.js @@ -25,13 +25,20 @@ const fuzzySelect = (choices) => pageSize: 10, }]) +const playChannel = (channel) => { + console.log(channel) +} + download(channelsUrl) .then(xml2js.parseStringPromise) .then((json) => json.channels.channel) + .then((channels) => channels.sort((a, b) => + b.listeners[0] - a.listeners[0])) .then((channels) => channels.map((channel) => ({ name: `${channel.title[0]} — ${channel.description[0]}`, value: channel.highestpls[0]['_'], }))) .then(fuzzySelect) - .then((x) => console.log(x)) + .then(({channel}) => channel) + .then(playChannel) .catch((error) => console.error('Error:', error.message))