This repository is inspired by roleoroleo's yi-hack-MStar.gdrive uploader. The gdrive uploader does provide some convenience, however, my Google drive has only 15GB space shared with Gmail and other account applications, and it is very easy to get storage fully packed with uploaded media files. Fortunately, I've subscribed Microsoft 365 Developer Program which provides 5TB storage space. I think uploading files to OneDrive is a better option for me.
If you have a subscription of Microsoft OneDrive Stroage or Microsoft 365 Developer Program, you will get more storage space, which can allow you to store your camera videos and pictures to it other than paying an expensive manufacturer's storage premium plan.
Yi cameras hacked with the same file hiearacy or builtin applications are more likely to be supported. Anyway, your own separate tests are necessary before you use it. I've tested on my own camera.
use App registrations to register an application on Azure portal
Supported account types
choice: choose Accounts in this organizational directory only
if your are a Azure Directory Single tenant; choose Personal Microsoft accounts only
if you are using your own Personal OneDrive.WEB
type and put a live redirectable URL, you can clone OAuth2 callback and use the code to serve a local redirect url http://localhost:8080/callback
set up the required Graph API permissions
Files.ReadWrite.All
Files.ReadWrite
and Files.ReadWrite.All
get your application client id, and tenant id (used for tenant account only, ignore it for personal account)
create a client secret and save the secret Value for next steps
Authentication setting for personal account type only
config.json
file before uploading the files to camera. Please refer to the following example to edit the config.json
file in your directory:
{
"grant_type": "authorization_code",
"client_id": "9083c44f-605d-4d31-9d16-955e48d69965",
"client_secret": "dFE8Q~bUtscYyoTUCxt3RLawrfsnyVGARFhGdcH7",
"tenant_id": "e2a801f7-46fe-4dcf-91b7-6d4409c7760e",
"scope": "https://graph.microsoft.com/.default",
"video_root_folder": "yihack_videos",
"convert_utc_path_name": "false",
"auto_clean_threshold": "100",
"enable_idle_transfer": "false"
}
Configuration key | Default value | Description |
---|---|---|
grant_type | authorization_code | |
client_id | "" | fill in with your data |
client_secret | "" | fill in with your data |
tenant_id | "" | for personal account, set it as "consumers"; for tenant account, set a specific tenant id |
scope | https://graph.microsoft.com/.default | not required |
video_root_folder | yihack_videos | name string without white spaces |
upload_video_only | true | not required; set it false will upload *.jpg files in the record folders |
convert_utc_path_name | false | not required; set it to true if you don't like the uploaded folders are in UTC time (for firmware v0.4.9 and later) |
auto_clean_threshold | 100 | value in range [50, 100) will enable this feature |
enable_idle_transfer | false | setting to true has chances of files upload delayed |
upload code and dependent files to your camera sd card via ssh
with root
account or a FTP tool, the target path: /tmp/sd/yi-hack
:
onedrive
in path /tmp/sd/yi-hack
init.sh
, stop.sh
and scripts
and bin
directory to /tmp/sd/yi-hack/onedrive
config.json
file to /tmp/sd/yi-hack/onedrive
sign in your Microsoft Azure account first
run the entry Shell script init.sh
to complete the application authorization grant flow
cd /tmp/sd/yi-hack/onedrive/
./init.sh
curl: option --data-binary: out of memory
is tolerable and has no issue to the file upload.
reboot -f # reboot without -f option cannot work on my camera
stop.sh
script to kill the running uploader.cd /tmp/sd/yi-hack/onedrive
./stop.sh
You might have messed up the configuration or you are not content with the running situation, you want to start again from the beginning.
data/last_upload.json
if you want the uploader to resume your uploading without any repetitive uploads);./init.sh
again to get your access tokens again;rm -rf data
rm -rf log
./init.sh
reboot -f
config.json
, or replace it with a new one as well.Once you have deleted data
directory or changed application credentials in config.json
files, you must run the init.sh
script manually to setup or reload your uploader again.
./init.sh
reboot -f
:warning: be cautious to delete file ./data/last_upload.json
if you want to restart the uploader and resume the upload to avoid repeatitive upload of all recorded files.