Get single image from nest-camera - google-api

Using the new Device Access for Google Nest Cameras there is a trait available to get an image from the camera - however the question is, how you can get the download-url for a non-event-based image?
I've tried:
curl -X POST \
'https://smartdevicemanagement.googleapis.com/v1/enterprises/project-id/devices/device-id:executeCommand' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer access-token' \
--data-raw '{
"command" : "sdm.devices.commands.CameraImage",
"params" : {}
}'
Which is unfortunately not working

It only shows the supported resolution.
Currently you can only get a snapshot from an event.
I got it working, but it's a bit too slow for my use-case: 'downloading a snapshot for a push-notification when someone rings my (classic) doorbell'
[edit]
I have a workaround by grabbing a single frame of the RTSP stream:
ffmpeg -y -loglevel fatal -rtsp_transport tcp -i rtsps://stream-eu1-delta.dropcam.com:443/sdm_live_stream/... -frames:v 2 -r 1 -s 1920x1280 snapshot.jpg
delay 2-5 seconds.

Related

Video Upload to imgur failed successfully via using curl

Image upload via curl works perfectly, but not for videos.
The imgur api documentation is outdated does not seem to work with video files.
The video file is fairy small, it's .mp4 file and the imgur api simply returns null errorcode.
Check the windows curl example below.
Before testing the code below, remember:
Insert your Client-ID into YOUR_CLIENT_ID
Adjust the file path of -F "video=#
Requirements curl:
Latest Windows 10 operating system that includes curl.exe binary.
Linux Distribution with curl binary.
Windows Batch script example.
save it with a file extension yourfilename.bat or yourfilename.cmd
#ECHO OFF
curl --request POST --url "https://api.imgur.com/3/image" --header "Authorization: Client-ID YOUR_CLIENT_ID" --header "content-type: multipart/form-data;" -F "name=testuploadname" -F "description=sdfdsf" -F "type=file" -F "video=#C:\Users\Windows10\Desktop\5757578.mp4" -F "disable_audio=1"
PAUSE
Output, video upload failed due to null errorcode:
{"data":{"errorCode":null,"ticket":"0c328b47"},"success":true,"status":200}
curl -X POST -H "Authorization: Bearer YOURTOKEN" -F "video=#C:\Users\Windows10\Desktop\75427.mp4" https://api.imgur.com/3/upload

Sending large file as data inside JSON via cURL

I'm trying to send a file as base64-encoded data via POST to the Bugzilla REST API as follows:
curl -X POST https://www.example.com/rest/bug/$id/attachment -H "Content-Type: application/json" \
-d "{\
\"login\" : \"$username\", \
\"password\" : \"$password\", \
\"ids\" : [ $id ], \
\"summary\" : \"...\", \
\"content_type\" : \"application/gzip\", \
\"data\" : \"$data\"\
}"
What I'm getting is an error from cURL that the argument list is too long. Presumably, this is because the file ($data) I'm trying to send is more than the shell maximum (the file is 11M). What I've seen online is that the best way to get around that is to have cURL read the data from a file using --data-binary. But since I need to send a username and password, I'd prefer not to have to save the entire file with them inside.
Is there some way to get around this maximum, or is there another way to send a large amount of data this way? I prefer native Linux tools, as I want this script to be portable.
You can try using a file like this, which is the recommended way.
curl -i \
-H 'Accept:application/json' \
-H 'Authorization:Basic $username:$password' \
-X POST -d #datafile.txt https://www.example.com/rest/bug/$id/attachment

How to upload a file to a slack channel using a bot

I have a slack bot and the token starting with xoxb is used to upload a file to a channel.
I am using below format
curl -F token="${SLACK_TOKEN}" -F file=e2e.sh -F channel="${SLACK_CHANNEL}" -F as_user=true https://slack.com/api/files.upload
This throws
{"ok":false,"error":"no_file_data"}
You are missing the # in your file=e2e.sh argument to let curl know you want to transmit a file. The following should do the trick:
curl \
-F token="${SLACK_TOKEN}" \
-F file=#e2e.sh \
-F channel="${SLACK_CHANNEL}" \
-F as_user=true \
https://slack.com/api/files.upload
p.s. Breaking a long curl into multiple lines can help you see things more clearly ;)

Run multiple cURL requests in Windows

I am able to execute the below cURL request (generated in PostMan) through a Git Bash in windows, and receive a response as expected.
curl -X GET \ https://test.amazon.com/production/john.stones \
-H 'authorization: Bearer dfgjdrjkdrt' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: 53a3fs9a-5ce3-10fe-7f0a-33e9695ec514' \
-H 'referer: king'
I wish to run multiple cURL requests, around a thousand like the above, with the name being the value that changes in each request. I tried placing them into a batch file but each line is taken as a command, so a bit unsure as to how to structure them. Anyone know how I can run multiple cURL requests, either in sequence or parallel, in Windows 10?
I have addressed this by listing each cURL request in a batch file, replacing all single quotes with double and removed all '\' generated in Postman to divide headers. Only after this does windows run the requests successfully.

Yammer Activity changes Message

Is it possible to use a URL in both a message and an activity in Yammer ?
Using the messages API, it is possible to construct a message which is:
Properly linked (in this example clicking on Title goes to example.com/id/1/); and
Includes an image (placehold.it/100x100).
For example:
#!/bin/bash
GROUP={GROUP}
TOKEN={TOKEN}
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
--data "body=hello" \
--data "group_id=$GROUP" \
--data "og_fetch=false" \
--data "og_url=http%3A%2F%2Fwww.example.com%2Fid%2F2%2F" \
--data "og_title=Title" \
--data "og_image=http%3A%2F%2Fplacehold.it%2F100x100" \
--data "og_description=Description" \
--data "og_object_type=page" \
--data "og_private=true" \
https://www.yammer.com/api/v1/messages.json
Using the activity API it is possible to make an Open Graph object:
Example:
#!/bin/bash
TOKEN={TOKEN}
EMAIL={EMAIL}
curl -X POST \
-H "Content-type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"activity":{"actor":{"email":"'$EMAIL'"},"action":"create","object":{"url":"http://www.example.com/id/1/","image":"http://placehold.it/110x110","title":"Title","type":"page"}},"private":"false","message":"This is an update"}' \
https://www.yammer.com/api/v1/activity.json
The problem is that now the original message from Step 1:
No longer links to the actual content (it links to https://www.yammer.com/{network}/graph/{id})
Loses its image (it is now mug0.assets-yammer.com/mugshot/images/75x75/3rd_party.png)
As an aside, the open graph object doesn't update for the new image provided in the activity post (110x110 vs 100x100). The docs (https://developer.yammer.com/v1.0/docs/open-graph) say "when an OG object exists (with the same URL), it is updated appropriately."
In one example you have the open graph object set to private and the other is to public. That may be causing the weird issue you are seeing.
"og_private=true"

Resources