From 82da03b01d2101afb428370a1923d06428caa3d3 Mon Sep 17 00:00:00 2001 From: He4eT Date: Mon, 25 Dec 2023 17:30:57 +0100 Subject: [PATCH] index.js: play selected channel with cvlc --- index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 43096f2..1ead813 100755 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ #!/usr/bin/env node -const xml2js = require('xml2js') const inquirer = require('inquirer') +const xml2js = require('xml2js') +const { exec } = require('child_process'); + inquirer.registerPrompt('search-list', require('inquirer-search-list')) const channelsUrl = 'https://somafm.com/channels.xml' @@ -22,7 +24,7 @@ const extractChannels = (json) => const fuzzySelect = (choices) => inquirer.prompt([{ type: "search-list", - message: "Select SomaFM channel", + message: "SomaFM channel", name: "channel", choices, }]) @@ -38,9 +40,8 @@ const shapeChannels = (channels) => value: channel.highestpls[0]['_'], })) -const playChannel = ({channel}) => { - console.log(channel) -} +const playChannel = ({channel}) => + exec(`cvlc ${channel}`) downloadChannelsXML(channelsUrl) .then(xml2js.parseStringPromise)