Fix minor issues regarding last commit
- Close session from InstaloaderContext.anonymous_copy(). - Have graphql_count_per_slidingwindow default value in one place rather than three.
This commit is contained in:
parent
3211d63ec1
commit
52eb6d8e27
@ -271,7 +271,7 @@ def main():
|
|||||||
g_how.add_argument('--user-agent',
|
g_how.add_argument('--user-agent',
|
||||||
help='User Agent to use for HTTP requests. Defaults to \'{}\'.'.format(default_user_agent()))
|
help='User Agent to use for HTTP requests. Defaults to \'{}\'.'.format(default_user_agent()))
|
||||||
g_how.add_argument('-S', '--no-sleep', action='store_true', help=SUPPRESS)
|
g_how.add_argument('-S', '--no-sleep', action='store_true', help=SUPPRESS)
|
||||||
g_how.add_argument('--graphql-rate-limit', type=int, default=20, help=SUPPRESS)
|
g_how.add_argument('--graphql-rate-limit', type=int, help=SUPPRESS)
|
||||||
g_how.add_argument('--max-connection-attempts', metavar='N', type=int, default=3,
|
g_how.add_argument('--max-connection-attempts', metavar='N', type=int, default=3,
|
||||||
help='Maximum number of connection attempts until a request is aborted. Defaults to 3. If a '
|
help='Maximum number of connection attempts until a request is aborted. Defaults to 3. If a '
|
||||||
'connection fails, it can be manually skipped by hitting CTRL+C. Set this to 0 to retry '
|
'connection fails, it can be manually skipped by hitting CTRL+C. Set this to 0 to retry '
|
||||||
|
@ -106,7 +106,7 @@ class Instaloader:
|
|||||||
compress_json: bool = True,
|
compress_json: bool = True,
|
||||||
post_metadata_txt_pattern: str = None,
|
post_metadata_txt_pattern: str = None,
|
||||||
storyitem_metadata_txt_pattern: str = None,
|
storyitem_metadata_txt_pattern: str = None,
|
||||||
graphql_rate_limit: int = 20,
|
graphql_rate_limit: Optional[int] = None,
|
||||||
max_connection_attempts: int = 3):
|
max_connection_attempts: int = 3):
|
||||||
|
|
||||||
self.context = InstaloaderContext(sleep, quiet, user_agent, graphql_rate_limit, max_connection_attempts)
|
self.context = InstaloaderContext(sleep, quiet, user_agent, graphql_rate_limit, max_connection_attempts)
|
||||||
|
@ -47,7 +47,7 @@ class InstaloaderContext:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, sleep: bool = True, quiet: bool = False, user_agent: Optional[str] = None,
|
def __init__(self, sleep: bool = True, quiet: bool = False, user_agent: Optional[str] = None,
|
||||||
graphql_count_per_slidingwindow: int = 20, max_connection_attempts: int = 3):
|
graphql_count_per_slidingwindow: Optional[int] = None, max_connection_attempts: int = 3):
|
||||||
|
|
||||||
self.user_agent = user_agent if user_agent is not None else default_user_agent()
|
self.user_agent = user_agent if user_agent is not None else default_user_agent()
|
||||||
self._session = self.get_anonymous_session()
|
self._session = self.get_anonymous_session()
|
||||||
@ -56,8 +56,7 @@ class InstaloaderContext:
|
|||||||
self.quiet = quiet
|
self.quiet = quiet
|
||||||
self.max_connection_attempts = max_connection_attempts
|
self.max_connection_attempts = max_connection_attempts
|
||||||
self._graphql_page_length = 50
|
self._graphql_page_length = 50
|
||||||
self.graphql_count_per_slidingwindow = graphql_count_per_slidingwindow \
|
self.graphql_count_per_slidingwindow = graphql_count_per_slidingwindow or 20
|
||||||
if graphql_count_per_slidingwindow else 20
|
|
||||||
self._root_rhx_gis = None
|
self._root_rhx_gis = None
|
||||||
|
|
||||||
# error log, filled with error() and printed at the end of Instaloader.main()
|
# error log, filled with error() and printed at the end of Instaloader.main()
|
||||||
@ -76,6 +75,7 @@ class InstaloaderContext:
|
|||||||
self._session = self.get_anonymous_session()
|
self._session = self.get_anonymous_session()
|
||||||
self.username = None
|
self.username = None
|
||||||
yield self
|
yield self
|
||||||
|
self._session.close()
|
||||||
self.username = username
|
self.username = username
|
||||||
self._session = session
|
self._session = session
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user