Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error When Attempting to Run Search #10

Closed
the-arkhive opened this issue Jan 29, 2016 · 8 comments
Closed

Error When Attempting to Run Search #10

the-arkhive opened this issue Jan 29, 2016 · 8 comments

Comments

@the-arkhive
Copy link

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
Copy link
Owner

mischah commented Jan 29, 2016

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

mischah commented Feb 2, 2016

Still exactly the same error message?

@kriskhaira
Copy link

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
Copy link
Owner

mischah commented Feb 4, 2016

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
Copy link

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

@mischah mischah closed this as completed Nov 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants