mischah / itunes-remote

:notes: Control iTunes via CLI
MIT License
426 stars 31 forks source link

Error When Attempting to Run Search #10

Closed the-arkhive closed 6 years ago

the-arkhive commented 8 years ago

When attempting to run a search with the itunes-remote system I get the following error.

iTunes: search symphony
Hold on ………
undefined:1
undefined
^

SyntaxError: Unexpected token u
    at Object.parse (native)
    at /usr/local/lib/node_modules/itunes-remote/index.js:125:15
    at Child_Process.<anonymous> (/usr/local/lib/node_modules/itunes-remote/node_modules/osascript/index.js:68:12)
    at emitOne (events.js:90:13)
    at Child_Process.emit (events.js:182:7)
    at ChildProcess.onExit (/usr/local/lib/node_modules/itunes-remote/node_modules/duplex-child-process/index.js:120:12)
    at ChildProcess.g (events.js:273:16)
    at emitTwo (events.js:100:13)
    at ChildProcess.emit (events.js:185:7)
    at maybeClose (internal/child_process.js:821:16)
mischah commented 8 years ago

mhm. Interesting never saw something like that before. Could you please add some metadata over here? Like: OS version, Node Version, ITunes version?

Than I would try my best to replicate this.

the-arkhive commented 8 years ago

OS X Version: 10.11 Beta (15A278b) but I thought I had updated to the official release, so I will be doing that soon. iTunes Version: 12.3.2 Node version: v5.5.0

If you think running the beta is the problem I can try updating to that and getting back to you once I do, that was you don't have to worry about trying to match OS version for testing purposes.

the-arkhive commented 8 years ago

Updating to the final release of El Capitan seemed to fix things. I have encountered this with other software, so it might be possible that you have an OS X version specified somewhere, but I haven't looked through your project to know that.

the-arkhive commented 8 years ago

Okay, so that was short lived. I am now encountering the same issue again. Is it possible that some application i have running at the same time is causing this problem?

mischah commented 8 years ago

Still exactly the same error message?

kriskhaira commented 8 years ago

I'm having the same problem but only for a particular keyword.

iTunes: search tron
Hold on …………
undefined:1
undefined
^

SyntaxError: Unexpected token u
    at Object.parse (native)
    at /usr/local/lib/node_modules/itunes-remote/index.js:125:15
    at Child_Process.<anonymous> (/usr/local/lib/node_modules/itunes-remote/node_modules/osascript/index.js:68:12)
    at emitOne (events.js:77:13)
    at Child_Process.emit (events.js:169:7)
    at ChildProcess.onExit (/usr/local/lib/node_modules/itunes-remote/node_modules/duplex-child-process/index.js:120:12)
    at ChildProcess.g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:821:16)

My environment:

itunes-remote 2.1.0
npm 3.5.3
node 5.4.1
iTunes 12.3.2.35
Mac OS X El Capitan 10.11.3
mischah commented 8 years ago

Okay. I’m still not able to reproduce that.

But according to the error message it seems like osascript returns undefined in index.js:125 where it should return a string representation of an array containing the playlistname and the amount of songs found by the search. Like ["itunes-remote", 167] if I search for tron or ["itunes-remote", 0]if i search for symphony.

bildschirmfoto 2016-02-04 um 22 08 52

I have no idea why osascript returns undefined.

But you could try to enlighten me by pasting the following into you Macs Script Editor.app:

(function() {
    var playlistName = 'itunes-remote';
    var app = Application('iTunes');
    var searchTerm = 'tron';
    var library = app.libraryPlaylists[0];
    var result;
    var list;

    console.log('itunes =', app.version());
    console.log('library =', library.name());

    app.run();

    result = app.search(library, {
        for: searchTerm
    });

    console.log('matches =', result.length);
    console.log('album of first hit =', result[0].album());

    try {
        app.userPlaylists[playlistName]();
    } catch (e) {
        console.log('create playlist');
        app.make({
            new: 'playlist',
            withProperties: {
                name: playlistName
            }
        });
    }

    list = app.userPlaylists[playlistName];

    app.delete(list.tracks);

    result.forEach(function(element) {
        app.duplicate(element, {
            to: list
        });
    });

    console.log('play time =', list.time());

    //list.play();
    return [
        playlistName,
        result.length
    ];
})();

What’s the output compared to this screenshot: search scpt 2016-02-04 22-24-32

The script editor should be shipped with every mac.

Thanks, Michael

luxmaker commented 8 years ago

hello Michael I'm so not an expert on these things but dipping into this with your remote. I have it installed on el captian . I tried the play artist command in order to choose who to play but i get this: iTunes: play artist ? Choose an artist (Use arrow keys) Vorpal Prompt error: [TypeError: Cannot read property 'length' of null]

Any thoughts? Thanks