From c44ffc4dfd5dbc72e5fb8292d7003c13e4e6ce41 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sat, 21 Jul 2018 15:41:35 +0200 Subject: [PATCH] do not hard code folder name --- drive-download | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drive-download b/drive-download index 6492ee7..73f75a5 100755 --- a/drive-download +++ b/drive-download @@ -1,12 +1,11 @@ #!/usr/bin/env python3 -FOLDER = 'scanbot' # XXX Should be arg - import sys if sys.version_info < (3, 3): sys.stderr.write("Sorry, requires at least Python 3.3\n") sys.exit(1) +import argparse import collections import os import pickle @@ -40,13 +39,17 @@ def folder_id(folder_name): def main(): global seen, drive + parser = argparse.ArgumentParser(description='Download files from a folder in Google Drive') + parser.add_argument('folder', type=str, help='folder to download from') + args = parser.parse_args() + read_seen() gauth = GoogleAuth(settings_file=os.path.expanduser('~/.config/drive-download/settings.yaml')) gauth.CommandLineAuth() drive = GoogleDrive(gauth) - file_query = "'%s' in parents and trashed=false" % folder_id(FOLDER) + file_query = "'%s' in parents and trashed=false" % folder_id(args.folder) file_list = drive.ListFile({'q': file_query}).GetList() file_names = [f['title'] for f in file_list]