dropcam

package module
v0.0.0-...-114bd38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2014 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

dropcam

usage: go get github.com/rabarar/dropcam

Dropcam Library 0.1 (Beta)

Based on the great work by Ryan Galloway (https://github.com/rsgalloway/dropcam), I've adopted this code for go.

http://godoc.org/github.com/rabarar/dropcam

How to use:

package main

import ( "github.com/rabarar/dropcam" "fmt" "time" ) import "os"

const ( USER = "DROPCAM_USER" PASS = "DROPCAM_PASS" )

func main() {

    u := os.Getenv(USER)
    p := os.Getenv(PASS)

    if u == "" || p == "" {
            fmt.Printf("need to set both %s and %s\n", USER, PASS)
            return
    }
    
    d, err := new(dropcam.Dropcam).Init(u, p)
    if err != nil {
            fmt.Printf("failed to Init Dropcam Credentials: %s\n", err)
            os.Exit(1)
    }

    c, err := d.Cameras()
    if err != nil {
            fmt.Printf("failed to Get Cameras: %s\n", err)
            os.Exit(1)
    }

    for j, owned := range c.Cam {
            fmt.Printf("%d: %s\n", j, owned.Title)
    }

    // Need to create a directory in the cwd called "images"
    // infinite loop - and  every 5 seconds write the images into the images file
    //
    
    for {
            fmt.Printf("***** GETTING Image **** \n")
            for i, o := range c.Cam {
                    fn := "./images/img-" + fmt.Sprintf("%d-", i) + fmt.Sprintf("%d", time.Now().Unix())
                    err = c.SaveImage(&o, fn, 720, time.Now())
                    if err != nil {
                            fmt.Printf("error saving image %d\n", i)
                    }
                    fmt.Printf("saved image %s\n", fn)
            }
            time.Sleep(5 * time.Second)
    }

}

Still need to add: Events and MediaStreaming

Documentation

Overview

Package dropcam implements a basic library to access DropCam cameras.

Index

Constants

View Source
const (
	NexusBase = "https://nexusapi.dropcam.com"
	ApiBase   = "https://www.dropcam.com"
	ApiPath   = "api/v1"
	Devel     = false
)

Constants

Variables

This section is empty.

Functions

func Dbg

func Dbg(format string, args ...interface{})

Types

type Cam

type Cam struct {
	Items []struct {
		Owned      []Owned       `json:"owned"`
		Subscribed []interface{} `json:"subscribed"`
	} `json:"items"`
	Status            int64  `json:"status"`
	StatusDescription string `json:"status_description"`
	StatusDetail      string `json:"status_detail"`
}

type CamProp

type CamProp struct {
	UUID  string `json:"camera_uuid"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Cameras

type Cameras struct {
	Dropcam *Dropcam
	Cam     []Owned
}

The Cameras type contains all of the user-owned dropcams associated with the Drocpam object

func (*Cameras) GetEvents

func (c *Cameras) GetEvents(o *Owned, st time.Time, et time.Time) ([]Events, error)

The GetEvents method will return an array of Events for the given timeframe

func (*Cameras) SaveImage

func (c *Cameras) SaveImage(o *Owned, path string, width int, st time.Time) error

The SaveImage method retrieves an image from a specifically Owned camera and writes it to disk.

func (*Cameras) SetProperties

func (c *Cameras) SetProperties(o *Owned, name string, value string) (bool, error)

The SetProperties method will set varias properties on an individual Owned Camera

type Dropcam

type Dropcam struct {
	LoginPath           string
	CamerasGet          string
	CamerasUpdate       string
	CamerasGetVisible   string
	CamerasGetImagePath string
	EventPath           string
	EventGetClipPath    string
	PropertiesPath      string

	Creds  UserCreds
	Cookie string
}

The DropCam type lists the URL acess points and contains the credentials and session cookie

func (*Dropcam) Cameras

func (d *Dropcam) Cameras() (*Cameras, error)

The Cameras method will return a list of DropCam cameras from the server. These are soley private cameras owned by the credentials.

func (*Dropcam) Init

func (d *Dropcam) Init(username string, password string) (*Dropcam, error)

Init is the method that passed the credentials to the dropcam server and receives back a session cookie for subsequent requests

type Events

type Events struct {
}

The Events type contains events for a specific camera over a defined epoch

type Items

type Items struct {
	Owned      []Owned       `json:"owned"`
	Subscribed []interface{} `json:"subscribed"`
}

type Owned

type Owned struct {
	Capabilities        []string    `json:"capabilities"`
	Description         string      `json:"description"`
	DownloadHost        string      `json:"download_host"`
	HasBundle           bool        `json:"has_bundle"`
	HoursOfRecordingMax float64     `json:"hours_of_recording_max"`
	Id                  int64       `json:"id"`
	IsConnected         bool        `json:"is_connected"`
	IsOnline            bool        `json:"is_online"`
	IsPublic            bool        `json:"is_public"`
	IsStreaming         bool        `json:"is_streaming"`
	IsStreamingEnabled  bool        `json:"is_streaming_enabled"`
	IsTrialMode         bool        `json:"is_trial_mode"`
	IsTrialWarning      bool        `json:"is_trial_warning"`
	LastLocalIp         string      `json:"last_local_ip"`
	LiveStreamHost      string      `json:"live_stream_host"`
	Location            interface{} `json:"location"`
	MacAddress          string      `json:"mac_address"`
	Name                string      `json:"name"`
	NestStructureId     interface{} `json:"nest_structure_id"`
	OwnerId             string      `json:"owner_id"`
	PublicToken         string      `json:"public_token"`
	Timezone            string      `json:"timezone"`
	TimezoneUtcOffset   int64       `json:"timezone_utc_offset"`
	Title               string      `json:"title"`
	TrialDaysLeft       int64       `json:"trial_days_left"`
	Type                int64       `json:"type"`
	Uuid                string      `json:"uuid"`
	Where               string      `json:"where"`
}

The Owned type contains the attribuetes associated with a users dropcam

type UserCreds

type UserCreds struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

The UserCreds contains the credentials sent to the DropCam URL

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址