mirror of
https://github.com/He4eT/fuzzsoma.git
synced 2026-05-04 17:27:23 +00:00
index.js: sort channels
This commit is contained in:
parent
24d8a8d288
commit
b6f3c4c048
1 changed files with 8 additions and 1 deletions
9
index.js
9
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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue