Home

Awesome

OneDrive-uploader for Yi IP Cameras

To visitors and cloners:

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.

Features

Supported camera models

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.

How to use the uploader?

Prerequisites

  1. make sure you've hacked your camera with the matched firmware, please check yi-hack-MStar or yi-hack-Allwinner-v2
  2. you have an OneDrive account assosiated with your Microsoft Azure account, you'd better have some knowledge of using the Azure portal.

Create Azure application for your uploader

  1. use App registrations to register an application on Azure portal
  1. set up the required Graph API permissions
  1. get your application client id, and tenant id (used for tenant account only, ignore it for personal account) Get application id and tenant id

  2. create a client secret and save the secret Value for next steps Get client credential

  3. Authentication setting for personal account type only Authentication

Use the repository code and setup on your camera

  1. clone the repository code to your local computer and enter the code directory
  2. use the data fetched from Azure application to fill in your 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 keyDefault valueDescription
grant_typeauthorization_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
scopehttps://graph.microsoft.com/.defaultnot required
video_root_folderyihack_videosname string without white spaces
upload_video_onlytruenot required; set it false will upload *.jpg files in the record folders
convert_utc_path_namefalsenot 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_threshold100value in range [50, 100) will enable this feature
enable_idle_transferfalsesetting to true has chances of files upload delayed
  1. 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:

    • create an empty directory named onedrive in path /tmp/sd/yi-hack
    • upload init.sh, stop.sh and scripts and bin directory to /tmp/sd/yi-hack/onedrive
    • upload your own config.json file to /tmp/sd/yi-hack/onedrive
  2. sign in your Microsoft Azure account first

  3. run the entry Shell script init.sh to complete the application authorization grant flow

cd /tmp/sd/yi-hack/onedrive/
./init.sh

Ahthorize uploader

  1. optional: reboot your camera
reboot -f # reboot without -f option cannot work on my camera

Maintenance

cd /tmp/sd/yi-hack/onedrive
./stop.sh
rm -rf data
rm -rf log
./init.sh  
reboot -f
./init.sh
reboot -f