0

This is a piece of code used to import subscriptions from one Youtube account to another by opening up a new Google Chrome tab/window with a channel url from the list inside the downloaded subscription_manager.xml file. When I use node to open the "app.js" file it shows no errors but it never opens Chrome. I think because the creator of the code was using Mac Os, he may have written something that isn't compatible in Windows. Can someone verify this to make sure it works for Windows too? Link to video "https://youtu.be/GVakGPDF3Kc"

var fs = require('fs'),
childProcess = require('child_process'),
xml2js = require('xml2js');

    var parser = new xml2js.Parser();
    fs.readFile(__dirname + '/subscription_manager.xml', function (err, data) {
        parser.parseString(data, function (err, result) {
            var nodes = result.opml.body[0].outline[0].outline;

        nodes.forEach(function (node, index) {
            var url = node['$'].xmlUrl;
            url = url.substring(url.indexOf('=') + 1, url.length);
            var channel = 'https://www.youtube.com/channel/' + url;

            if (index == 1) {
                childProcess.exec('open -a "Google Chrome" ' + channel);
            }
        });
    });
});
  • Maybe refer to this [question](https://stackoverflow.com/q/14348840/2950032) to open Chrome on Windows? – maazadeeb Jul 11 '17 at 15:19

1 Answers1

0

You're right about the MacOS vs Windows portion - this code:

childProcess.exec('open -a "Google Chrome" ' + channel);

is for the MacOS terminal. You could try changing it to:

childProcess.exec('start chrome ' + channel);

(Tested on Windows 10)

Shahein Moussavi
  • 349
  • 2
  • 13