-
Notifications
You must be signed in to change notification settings - Fork 26
/
listmedia.js
49 lines (38 loc) · 1.45 KB
/
listmedia.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var GoPro = require('../lib/index.js');
var cam = new GoPro.Camera();
/*
** List all the media
*/
cam.listMedia().then(function (result) {
/*
** For each directory the camera has
** I haven't seen more than one
*/
result.media.forEach(function (directory) {
console.log('[directory] =', directory.d);
/*
** For each file in this directory
*/
directory.fs.forEach(function (file) {
var dateTaken = new Date(file.mod * 1000); /* x1000 timestamp unix > timestamp ms */
var size = file.s / 1000000; /* byte to mb */
var name = file.n; /* filename */
if (file.g !== undefined) { // burst
var burstId = file.g;
var startingId = file.b;
var endId = file.l;
// Format = G + burstId(3 digits) + pictureId (4 digits)
// pictureId = range between startingId and endId
//
// Example: for [burstId = 5] [startingId = 20] [endId = 28]
//
// G0050020.JPG -----> G0050028.JPG
var numberOfPics = (endId - startingId) + 1;
// Some fields are unknown
// file.t ? values I have seen: 'b' 't'
// file.m ? always an empty array
}
console.log('[url] = ', 'http://' + cam._ip + '/videos/DCIM/' + directory.d + '/' + file.n);
});
});
});