refactor media import

This commit is contained in:
j 2019-01-28 12:35:16 +05:30
parent 79d0d8e290
commit e0163ed881

View file

@ -82,7 +82,7 @@ pandora.ui.importMediaDialog = function(options) {
width: 544
});
function addMedia(url, callback) {
function getMediaUrlInfo(url, callback) {
pandora.api.getMediaUrlInfo({url: url}, function(result) {
// FIXME: support playlists / multiple items
var info = result.data.items[0];
@ -116,6 +116,12 @@ pandora.ui.importMediaDialog = function(options) {
}
return value;
});
callback(values, info)
});
}
function addMedia(url, callback) {
getMediaUrlInfo(url, function(values, info) {
pandora.api.add({title: values.title || info.title}, function(result) {
var edit = Ox.extend(
Ox.filter(values, function(value, key) {