photolocations.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const stripAnsi = require('strip-ansi')
  2. const iPhoneBackup = require('../util/iphone_backup.js').iPhoneBackup
  3. const normalizeCols = require('../util/normalize.js')
  4. module.exports.name = 'photolocations'
  5. module.exports.description = 'List all geolocation information for iOS photos (iOS 10+)'
  6. module.exports.func = function (program, base) {
  7. if (!program.backup) {
  8. console.log('use -b or --backup <id> to specify backup.')
  9. process.exit(1)
  10. }
  11. // Grab the backup
  12. var backup = iPhoneBackup.fromID(program.backup, base)
  13. backup.getPhotoLocationHistory(program.dump)
  14. .then((history) => {
  15. if (program.dump) {
  16. console.log(JSON.stringify(history, null, 4))
  17. return
  18. }
  19. var items = history.map(el => [
  20. el.XFORMATTEDDATESTRING + '' || '',
  21. el.ZLATITUDE + '' || '',
  22. el.ZLONGITUDE + '' || '',
  23. el.ZFILENAME + '' || ''
  24. ])
  25. items = [['Time', 'Latitude', 'Longitude', 'Photo Name'], ['-', '-', '-'], ...items]
  26. items = normalizeCols(items).map(el => el.join(' | ').replace(/\n/g, '')).join('\n')
  27. if (!program.color) { items = stripAnsi(items) }
  28. console.log(items)
  29. })
  30. .catch((e) => {
  31. console.log('[!] Encountered an Error:', e)
  32. })
  33. }