Git Product home page Git Product logo

xiaomi_gdrive's Introduction

Google drive loader for xiaomi smart ip camera

Google drive loader for xiaomi smart ip camera (12CN). xiaomi_gdrive let you automatically upload your videos from xiaomi smart ip camera to your google drive account. Also it can automatically remove old files from your google drive account to prevent space exhaustion.

ants_smart_webcam_ xiaomi

Step-by-step instruction for installing xiaomi_gdrive

  1. Turn off your camera and get microSD
  2. Download xiaomi_gdrive and unzip it (https://github.com/porunov/xiaomi_gdrive/releases/download/0.0.5/xiaomi_gdrive.zip)
  3. Copy next folders into your microSD:
test
gdrive
  1. If you want to set the time when your GDrive can interact with the Internet (i.e. send or remove files to Google Drive) you can change change the time in GDriveAutoremover and GDriveUploader files. If you want to let the camera interact with the Internet 24 hour/day (immediately send a video after it is recorded) then skip this step. If you still want to change the time then open your GDriveUploader script and change start_time and finish_time variables to whatever you want in the next format: HH:MM:SS. To do it find the next line:
start_time="00:00:00"

and change the time in this line to whatever you want. Example 7:35:00 pm will be:

start_time="19:35:00"

Then find the next line:

finish_time="23:59:59"

and change it to whatever you want. Example 01:00:05 am will be:

finish_time="01:00:05"

Your camera will be able to interact with the Internet from start_time to finish_time.

  1. Put microSD into your camera
  2. Turn on camera
  3. After turnung on a camera use telnet to connect to your camera (login: root, password: 1234qwer):
telnet {YOUR_CAMERA_IP_ADDRESS}
Example: telnet 192.168.0.70
  1. Go to the browser

  2. Create your Google Drive application and OAuth keys for Google Drive API (example tutorial: http://www.iperiusbackup.net/en/how-to-enable-google-drive-api-and-get-client-credentials/)

    Example:

    1. Go to Google Api Console (https://console.developers.google.com/?hl=RU)
    2. Click "Drive API"
    3. Clieck "Create project" and create it (if don't have one)
    4. Click "Enable"
    5. Go to Credentials and add credentials to your project
      1. Where will you be calling the API from? : Other UI (e.g. Windows, CLI tool)
      2. What data will you be accessing? : User data
      3. Click "What credentials do I need?"
      4. Name your credentials as you want
      5. Product name shown to users - use any name
      6. Click "Done"
    6. Click on your credentials
    7. Save your client id and client secret
  3. Go to your console back

  4. Run GDriveConf to configure your Google Drive access:

sh /home/hd1/gdrive/GDriveConf
  1. Paste your client id and press enter
  2. Paste your client secret and press enter
  3. Copy link which you see and paste into your browser
  4. Click "Accept"
  5. Copy code which you see
  6. Go to your console back
  7. Paste your code and press enter
  8. You will be suggested to see the folders. Press Enter if you want to see all folders. If you want to see only root folders type root and press Enter.
    //Folders showing isn't fast. Wait for 5-10 seconds to see your directories.
  9. You will see your folders (number of folder is on the left side)
  10. Type the number of a folder and press Enter. (If you want to save videos in the root dir then just press Enter)
  11. You will be asked if you want to turn on automatic remove. Press 1 and type Enter if you want. Press 0 and type Enter if you do not want. GDriveAutoremover itself will delete old files in case if your disk space overflows.
  12. Reboot your camera:
reboot
  1. Done

How it works: The script in the loop will create the same folders as in the record folder and upload videos into Google Drive. After the reboot, or failure of the Internet script continues normally send files. If you have enabled automatic remove, GDriveAutoremover will check your free space every 45 minutes. In case when disk space is not enough, the script will erase old videos (IMPORTANT: do not put anything extra in the folder which is designed for video because GDriveAutoremover can remove it if it considers that the disk space is not enough).

This scripts were tested under 1.8.5.1L firmware

Troubleshooting:

  1. Your camera starts reboot from time to time. Your RAM is likely not enough. Turn off additional features which you have installed.

    1. Turn off ftp server:

      rm /etc/init.d/S89ftp
      
    2. Turn off HTTP server

      rm /home/web/server
      rm /home/web/record
      
    3. Turn off RTSP server

      rm /home/rtspsvr
      mv /home/recv_X.726 /home/recv.726
      
    4. Reboot your camera

      reboot
      
  2. Check if camera can send requests to the Internet.

    ping -q -c2 8.8.8.8
    ping -q -c2 google.com
    

    if it isn't pingable then check your route table:

    route -n
    
    1. If your gateway isn't correct then add your gateway (Where 192.168.0.1 is your router IP address):

      my_router_ip="192.168.0.1"
      route add default gw ${my_router_ip} ra0
      
    2. To have normal gateway after reboot run all next commands:

      echo "#!/bin/sh" > /etc/init.d/S65route
      echo "change_def_route(){" >> /etc/init.d/S65route
      echo "route add default gw ${my_router_ip} ra0" >> /etc/init.d/S65route
      echo "}" >> /etc/init.d/S65route
      echo "change_def_route &" >> /etc/init.d/S65route
      echo "exit 0" >> /etc/init.d/S65route
      chmod +x vi /etc/init.d/S65route
      echo "${my_router_ip}" > /tmp/gw1
      
    3. Add public DNS

      echo "nameserver 8.8.8.8" > /var/run/dhcpcd/resolv.conf/resolv.conf
      echo "nameserver 8.8.8.8" > /etc/resolv.conf
      
    4. Reboot your camera

      reboot
      

xiaomi_gdrive's People

Contributors

popadko avatar porunov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xiaomi_gdrive's Issues

don't work on cameras 27US release

Hi!
Script don't work on new cameras american release.
They changed firmware - so new path to card (that is small problem, easy fix) and busybox (egrep don't work now, so script crashes)

curl with more protocols

Hi Alexandr!

Nice work, could you try to compile curl with more protocols enabled? Or tell me where you got it from? SMTP would be neat to play with..

BR

Config Issues

I am having trouble configuring the gdrive.

Every time i try to configure it comes back with an error saying illegal insturction. The grep is unable to read a response from the response folder.

Ip Adress

Where can I find the IP Adress? I tried all sorts of software but with no luck.

Feature request: uploading not *.mp4 files

Is it possible to add support for automatic upload of files other than *.mp4? It could be very useful to upload some stats - uptime, free space etc...

I've put text.txt in the /home/hd1/record/ and it didn't got uploaded to GDrive, instead it created the folder named text.txt in GDrive.

Feature request: email notification

Would you mind adding email notification when motion file detected (maybe with the link to GDrive)?

Since you're already dealing with google token, I guess it would be not that hard to add.

Why is it needed? Original Yi Home app sometimes are really laggy. But gmail delivers really fast.

Thanks a lot! I hope it is not much to ask =)

Deleting the content of recordings

Hi, what to add to the file so that it does not use all the free gdrive space, only the specified after exceeding it, deleted the content. The camera collapses my disk space unnecessarily. Please help

Feature request: uploading filename xxxxYxxMxxDxxHxxM.mp4 files

Is it possible to add support for automatically uploading the file name xxxxYxxMxxDxxHxxM.mp4 instead of the current xxMxxS.mp4 filename? It can be very useful when saving .mp4 files or when importing to youtube.com

Youtube is now for importing your videos from Google Photos
ย  Https://www.youtube.com/upload and Youtube video editing https://www.youtube.com/editor to merge multiple * .mp4 files but the current xxHxxS.mp4 files make it difficult to select File xxHxxS.mp4
Therefore, it is desirable to name the file * .mp4 format as xxxxYxxMxxDxxHxxM.mp4

curl not work

The curl returns

./curl: can't load library 'libz.so.1'

Help me please

11-18 point - GDriveConf: line 59: /home/hd1/gdrive/./curl: not found

Hi,

I have problem with your "xiaomi_gdrive". In point 11 If I run sh GDriveConf.
First It script has problem with create files (but I think that it's not problem because I see these files on camera memory via FTP).
Configuration is started. Wait for several seconds. cp: can't create '/home/libusr/libz.so': No such file or directory cp: can't create '/home/libusr/libz.so.1': No such file or directory cp: can't create '/home/libusr/libz.so.1.2.8': No such file or directory chmod: /home/libusr/libz.so*: No such file or directory Enter your Client ID:
If I provide Client ID and Client secret I have link to google, next If I provide code from google I have next error:
GDriveConf: line 59: /home/hd1/gdrive/./curl: not found grep: /home/hd1/gdrive/conf/response: No such file or directory grep: /home/hd1/gdrive/conf/response: No such file or directory Your code was expired or it is not correct. Please refresh a link in your browser and enter a new valid code

Could you help me with this?
I have yi camera 1080p 9FUS.
Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.