Update README.md
This commit is contained in:
parent
ca2ff36131
commit
542e59f9ea
43
README.md
43
README.md
@ -47,20 +47,18 @@ After installing all of the required libraries, you can import and use this libr
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jeffreydwalter/arlo-golang"
|
"github.com/jeffreydwalter/arlo-golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
const oneDay = 24 * time.Hour
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
USERNAME = 'user@example.com'
|
USERNAME = "user@example.com"
|
||||||
PASSWORD = 'supersecretpassword'
|
PASSWORD = "supersecretpassword"
|
||||||
|
|
||||||
|
oneDay = 24 * time.Hour
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -69,33 +67,38 @@ func main() {
|
|||||||
// Subsequent successful calls to login will update the oAuth token.
|
// Subsequent successful calls to login will update the oAuth token.
|
||||||
arlo, err := arlo.Login(USERNAME, PASSWORD)
|
arlo, err := arlo.Login(USERNAME, PASSWORD)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to login: %s\n", err)
|
log.Printf("Failed to login: %s\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// At this point you're logged into Arlo.
|
// At this point you're logged into Arlo.
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
start := now.Sub(7 * oneDay)
|
start := now.Add(-7 * oneDay)
|
||||||
|
|
||||||
// Get all of the recordings for a date range.
|
// Get all of the recordings for a date range.
|
||||||
library, err := arlo.GetLibrary(start, now)
|
library, err := arlo.GetLibrary(start, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, recording := range *library {
|
for _, recording := range *library {
|
||||||
filename := fmt.Sprintf("%s %s.mp4", time.Unix(0, recording.UtcCreatedDate*int64(time.Millisecond)).Format(("2006-01-02 15:04:05")), recording.UniqueId)
|
|
||||||
|
// The go func() here makes this script download the files concurrently.
|
||||||
|
// If you want to download them serially for some reason, just remove the go func() call.
|
||||||
|
go func() {
|
||||||
|
filename := fmt.Sprintf("%s %s.mp4", time.Unix(0, recording.UtcCreatedDate*int64(time.Millisecond)).Format(("2006-01-02 15:04:05")), recording.UniqueId)
|
||||||
|
|
||||||
// The videos produced by Arlo are pretty small, even in their longest, best quality settings,
|
// The videos produced by Arlo are pretty small, even in their longest, best quality settings,
|
||||||
// but you should probably prefer the chunked stream (see below).
|
// but you should probably prefer the chunked stream (see below).
|
||||||
|
|
||||||
// Download the whole video into memory as a single chunk.
|
// Download the whole video into memory as a single chunk.
|
||||||
if err := arlo.DownloadFile(recording.PresignedContentUrl, fmt.Sprintf("videos/%s", filename)); err != nil {
|
if err := arlo.DownloadFile(recording.PresignedContentUrl, fmt.Sprintf("videos/%s", filename)); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Downloaded video %s from %s", recording.CreatedDate)
|
log.Printf("Downloaded video %s from %s", recording.CreatedDate)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all of the videos you just downloaded from the Arlo library.
|
// Delete all of the videos you just downloaded from the Arlo library.
|
||||||
|
Loading…
Reference in New Issue
Block a user