I’m working on a internet radio (spotify/podcasts) on a raspberry pi in an Ikea hack, and absolutely loving Mopidy so far! However, I run into the following problem: when trying to create a playlist based on a podcast URI, no playlist seems to be created. More specifically, the following code returns the console error: [TypeError: Cannot read property ‘name’ of null]
var Mopidy = require("mopidy");
var mopidy = new Mopidy({
webSocketUrl: "ws://localhost:6680/mopidy/ws",
callingConvention: "by-position-only"
});
var init = function() {
mopidy.playlists.create("Podcast Playlist", "http://www.npr.org/rss/podcast.php?id=510019").then(function(playlist) {
console.log(playlist.name);
})
.catch(console.error.bind(console))
.done();
};
mopidy.on("state:online", init);
I tried different variations of the podcast url (e.g., podcast:// or podcast+http:// instead of http://, as mentioned on https://github.com/tkem/mopidy-podcast/issues/7) but got the same error. Probably, I’m missing something obvious but I’m not finding any clues in the forums or on github. Any clues or pointers are greatly appreciated!
I suspect this is the same issue as was fixed in https://github.com/mopidy/mopidy/pull/1165, which was released in Mopidy 1.0.5 a few mintues ago. Can you retry with that version?
Thanks a lot, @jodal ! Indeed, after the upgrade to 1.0.5, the javascript code displayed the name of the playlist correctly
However, I expected that the podcast episodes would then be added as tracks for that playlist. Currently, no tracks seem to be present in the playlist: the musicbox web client also shows the playlist, but no tracks. Is this by design? Anyway, I’ll try to look further into it tomorrow.
The API is a bit funny due to well legacy reasons. You have to create a new playlist model instance, then you can replace that tracks key with a new list of tracks. These also need to be valid models, so run the URIs through library.lookup to get them converted. Then once that is done you can call save on your modified playlist instance.
Longer term we really really hope to kill this form of the API, as it isn’t exactly nice to work with or explain.
which saves the current tracklist as a playlist. Note also that you don’t have to do a library.lookup necessarily; you can use any JS object that looks like a proper Track model to Mopidy, i.e. has uri, name and __model__ fields; see