Browse Source

centralize flickr ID extraction

pull/557/head
Joe Germuska 11 years ago
parent
commit
847635f648
  1. 13
      source/js/Core/Media/VMM.ExternalAPI.js
  2. 4
      source/js/Core/Media/VMM.MediaType.js

13
source/js/Core/Media/VMM.ExternalAPI.js

@ -1127,7 +1127,7 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
var the_url = "//api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + api_key + "&photo_id=" + m.id + "&format=json&jsoncallback=?";
VMM.getJSON(the_url, function(d) {
var flickr_id = d.sizes.size[0].url.split("photos\/")[1].split("/")[1];
var flickr_id = VMM.ExternalAPI.flickr.getFlickrIdFromUrl(d.sizes.size[0].url);
var flickr_large_id = "#" + m.uid,
flickr_thumb_id = "#" + m.uid + "_thumb";
@ -1193,8 +1193,17 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
}
return _size;
}
},
getFlickrIdFromUrl: function(url) {
var idx = url.indexOf("flickr.com/photos/");
if (idx == -1) return null;
var pos = idx + "flickr.com/photos/".length;
var photo_info = url.substr(pos)
if (photo_info.indexOf('/') == -1) return null;
if (photo_info.indexOf('/') == 0) photo_info = photo_info.substr(1);
return photo_info.split("/")[1];
}
},
instagram: {

4
source/js/Core/Media/VMM.MediaType.js

@ -86,9 +86,7 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
success = true;
} else if (d.match("flickr.com/photos/")) {
media.type = "flickr";
var pos = d.indexOf("flickr.com/photos/") + "flickr.com/photos/".length;
var photo_info = d.substr(pos)
media.id = photo_info.split("/")[1];
media.id = VMM.ExternalAPI.flickr.getFlickrIdFromUrl(d)
media.link = d;
success = Boolean(media.id);
} else if (d.match("instagr.am/p/")) {

Loading…
Cancel
Save