summaryrefslogtreecommitdiff
path: root/download-videos-gopro.py
diff options
context:
space:
mode:
Diffstat (limited to 'download-videos-gopro.py')
-rwxr-xr-xdownload-videos-gopro.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/download-videos-gopro.py b/download-videos-gopro.py
new file mode 100755
index 0000000..11edc82
--- /dev/null
+++ b/download-videos-gopro.py
@@ -0,0 +1,34 @@
+#! /usr/bin/python3
+import os
+from shutil import copyfile
+import sys
+from pathlib import Path
+if os.path.exists(sys.argv[1]):
+ path = os.path.abspath(sys.argv[1])
+else:
+ print("Cannot find " + sys.argv[1])
+ exit()
+with open('/home/lxf/.videogoprorc', 'r') as f:
+ lastfile = str(f.readline().rstrip())
+sorter = []
+for (dirname, dirs, files) in os.walk(path):
+ dirn = os.path.abspath(dirname)
+ for filename in files:
+ if Path(filename).suffix == '.MP4':
+ video = filename.split('.MP4')[0]
+ video_num = video[2:]
+ print(video, video_num)
+ if int(video_num) > int(lastfile.split('.MP4')[0][2:]):
+ sorter.append([int(filename.split('.MP4')[0][2:]), filename])
+for f in sorted(sorter):
+ dest = '/home/lxf/videos/inbox/'
+ if not os.path.exists(dest):
+ os.makedirs(dest)
+ print("copying:", dirn+'/'+f[1], "--->", dest+f[1])
+ copyfile(dirn+'/'+f[1], dest+f[1])
+ try:
+ out = sorted(sorter)[-1]
+ with open('/home/lxf/.videogoprorc', 'w') as f:
+ f.write(out[1])
+ except IndexError:
+ pass