#13 Finializing fix
- Updated the regex to double exclude '\' - Updated extractValue function to return the full result
This commit is contained in:
@@ -11,8 +11,8 @@ let type = "dshow";
|
|||||||
if (os.platform() === 'linux') {
|
if (os.platform() === 'linux') {
|
||||||
await new Promise((res) => {
|
await new Promise((res) => {
|
||||||
executeCommand("pactl", ['list', 'short', 'sources']).then(cliOutput => {
|
executeCommand("pactl", ['list', 'short', 'sources']).then(cliOutput => {
|
||||||
device = extractValue(cliOutput, '(?:\d[ ]{4,12}(.+?)[ ]{4,12}(?:.+?[ ]{4,12}){2,4}RUNNING)')
|
device = extractValue(cliOutput, '(?:\\d(?:\\t|[\\s]{1,9})(?<device>[\\w\\d\\-\\.\\_]+?)(?:\\t|[\\s]{1,9})(?<card>[\\w\\d\\-\\.\\_]+)(?:\\t|[\\s]{1,9})(?:(?<device_type>[\\w\\d\\-\\.\\_]+?) (?<channels>\\dch) (?<frequency>\\d+Hz))(?:\\t|[\\s]{1,9})(?:IDLE|RUNNING|SUSPENDED))')
|
||||||
console.log("Device:", device);
|
console.log("Device:", device.groups.device);
|
||||||
res();
|
res();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export const generateUniqueID = () => {
|
|||||||
* @returns {string|null} The value found after the pattern, or null if not found.
|
* @returns {string|null} The value found after the pattern, or null if not found.
|
||||||
*/
|
*/
|
||||||
export const extractValue = (input, pattern) => {
|
export const extractValue = (input, pattern) => {
|
||||||
const regex = new RegExp(`${pattern}\\s+(\\S+)`);
|
const regex = new RegExp(`${pattern}`);
|
||||||
const match = input.match(regex);
|
const match = input.match(regex);
|
||||||
return match ? match[1] : null;
|
return match ? match : null;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user