|
|
@ -37,24 +37,27 @@ def folder_id(folder_name):
|
|
|
|
return file1['id']
|
|
|
|
return file1['id']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
read_seen()
|
|
|
|
def main():
|
|
|
|
|
|
|
|
global seen, drive
|
|
|
|
|
|
|
|
|
|
|
|
gauth = GoogleAuth(settings_file=os.path.expanduser('~/.config/drive-download/settings.yaml'))
|
|
|
|
read_seen()
|
|
|
|
gauth.CommandLineAuth()
|
|
|
|
|
|
|
|
drive = GoogleDrive(gauth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_query = "'%s' in parents and trashed=false" % folder_id(FOLDER)
|
|
|
|
gauth = GoogleAuth(settings_file=os.path.expanduser('~/.config/drive-download/settings.yaml'))
|
|
|
|
file_list = drive.ListFile({'q': file_query}).GetList()
|
|
|
|
gauth.CommandLineAuth()
|
|
|
|
|
|
|
|
drive = GoogleDrive(gauth)
|
|
|
|
|
|
|
|
|
|
|
|
file_names = [f['title'] for f in file_list]
|
|
|
|
file_query = "'%s' in parents and trashed=false" % folder_id(FOLDER)
|
|
|
|
file_names_dupes = [f for f, count in collections.Counter(file_names).items() if count > 1]
|
|
|
|
file_list = drive.ListFile({'q': file_query}).GetList()
|
|
|
|
if len(file_names_dupes) > 0:
|
|
|
|
|
|
|
|
|
|
|
|
file_names = [f['title'] for f in file_list]
|
|
|
|
|
|
|
|
file_names_dupes = [f for f, count in collections.Counter(file_names).items() if count > 1]
|
|
|
|
|
|
|
|
if len(file_names_dupes) > 0:
|
|
|
|
print('Duplicate filenames on Drive!')
|
|
|
|
print('Duplicate filenames on Drive!')
|
|
|
|
for fn in sorted(file_names_dupes):
|
|
|
|
for fn in sorted(file_names_dupes):
|
|
|
|
print(fn)
|
|
|
|
print(shlex.quote(fn))
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
for file1 in file_list:
|
|
|
|
for file1 in file_list:
|
|
|
|
if file1['mimeType'] == 'application/vnd.google-apps.folder':
|
|
|
|
if file1['mimeType'] == 'application/vnd.google-apps.folder':
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
if file1['id'] in seen: # XXX could update the file if it needs updating
|
|
|
|
if file1['id'] in seen: # XXX could update the file if it needs updating
|
|
|
@ -70,4 +73,7 @@ for file1 in file_list:
|
|
|
|
print("{} exists locally!".format(shlex.quote(local_filename)))
|
|
|
|
print("{} exists locally!".format(shlex.quote(local_filename)))
|
|
|
|
sys.exit(2)
|
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
|
|
# vim:tw=100:
|
|
|
|
# vim:tw=100:
|
|
|
|