summaryrefslogtreecommitdiff
path: root/download-videos.py
diff options
context:
space:
mode:
Diffstat (limited to 'download-videos.py')
-rwxr-xr-x[-rw-r--r--]download-videos.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/download-videos.py b/download-videos.py
index 194edf1..cdf7c8b 100644..100755
--- a/download-videos.py
+++ b/download-videos.py
@@ -2,28 +2,31 @@
import os
from shutil import copyfile
import sys
+
+home_directory = os.path.expanduser('~')
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:
+with open(os.path.join(home_directory, '.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])
+ if filename.endswith('.MP4'):
+ if int(filename.split('C')[1].split(".MP4")[0]) > int(lastfile.split('C')[1].split(".MP4")[0]):
+ sorter.append([int(filename.split('C')[1].split(".MP4")[0]), filename])
for f in sorted(sorter):
- dest = '/home/lxf/videos/inbox/'
+ dest = os.path.join(home_directory, '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])
+ copyfile(dirn+'/'+f[1], os.path.join(dest, f[1]))
try:
out = sorted(sorter)[-1]
- with open('/home/lxf/.videocopyrc', 'w') as f:
+ with open(os.path.join(home_directory, '.videocopyrc'), 'w') as f:
f.write(out[1])
except IndexError:
pass