Categorygithub.com/jeffreydwalter/arlo-go
modulepackage
0.0.0-20200420231349-d68ae1fb4cb7
Repository: https://github.com/jeffreydwalter/arlo-go.git
Documentation: pkg.go.dev

# README

arlo-go

Go Report Card

Go package for interacting with Netgear's Arlo camera system.


Now in Go!

I love Go. That is why I decided to write this library! I am the creator of the first arlo library written in Python.

My goal is to bring parity to the Python version asap. If you know what you're doing in Go, I would appreciate any feedback on the general structure of the library, bugs found, contributions, etc.


It is by no means complete, although it does expose quite a bit of the Arlo interface in an easy to use Go pacakge. As such, this package does not come with unit tests (feel free to add them, or I will eventually) or guarantees. All contributions are welcome and appreciated!

Please, feel free to contribute to this repo or buy Jeff a beer! Donate


Generous Benefactors (Thank you!)

No beers for Jeff yet! 🍺


Awesomely Smart Contributors (Thank you!)

  • bwagner5 - Dec 8, 2019 - Migrated package from dep to go modules.

If You'd like to make a diffrence in the world and get your name on this most prestegious list, have a look at our help wanted section!


Filing an Issue

Please read the Issue Guidelines and Policies wiki page BEFORE you file an issue. Thanks.


Install

# Install latest stable package
$ go get github.com/jeffreydwalter/arlo-go
package main

import (
	"fmt"
	"log"
	"sync"
	"time"

	"github.com/jeffreydwalter/arlo-go"
)

const (
	USERNAME = "[email protected]"
	PASSWORD = "supersecretpassword"
)

func main() {

	// Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached.
	// Subsequent successful calls to login will update the oAuth token.
	arlo, err := arlo.Login(USERNAME, PASSWORD)
	if err != nil {
		log.Printf("Failed to login: %s\n", err)
		return
	}
	// At this point you're logged into Arlo.

	now := time.Now()
	start := now.Add(-7 * 24 * time.Hour)

	// Get all of the recordings for a date range.
	library, err := arlo.GetLibrary(start, now)
	if err != nil {
		log.Println(err)
		return
	}

	// We need to wait for all of the recordings to download.
	var wg sync.WaitGroup

	for _, recording := range *library {

		// Let the wait group know about the go routine that we're about to run.
		wg.Add(1)

		// 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() {
			fileToWrite, err := os.Create(fmt.Sprintf("downloads/%s_%s.mp4", time.Unix(0, recording.UtcCreatedDate*int64(time.Millisecond)).Format(("2006-01-02_15.04.05")), recording.UniqueId))
            defer fileToWrite.Close()

            if err != nil {
                log.Fatal(err)
            }

			// The videos produced by Arlo are pretty small, even in their longest, best quality settings.
			// DownloadFile() efficiently streams the file from the http.Response.Body directly to a file.
			if err := arlo.DownloadFile(recording.PresignedContentUrl, fileToWrite); err != nil {
				log.Println(err)
			} else {
				log.Printf("Downloaded video %s from %s", recording.CreatedDate, recording.PresignedContentUrl)
			}

			// Mark this go routine as done in the wait group.
			wg.Done()
		}()
	}

	// Wait here until all of the go routines are done.
	wg.Wait()


    // The below example demonstrates how you could delete the cloud recordings after downloading them.
    // Simply uncomment the below code to start using it.

    // Delete all of the videos you just downloaded from the Arlo library.
	// Notice that you can pass the "library" object we got back from the GetLibrary() call.
	/* if err := arlo.BatchDeleteRecordings(library); err != nil {
		log.Println(err)
		return
	} */

	// If we made it here without an exception, then the videos were successfully deleted.
	/* log.Println("Batch deletion of videos completed successfully.") */
}

** (coming soon) For more code examples check out the wiki**

# Functions

No description provided by the author
No description provided by the author
No description provided by the author

# Constants

TODO: Implement all of the following urls.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Account is the account data.
No description provided by the author
No description provided by the author
AudioDetectionProperties is the Properties struct for the EventStreamPayload type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A Basestation is a Device that's not type "camera" (basestation, arloq, arloqs, etc.).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Connectivity is part of the Device data.
No description provided by the author
No description provided by the author
URL is part of the Status message fragment returned by most calls to the Arlo API.
A Device is the device data, this can be a camera, basestation, arloq, etc.
A DeviceOrder holds a map of device ids and a numeric index.
DeviceResponse is an intermediate struct used when parsing data from the GetDevices() call.
No description provided by the author
No description provided by the author
EventStreamPayload is the message that will be sent to the arlo servers via the /notify API.
No description provided by the author
No description provided by the author
Friend is the account data for non-primary account holders designated as friends.
LibraryMetaData is the library meta data.
LibraryMetaDataResponse is an intermediate struct used when parsing data from the GetLibraryMetaData() call.
No description provided by the author
LoginResponse is an intermediate struct used when parsing data from the Login() call.
No description provided by the author
MotionDetectionProperties is the Properties struct for the EventStreamPayload type.
No description provided by the author
No description provided by the author
Owner is the owner of a Device data.
No description provided by the author
No description provided by the author
Properties is the Device properties data.
presignedContentUrl is a link to the actual video in Amazon AWS.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Status is the message fragment returned from most http calls to the Arlo API.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

Basestations is a slice of Basestation objects.
A Camera is a Device of type "camera".
Cameras is a slice of Camera objects.
Devices is a slice of Device objects.
No description provided by the author