mirror of
https://github.com/He4eT/fuzzsoma.git
synced 2026-05-05 01:37:22 +00:00
index.js: cleanup
This commit is contained in:
parent
82da03b01d
commit
13774d5a8d
1 changed files with 6 additions and 6 deletions
12
index.js
12
index.js
|
|
@ -4,9 +4,7 @@ const inquirer = require('inquirer')
|
||||||
const xml2js = require('xml2js')
|
const xml2js = require('xml2js')
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
inquirer.registerPrompt('search-list', require('inquirer-search-list'))
|
const CHANNELS_XML_URL = 'https://somafm.com/channels.xml'
|
||||||
|
|
||||||
const channelsUrl = 'https://somafm.com/channels.xml'
|
|
||||||
|
|
||||||
const downloadChannelsXML = (url) =>
|
const downloadChannelsXML = (url) =>
|
||||||
fetch(url)
|
fetch(url)
|
||||||
|
|
@ -21,13 +19,15 @@ const downloadChannelsXML = (url) =>
|
||||||
const extractChannels = (json) =>
|
const extractChannels = (json) =>
|
||||||
json.channels.channel
|
json.channels.channel
|
||||||
|
|
||||||
const fuzzySelect = (choices) =>
|
const fuzzySelect = (choices) => {
|
||||||
inquirer.prompt([{
|
inquirer.registerPrompt('search-list', require('inquirer-search-list'))
|
||||||
|
return inquirer.prompt([{
|
||||||
type: "search-list",
|
type: "search-list",
|
||||||
message: "SomaFM channel",
|
message: "SomaFM channel",
|
||||||
name: "channel",
|
name: "channel",
|
||||||
choices,
|
choices,
|
||||||
}])
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
const sortChannels = (channels) =>
|
const sortChannels = (channels) =>
|
||||||
channels.sort((a, b) =>
|
channels.sort((a, b) =>
|
||||||
|
|
@ -43,7 +43,7 @@ const shapeChannels = (channels) =>
|
||||||
const playChannel = ({channel}) =>
|
const playChannel = ({channel}) =>
|
||||||
exec(`cvlc ${channel}`)
|
exec(`cvlc ${channel}`)
|
||||||
|
|
||||||
downloadChannelsXML(channelsUrl)
|
downloadChannelsXML(CHANNELS_XML_URL)
|
||||||
.then(xml2js.parseStringPromise)
|
.then(xml2js.parseStringPromise)
|
||||||
.then(extractChannels)
|
.then(extractChannels)
|
||||||
.then(sortChannels)
|
.then(sortChannels)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue