porunov / xiaomi_gdrive

Google drive loader for xiaomi smart ip camera
MIT License
79 stars 28 forks source link

Feature request: uploading not *.mp4 files #1

Open Yury-MonZon opened 8 years ago

Yury-MonZon commented 8 years ago

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.

porunov commented 8 years ago

Yes, it is possible to upload other files rather than .mp4. To support it you should remove an operator 'if' for mp4 in GDriveUploader script:

line 100 remove: && [ "$(echo -n $n | tail -c 4)" = ".mp4" ] line 130 remove: if [ "$(echo -n $n | tail -c 4)" = ".mp4" ]; then line 133 remove: fi

But I don't recommend to do this. When your camera is working it creates and removes temporary files (other than mp4). It will cause the problem that you will see unuseful files in your Google Drive folder.

You shouldn't put anything additional in the /home/hd1/record/. Camera is waiting for new folders in that folder, so when it see something in that folder it creates a folder with the same name in your Google Drive folder.

Yury-MonZon commented 8 years ago

What if I change the line [ "$(echo -n $n | tail -c 4)" = ".mp4" ] to [[ "$(echo -n $n | tail -c 4)" = ".mp4" ] || [ "$(echo -n $n | tail -c 4)" = ".log" ]]. I'm not a bash coder at all, please, correct me - I'm guesstimating with my C knowledge here. So will it work for *.log as well?

About folders stuff - can't I create /home/hd1/record/log folder and put all my logs in here, so they will be synchronised?

porunov commented 8 years ago
  1. Yes. But without additional brackets. It must be like this: [ "$(echo -n $n | tail -c 4)" = ".mp4" ] || [ "$(echo -n $n | tail -c 4)" = ".log" ]
  2. Unfortunately, no. It won't work. It will upload or files in the folder 'log' and then continue to upload other folders. It won't return back to 'log' folder again.

It is better to create additional scripts to upload other stuff in parallel.

Yury-MonZon commented 8 years ago

Thanks!

What if my script is going to create a folder with every_time_new_random_name and log file inside it every time I need it? will your script detect it?

porunov commented 8 years ago

It depends on the folder name. Every time your script creates a folder it have to use the name like: 2016Y10M22D18H_log

Where "2016Y10M22D18H" is the current year, month, day and hour. This folder will be uploaded when 19 hour starts.