Monkeypatch use_ssl_unverified_context for SSL issues (fictionpad.com)

This commit is contained in:
Jim Miller 2015-02-21 10:47:25 -06:00
parent 269b732928
commit 94ea4c9dcf
2 changed files with 14 additions and 3 deletions

View file

@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2014, Jim Miller'
__copyright__ = '2015, Jim Miller'
__copyright__ = '2011, Grant Drake <grant.drake@gmail.com>'
__docformat__ = 'restructuredtext en'
@ -112,7 +112,15 @@ def do_download_for_worker(book,options,notification=lambda x,y:x):
configuration = get_ffdl_config(book['url'],
options['fileform'],
options['personal.ini'])
if configuration.getConfig('use_ssl_unverified_context'):
## monkey patch to avoid SSL bug. dupliated from
## ffdl_plugin.py because bg jobs run in own process
## space.
import ssl
if hasattr(ssl, '_create_unverified_context'):
ssl._create_default_https_context = ssl._create_unverified_context
if not options['updateepubcover'] and 'epub_for_update' in book and options['collision'] in (UPDATE, UPDATEALWAYS):
configuration.set("overrides","never_make_cover","true")

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Fanficdownloader team
# Copyright 2015 Fanficdownloader team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -94,6 +94,8 @@ def get_valid_set_options():
'strip_chapter_numbers':(None,None,boollist),
'titlepage_use_table':(None,None,boollist),
'use_ssl_unverified_context':(None,None,boollist),
'add_chapter_numbers':(None,None,boollist+['toconly']),
'check_next_chapter':(['fanfiction.net'],None,boollist),
@ -253,6 +255,7 @@ def get_valid_keywords():
'tocpage_start',
'tweak_fg_sleep',
'universe_as_series',
'use_ssl_unverified_context',
'user_agent',
'username',
'website_encodings',