我剛剛查了一下週圍的Spotify的源代碼,發現這行代碼:什麼是hm://協議?
var ALBUM_URI = 'hm://album/v1/album-app/album/';
,我想知道這個hm://
協議是什麼。不幸的是,我沒有在谷歌上找到任何東西。
A code-snippet Context taken FROM HERE:
var live = require('spotify-live');
var Cosmos = require('spotify-cosmos-api');
var ALBUM_URI = 'hm://album/v1/album-app/album/';
var formatData = require('../data_formatters');
/**
* Album model contains all album data
* @param {string} albumURI The Spotify uri for an album to create a model.
*/
function AlbumModel(albumURI) {
this.albumURI = albumURI;
this.album = live(albumURI);
}
AlbumModel.prototype.init = function(callback) {
this.callback = callback;
var requestURI = ALBUM_URI + this.albumURI + '/desktop';
Cosmos.resolver.get(requestURI, this.prepareData.bind(this));
};
AlbumModel.prototype.prepareData = function(error, data) {
if (error) {
var errorStatusCode = error.response ? error.response.getStatusCode() : 500;
var simplifiedStatusCode = 400;
if (400 <= errorStatusCode && errorStatusCode <= 410) {
simplifiedStatusCode = 400;
} else if (500 <= errorStatusCode && errorStatusCode <= 503) {
simplifiedStatusCode = 500;
}
this.callback(simplifiedStatusCode, {});
return;
}
var albumData = data.getJSONBody();
albumData = formatData(albumData);
if (!this.album.get('rows')) {
this.album.update(albumData);
}
this.callback(null, albumData);
};
module.exports = AlbumModel;