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))