_setResultsByPlaylist: function(playlistId) { // https://github.com/MeoMix/StreamusChromeExtension/issues/567 var pendingRequest = YouTubeV3API.getPlaylistSongs({ playlistId: playlistId, success: this._onGetPlaylistSongsSuccess.bind(this, playlistId), error: this._onSearchError.bind(this) }); this.set('pendingRequest', pendingRequest); },
_setResultsByPlaylist: function(playlistId) { // TODO: This is not DRY with how a Playlist loads its songs internally, how can I share the logic? var pendingRequest = YouTubeV3API.getPlaylistSongs({ playlistId: playlistId, success: this._onGetPlaylistSongsSuccess.bind(this, playlistId), error: this._onSearchError.bind(this) }); this.set('pendingRequest', pendingRequest); },
_onAddSongsByDataSourceSuccess: function(nextPageToken) { if (_.isUndefined(nextPageToken)) { this.set('dataSourceLoaded', true); } else { // Request next batch of data by iteration once addItems has succeeded. YouTubeV3API.getPlaylistSongs({ playlistId: this.get('dataSource').get('id'), pageToken: nextPageToken, success: this._onGetPlaylistSongsSuccess.bind(this) }); } },
_onGetPlaylistSongsSuccess: function(playlistId, response) { this.get('results').addSongs(response.songs); if (!_.isUndefined(response.nextPageToken)) { var pendingRequest = YouTubeV3API.getPlaylistSongs({ playlistId: playlistId, pageToken: response.nextPageToken, success: this._onGetPlaylistSongsSuccess.bind(this, playlistId), error: this._onSearchError.bind(this) }); this.set('pendingRequest', pendingRequest); } else { this.set('pendingRequest', null); } },
loadDataSource: function() { YouTubeV3API.getPlaylistSongs({ playlistId: this.get('dataSource').get('id'), success: this._onGetPlaylistSongsSuccess.bind(this) }); },