-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rekram1-node/working-lib
Finalizing 1st Complete version of the library
- Loading branch information
Showing
13 changed files
with
502 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Lint and Test before merging to main | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
|
||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.50.1 | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Test | ||
run: | | ||
go test -v ./... | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,87 @@ | ||
# blinkgo | ||
|
||
 | ||
[](https://goreportcard.com/report/github.com/rekram1-node/blinkgo) [](https://raw.githubusercontent.com/rekram1-node/blinkgo/main/LICENSE)  | ||
|
||
CURRENTLY INCOMPLETE, WILL BE READY FOR USAGE IN A COUPLE DAYS | ||
 | ||
|
||
Simple library for interacting with blink cameras, mainly: authentication, listing devices/networks/clips, and downloading clips from local storage | ||
|
||
This library was made for my purposes but if you would like to see more features open an issue and I will get to it | ||
|
||
## Installation | ||
Credit to MattTW, who's findings: [BlinkMonitorProtocol](https://github.com/MattTW/BlinkMonitorProtocol) I used to create this implementation | ||
|
||
## Features | ||
|
||
* authentication | ||
* read networks, cameras, sync modules | ||
* list videos | ||
* download videos | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
- [Go](https://go.dev/) | ||
|
||
### Getting blinkgo | ||
|
||
With [Go module](https://github.com/golang/go/wiki/Modules) support, simply add the following import | ||
|
||
```go | ||
import "github.com/rekram1-node/blinkgo/blink" | ||
``` | ||
|
||
to your code, and then `go [build|run|test]` will automatically fetch the necessary dependencies. | ||
|
||
Otherwise, run the following to install the `blinkgo` library | ||
|
||
```shell | ||
go get -u github.com/rekram1-node/blinkgo/blink | ||
$ go get -u github.com/rekram1-node/blinkgo/blink | ||
``` | ||
|
||
## Table of contents | ||
## Documentation | ||
|
||
* [authentication](#auth) | ||
* [fetch user info](#user) | ||
* [list cameras](#camera) | ||
* [download videos](#videos) | ||
Read the [documentation](https:/github.com/rekram1-node/blinkgo/docs/docs.md) for usage instructions | ||
|
||
## Usage | ||
|
||
```shell | ||
example | ||
## Authentication | ||
|
||
#### Simple login and 2FA verify pin | ||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/rekram1-node/blinkgo/blink" | ||
) | ||
|
||
func main() { | ||
email := "[email protected]" | ||
password := "PLEASE_DON'T_PLAINTEXT_REAL_PASSWORDS" | ||
|
||
// returns account object with: email, password, uuid | ||
account := blink.NewAccount(email, password) | ||
|
||
// this returns a login response that you can use | ||
// however, it is unneccessary for this example | ||
if _, err := account.Login(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Print("Enter Pin: ") | ||
var pin string | ||
fmt.Scanln(&pin) | ||
|
||
// this returns a verify pin response that you can use | ||
// however, it is unneccessary for this example | ||
if _, err = account.VerifyPin(pin); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
``` | ||
|
||
## Local Storage | ||
## Local-Storage | ||
|
||
I did not discover this myself, this is from [blinkpy](https://github.com/fronzbot/blinkpy) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package blink_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/rekram1-node/blinkgo/blink" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewAccount(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
fakeEmail string | ||
fakePass string | ||
expectedAccount *blink.Account | ||
}{ | ||
{ | ||
name: "NewAccount: Good Call", | ||
fakeEmail: "[email protected]", | ||
fakePass: "fakepassword", | ||
expectedAccount: &blink.Account{ | ||
Email: "[email protected]", | ||
Password: "fakepassword", | ||
}, | ||
}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
account := blink.NewAccount(test.fakeEmail, test.fakePass) | ||
assert.Equal(t, test.expectedAccount.Email, account.Email) | ||
assert.Equal(t, test.expectedAccount.Password, account.Password) | ||
assert.NotEqual(t, "", account.UniqueID) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package blink | ||
|
||
func (account *Account) GetSyncModules() error { | ||
manifest, err := account.GetManifest() | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
account.SyncModules = &manifest.SyncModules | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.