diff options
author | luxagraf <sng@luxagraf.net> | 2020-02-16 15:57:40 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2020-02-16 15:57:40 -0500 |
commit | 2a9538f7711dcea71ba5702ca94a9d9c00287ea4 (patch) | |
tree | e0fe5ea7c909b01e10bf6a8dd4abcb619b6924c9 /bin/download-videos.py | |
parent | 3165ef5abdb298108efa2ba3d339f70ca966315a (diff) |
added the rest of bin
Diffstat (limited to 'bin/download-videos.py')
-rw-r--r-- | bin/download-videos.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/download-videos.py b/bin/download-videos.py new file mode 100644 index 0000000..194edf1 --- /dev/null +++ b/bin/download-videos.py @@ -0,0 +1,29 @@ +#! /bin/python +import os +from shutil import copyfile +import sys +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/.videocopyrc', '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 int(filename.split('.MTS')[0]) > int(lastfile.split('.MTS')[0]): + sorter.append([int(filename.split('.MTS')[0]), 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/.videocopyrc', 'w') as f: + f.write(out[1]) + except IndexError: + pass |