Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. flickr = require './flickr'
  2. photos = flickr.results.photos.photo
  3.  
  4. # Example input object
  5. ###
  6. id: 6711220011
  7. owner: 43769855@N02
  8. secret: fa596d04c5
  9. server: 7162
  10. farm: 8
  11. title: 109
  12. ispublic: 1
  13. isfriend: 0
  14. isfamily": 0
  15. ###
  16.  
  17. # Example target object
  18. ###
  19. id: "5681612321"
  20. image: "http://farm6.static.flickr.com/5188/5681612321_681b61281e_z.jpg"
  21. thumbnail: "http://farm6.static.flickr.com/5188/5681612321_681b61281e_s.jpg"
  22. ###
  23.  
  24. new_photos = []
  25.  
  26. console.log 'mapping', photos.length, 'original photos'
  27.  
  28. for p in photos
  29.   new_photos.push
  30.     id: p.id
  31.     image: "http://farm#{p.farm}.staticflickr.com/#{p.server}/#{p.id}_#{p.secret}_z.jpg"
  32.     thumbnail: "http://farm#{p.farm}.staticflickr.com/#{p.server}/#{p.id}_#{p.secret}_s.jpg"
  33.  
  34. console.log 'done.\n', JSON.stringify new_photos