npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gopro-js

v0.2.3

Published

A Promise based JavaScript GoPro Controller/API Wrapper (Unofficial)

Downloads

14

Readme

GoPro JS

A Promise based JavaScript GoPro Controller/API Wrapper (Unofficial)

The Idea:

While checking for JavaScript solutions to control my GoPro I found out that the existing ones were too specific to one single model or even written in other languages.

Using ES6 I'm aiming to create a Proxy for different API's in a way that you only need to create an instance of the object and it will discover itself and use the proper API to communicate with the camera.

The API's will implement an interface, making it modularized and easy to mantain and extend. With this approach I'm hoping to be compatible with every model since it can hold different ways to interact with different models.

Initially I will focus on the HERO4 model since is the one I own. But I'm referencing my work on these open-source projects that explore and reverse engineer other models, making it more easy to implement them:

Installation

npm install gopro-js

Usage:

This package is Promise based, with a simplified chain workflow without the explicit then usage. Attention when using then or catch: The value returned is a new GoPro instance, with the last promise result attached to lastResult property!

import GoPro from 'gopro-js' // or const GoPro = require('gopro-js').default

const gp = new GoPro() // Instantiate
gp.mode('VIDEO') // Begin chaining (without then)
  .delay(1000) // Delays the next method
  .shutter(0, 2000) // Records 2s video after 0s delay
  .status('Storage.RemainingPhotos')
  .then(instance => { // Chaining with then **ATTENTION**
    // Get result of last execution using instance.lastResult
    const result = instance.lastResult
    console.log(`RemainingPhotos: ${result}`)
    // THEN and CATCH returns instance of GoPro to be used
    // DON'T use gp here, as it will break the chain!!
    if (result > 100) instance.mode('MULTISHOT', 'BURST')
    else instance.mode('PHOTO', 'NIGHT')
    instance.delay(5000)
  })
  .dummy() // Calls and unexistent method, throwing an error
  .catch(instance => {
    console.log(instance.lastResult.message) // dummy not defined for current API.
    // Catches the error and changes to other mode
    instance.mode('PHOTO', 'SINGLE')
  })
  .set('Photo.Resolution.R5MEDIUM') // Apply some setting
  .status('System.BUSY') // Check camera status
  .then(instance => {
    console.log(`Camera is ${instance.lastResult ? 'BUSY' : 'OK'}`)
  }) // Print previous result
  .shutter(2000) // Activate shutter after 2 seconds delay
  .set('Photo.Resolution.R12WIDE') // Apply some setting
  .listMedia()
  .then(({ lastResult }) => { // Accessing last result with Destructuring
    console.log(lastResult)
  })
  .deleteLast(2) // Deletes the last 2 files
  .powerOff() // Power Off
  .delay(5000)
  .powerOn() // Power On
import GoPro from 'gopro-js'

const gp = new GoPro({ mac: 'AA:BB:CC:DD:EE:FF'}) // Instantiate with a valid mac address
gp.powerOn().mode('VIDEO') // It can discover itself and powerOn

const gp2 =  new GoPro() // Or without mac(but already turned on) it can powerOn after a powerOff
gp2.powerOff().delay(5000).powerOn()