mirror of
https://github.com/He4eT/fuzzsoma.git
synced 2026-05-05 01:37:22 +00:00
index.js: play selected channel with cvlc
This commit is contained in:
parent
36b8e962e2
commit
82da03b01d
1 changed files with 6 additions and 5 deletions
11
index.js
11
index.js
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const xml2js = require('xml2js')
|
|
||||||
const inquirer = require('inquirer')
|
const inquirer = require('inquirer')
|
||||||
|
const xml2js = require('xml2js')
|
||||||
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
inquirer.registerPrompt('search-list', require('inquirer-search-list'))
|
inquirer.registerPrompt('search-list', require('inquirer-search-list'))
|
||||||
|
|
||||||
const channelsUrl = 'https://somafm.com/channels.xml'
|
const channelsUrl = 'https://somafm.com/channels.xml'
|
||||||
|
|
@ -22,7 +24,7 @@ const extractChannels = (json) =>
|
||||||
const fuzzySelect = (choices) =>
|
const fuzzySelect = (choices) =>
|
||||||
inquirer.prompt([{
|
inquirer.prompt([{
|
||||||
type: "search-list",
|
type: "search-list",
|
||||||
message: "Select SomaFM channel",
|
message: "SomaFM channel",
|
||||||
name: "channel",
|
name: "channel",
|
||||||
choices,
|
choices,
|
||||||
}])
|
}])
|
||||||
|
|
@ -38,9 +40,8 @@ const shapeChannels = (channels) =>
|
||||||
value: channel.highestpls[0]['_'],
|
value: channel.highestpls[0]['_'],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const playChannel = ({channel}) => {
|
const playChannel = ({channel}) =>
|
||||||
console.log(channel)
|
exec(`cvlc ${channel}`)
|
||||||
}
|
|
||||||
|
|
||||||
downloadChannelsXML(channelsUrl)
|
downloadChannelsXML(channelsUrl)
|
||||||
.then(xml2js.parseStringPromise)
|
.then(xml2js.parseStringPromise)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue