From 6da79dc3149e6552f5ec6ed71e8c206733de10b6 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 26 Dec 2018 08:31:46 +1000 Subject: [PATCH 01/14] Update DownloadFile method to use generic http.Get() We do this to avoid the customised http client setting incorrect headers (which are only needed for Arlo webiste) when fetching the files from Amazon S3 --- util.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util.go b/util.go index d5b167f..ab34034 100644 --- a/util.go +++ b/util.go @@ -103,10 +103,12 @@ func (a *Arlo) DownloadFile(url, to string) error { func (a *Arlo) DownloadFile(url string, w io.Writer) error { msg := fmt.Sprintf("failed to download file (%s)", url) - resp, err := a.get(url, "", nil) + + resp, err := http.Get(url) if err != nil { return errors.WithMessage(err, msg) } + defer resp.Body.Close() _, err = io.Copy(w, resp.Body) From f63e3d3d7de9bd8405926b88d87c47cfe5d87720 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 26 Dec 2018 08:41:50 +1000 Subject: [PATCH 02/14] fix the code example in the readme the example for downloading files doesn't match the parameters we need to provide for the DownloadFile method --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9383afa..a1db1f4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # arlo-go -![](gopher-arlo.png) +![](gopher-arlo.png) > Go package for interacting with Netgear's Arlo camera system. --- @@ -92,14 +92,19 @@ func main() { // 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) + 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, fmt.Sprintf("videos/%s", filename)); err != nil { + if err := arlo.DownloadFile(recording.PresignedContentUrl, fileToWrite); err != nil { log.Println(err) } else { - log.Printf("Downloaded video %s from %s", recording.CreatedDate) + log.Printf("Downloaded video %s from %s", recording.CreatedDate, recording.PresignedContentUrl) } // Mark this go routine as done in the wait group. From cc96ca736fcf67ce67340ca811df55d18fa54503 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 30 Mar 2019 19:36:48 +1000 Subject: [PATCH 03/14] comment out batch deleting vides; resolves #9 --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a1db1f4..7b5fb26 100644 --- a/README.md +++ b/README.md @@ -115,15 +115,19 @@ func main() { // Wait here until all of the go routines are done. wg.Wait() - // Delete all of the videos you just downloaded from the Arlo library. + + // 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 { + /* 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.") + /* log.Println("Batch deletion of videos completed successfully.") */ } ``` From 63d275ee101095ccd970fb38ada7514be6763e12 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 30 Mar 2019 19:41:48 +1000 Subject: [PATCH 04/14] add godoc.org badge; resolves #8 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a1db1f4..907fe19 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # arlo-go +![](https://godoc.org/github.com/jeffreydwalter/arlo-go?status.svg) + ![](gopher-arlo.png) > Go package for interacting with Netgear's Arlo camera system. From 87f23fe55a1a5ac57ab195b76dac252f5da2d670 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 30 Mar 2019 19:46:45 +1000 Subject: [PATCH 05/14] remove openssl references; resolves #7 --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index a1db1f4..3520482 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,6 @@ $ go get github.com/jeffreydwalter/arlo-go # Note: This package uses the `go dep` package for dependency management. If you plan on contributing to this package, you will be required to use [dep](https://github.com/golang/dep). Setting it up is outside the scope of this README, but if you want to contribute and aren't familiar with `dep`, I'm happy to get you. ``` -**NOTE 1:** arlo.netgear.com requires TLS 1.2 for their API. So, if you're getting ssl errors, it's most likely related to your version of openssl. You may need to upgrade your openssl library. -If you're running this library on OSX or macOS, they ship with `openssl v0.9.x` which does not support TLS 1.2. You should follow the instructions found [here](https://comeroutewithme.com/2016/03/13/python-osx-openssl-issue/) to upgrade your openssl library. - After installing all of the required libraries, you can import and use this library like so: ```golang From 5c2aa930515d1cdae00bccd0be88422bf6a3511e Mon Sep 17 00:00:00 2001 From: James Date: Sat, 30 Mar 2019 19:56:50 +1000 Subject: [PATCH 06/14] remove unused UnixMicro and UnixMilli functions; resolves #12 --- util.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/util.go b/util.go index ab34034..a8fdb0d 100644 --- a/util.go +++ b/util.go @@ -119,22 +119,6 @@ func (a *Arlo) DownloadFile(url string, w io.Writer) error { return nil } -func UnixMicro(t time.Time) int64 { - ns := t.UnixNano() - if ns < 0 { - return (ns - 999) / 1000 - } - return ns / 1000 -} - -func UnixMilli(t time.Time) int64 { - ns := t.UnixNano() - if ns < 0 { - return (ns - 999999) / 1000000 - } - return ns / 1000000 -} - func FromUnixMicro(µs int64) time.Time { return time.Unix(0, 1000*µs) } func FromUnixMilli(ms int64) time.Time { return time.Unix(0, 1000000*ms) } From 8802c6224c772dd74e5ad00de98575ec8f658257 Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Thu, 10 Oct 2019 23:48:35 +0300 Subject: [PATCH 07/14] Fix a couple of issues reported by go-vet. --- types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types.go b/types.go index 3335799..c885c2b 100644 --- a/types.go +++ b/types.go @@ -62,7 +62,7 @@ type Account struct { type AppStore struct { Enforce bool `json:"enforce"` LatestVersion string `json:"latestVersion"` - updateLink string `json:"updateLink"` + UpdateLink string `json:"updateLink"` } type Session struct { @@ -235,7 +235,7 @@ type BaseNightLightProperties struct { Brightness int `json:"brightness,omitempty"` Enabled bool `json:"enabled"` Mode string `json:"mode,omitempty"` - RGB NightLightRGBProperties `json:"mode,omitempty"` + RGB NightLightRGBProperties `json:"rgb,omitempty"` SleepTime int64 `json:"sleepTime,omitempty"` SleepTimeRel int `json:"sleepTimeRel,omitempty"` } From 55af80f02f49202c905b71fbe6c56626f172f159 Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Fri, 11 Oct 2019 00:09:07 +0300 Subject: [PATCH 08/14] Update base url to my.arlo.com. --- const.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/const.go b/const.go index b55273e..5d9ac78 100644 --- a/const.go +++ b/const.go @@ -25,7 +25,7 @@ const ( DeviceTypeSiren = "siren" TransIdPrefix = "web" - BaseUrl = "https://arlo.netgear.com/hmsweb" + BaseUrl = "https://my.arlo.com/hmsweb" // TODO: Implement all of the following urls. There are many here I don't have devices for. :/ ActiveAutomationUri = "/users/devices/automation/active" From bc0a605676982281471c5e35159e119a6dd8b93c Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Fri, 11 Oct 2019 00:10:15 +0300 Subject: [PATCH 09/14] Update url to my.arlo.com. --- arlo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arlo.go b/arlo.go index b9dd95a..35ba064 100644 --- a/arlo.go +++ b/arlo.go @@ -43,8 +43,8 @@ func newArlo(user string, pass string) (arlo *Arlo) { baseHeaders := make(http.Header) baseHeaders.Add("DNT", "1") baseHeaders.Add("schemaVersion", "1") - baseHeaders.Add("Host", "arlo.netgear.com") - baseHeaders.Add("Referer", "https://arlo.netgear.com/") + baseHeaders.Add("Host", "my.arlo.com") + baseHeaders.Add("Referer", "https://my.arlo.com/") c, _ := request.NewClient(BaseUrl, baseHeaders) From e064b6ecb31698d9b46ec4f00af67258b2e065ba Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Fri, 11 Oct 2019 00:19:22 +0300 Subject: [PATCH 10/14] Fix formatting. --- events_stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events_stream.go b/events_stream.go index 3ea05a1..e027eea 100644 --- a/events_stream.go +++ b/events_stream.go @@ -111,7 +111,7 @@ func (e *eventStream) listen() (connected chan bool) { connected <- true } else if notifyResponse.Status == "disconnected" { e.disconnect() - } else if notifyResponse.Action == "logout" { + } else if notifyResponse.Action == "logout" { e.disconnect() } else { e.subscriptions.rwmutex.RLock() From 77feb88c14f91f1a8adb6bbac0c19c3887179d56 Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Fri, 11 Oct 2019 00:23:51 +0300 Subject: [PATCH 11/14] gofmt events_stream.go. --- events_stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events_stream.go b/events_stream.go index e027eea..32fd2c7 100644 --- a/events_stream.go +++ b/events_stream.go @@ -111,7 +111,7 @@ func (e *eventStream) listen() (connected chan bool) { connected <- true } else if notifyResponse.Status == "disconnected" { e.disconnect() - } else if notifyResponse.Action == "logout" { + } else if notifyResponse.Action == "logout" { e.disconnect() } else { e.subscriptions.rwmutex.RLock() From db15c4d9244aa8f5767682a1d73ca692a7c35b8b Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Fri, 11 Oct 2019 00:25:12 +0300 Subject: [PATCH 12/14] Add go report card to the README. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index db11a0a..09cfd33 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # arlo-go ![](https://godoc.org/github.com/jeffreydwalter/arlo-go?status.svg) +[![Go Report Card](https://goreportcard.com/badge/github.com/jeffreydwalter/arlo-go)](https://goreportcard.com/report/github.com/jeffreydwalter/arlo-go) ![](gopher-arlo.png) > Go package for interacting with Netgear's Arlo camera system. From 04a016bc13b9c122338b4df252e6de3684e610a7 Mon Sep 17 00:00:00 2001 From: Brandon Wagner Date: Sun, 1 Dec 2019 09:34:44 -0600 Subject: [PATCH 13/14] convert to use go mods for deps --- Gopkg.toml | 34 ---------------------------------- Makefile | 12 ++++++++++++ README.md | 4 ---- go.mod | 9 +++++++++ go.sum | 18 ++++++++++++++++++ 5 files changed, 39 insertions(+), 38 deletions(-) delete mode 100644 Gopkg.toml create mode 100644 Makefile create mode 100644 go.mod create mode 100644 go.sum diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index f0df04d..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,34 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - branch = "master" - name = "github.com/mitchellh/mapstructure" - -[[constraint]] - branch = "master" - name = "github.com/pkg/errors" - -[[constraint]] - branch = "master" - name = "github.com/r3labs/sse" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..10f5540 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ + +all: test build + +build: + go build -v ./... + +test: + go test -v ./... + +clean: + go clean + diff --git a/README.md b/README.md index 09cfd33..1e53b0e 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,8 @@ Please read the [Issue Guidelines and Policies](https://github.com/jeffreydwalte ```bash # Install latest stable package $ go get github.com/jeffreydwalter/arlo-go - -# Note: This package uses the `go dep` package for dependency management. If you plan on contributing to this package, you will be required to use [dep](https://github.com/golang/dep). Setting it up is outside the scope of this README, but if you want to contribute and aren't familiar with `dep`, I'm happy to get you. ``` -After installing all of the required libraries, you can import and use this library like so: - ```golang package main diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..59590de --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/jeffreydwalter/arlo-go + +go 1.13 + +require ( + github.com/pkg/errors v0.8.1 + github.com/r3labs/sse v0.0.0-20191120111931-24eacf438413 + golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..92f762f --- /dev/null +++ b/go.sum @@ -0,0 +1,18 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/r3labs/sse v0.0.0-20191120111931-24eacf438413 h1:bF3heZD0lrJF16uVKKJsorZjBS7ET5Y9QKYtgno7X4Q= +github.com/r3labs/sse v0.0.0-20191120111931-24eacf438413/go.mod h1:S8xSOnV3CgpNrWd0GQ/OoQfMtlg2uPRSuTzcSGrzwK8= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 h1:e6HwijUxhDe+hPNjZQQn9bA5PW3vNmnN64U2ZW759Lk= +golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= +gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From de23738a294803510e4b19f974fca68f10c935bc Mon Sep 17 00:00:00 2001 From: Jeffrey Walter Date: Sun, 8 Dec 2019 23:19:36 -0600 Subject: [PATCH 14/14] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1e53b0e..400381b 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ My goal is to bring parity to the Python version asap. If you know what you're d --- 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](https://github.com/jeffreydwalter/arlo/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) are welcome and appreciated!** +**All [contributions](https://github.com/jeffreydwalter/arlo-go/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) are welcome and appreciated!** -**Please, feel free to [contribute](https://github.com/jeffreydwalter/arlo/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) to this repo or buy Jeff a beer!** [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=R77B7UXMLA6ML&lc=US&item_name=Jeff%20Needs%20Beer&item_number=buyjeffabeer¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) +**Please, feel free to [contribute](https://github.com/jeffreydwalter/arlo-go/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) to this repo or buy Jeff a beer!** [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=R77B7UXMLA6ML&lc=US&item_name=Jeff%20Needs%20Beer&item_number=buyjeffabeer¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) --- ### Generous Benefactors (Thank you!) @@ -23,13 +23,13 @@ No beers for Jeff yet! 🍺 --- ### Awesomely Smart Contributors (Thank you!) -Just me so far... +* [bwagner5](https://github.com/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](https://github.com/jeffreydwalter/arlo/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) section! +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](https://github.com/jeffreydwalter/arlo-go/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) section! --- ### Filing an Issue -Please read the [Issue Guidelines and Policies](https://github.com/jeffreydwalter/arlo/wiki/Issue-Guidelines-and-Policies) wiki page **BEFORE** you file an issue. Thanks. +Please read the [Issue Guidelines and Policies](https://github.com/jeffreydwalter/arlo-go/wiki/Issue-Guidelines-and-Policies) wiki page **BEFORE** you file an issue. Thanks. ---