Merge pull request #724 from vstrizhenok/master

added ca param on command line - good solution for #702
This commit is contained in:
Yuri Bochkarev 2019-12-16 21:40:54 +01:00 committed by GitHub
commit fa8f4d810f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View file

@ -280,6 +280,8 @@ class names, as well as any additional parameters:
General: coursera-dl -u <user> -p <pass> modelthinking-004
With CAUTH parameter: coursera-dl -ca 'some-ca-value-from-browser' modelthinking-004
If you don't want to type your password in command line as plain text, you can use the script without `-p` option. In this case you will be prompted for password once the script is run.
Without -p field: coursera-dl -u <user> modelthinking-004

View file

@ -341,6 +341,14 @@ def parse_args(args=None):
group_adv_auth = parser.add_argument_group(
'Advanced authentication options')
group_adv_auth.add_argument(
'-ca',
'--cauth',
dest='cookies_cauth',
action='store',
default=None,
help='cauth cookie value from browser')
group_adv_auth.add_argument(
'-c',
'--cookies_file',
@ -492,7 +500,7 @@ def parse_args(args=None):
logging.error('Cookies file not found: %s', args.cookies_file)
sys.exit(1)
if not args.cookies_file:
if not args.cookies_file and not args.cookies_cauth:
try:
args.username, args.password = get_credentials(
username=args.username, password=args.password,

View file

@ -233,7 +233,10 @@ def main():
return
session = get_session()
login(session, args.username, args.password)
if args.cookies_cauth:
session.cookies.set('CAUTH', args.cookies_cauth)
else:
login(session, args.username, args.password)
if args.specialization:
args.class_names = expand_specializations(session, args.class_names)