mirror of
https://github.com/instaloader/instaloader.git
synced 2024-11-04 09:22:29 +01:00
Create session file with 600 permissions
Fixes #4. Also, default session filename is "less" hardcoded.
This commit is contained in:
parent
e2d8c34eac
commit
51822eaa66
@ -5,6 +5,8 @@ from io import BytesIO
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
DEFAULTSESSIONFILE = "/tmp/.instaloadersession"
|
||||||
|
|
||||||
class DownloaderException(Exception):
|
class DownloaderException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -119,13 +121,14 @@ def download_profilepic(name, url, quiet=False):
|
|||||||
|
|
||||||
def save_object(obj, filename):
|
def save_object(obj, filename):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = '/tmp/instaloader.session'
|
filename = DEFAULTSESSIONFILE
|
||||||
with open(filename, 'wb') as file:
|
with open(filename, 'wb') as file:
|
||||||
|
os.chmod(filename, 0o600)
|
||||||
shutil.copyfileobj(BytesIO(pickle.dumps(obj, -1)), file)
|
shutil.copyfileobj(BytesIO(pickle.dumps(obj, -1)), file)
|
||||||
|
|
||||||
def load_object(filename):
|
def load_object(filename):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = '/tmp/instaloader.session'
|
filename = DEFAULTSESSIONFILE
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
with open(filename, 'rb') as sessionfile:
|
with open(filename, 'rb') as sessionfile:
|
||||||
obj = pickle.load(sessionfile)
|
obj = pickle.load(sessionfile)
|
||||||
@ -263,7 +266,7 @@ def main():
|
|||||||
parser.add_argument('-p', '--password',
|
parser.add_argument('-p', '--password',
|
||||||
help='Provide password for your Instagram account')
|
help='Provide password for your Instagram account')
|
||||||
parser.add_argument('-f', '--sessionfile',
|
parser.add_argument('-f', '--sessionfile',
|
||||||
help='File to store session key, defaults to /tmp/instaloader.session')
|
help='File to store session key, defaults to '+DEFAULTSESSIONFILE)
|
||||||
parser.add_argument('-P', '--profile-pic-only', action='store_true',
|
parser.add_argument('-P', '--profile-pic-only', action='store_true',
|
||||||
help='Only download profile picture')
|
help='Only download profile picture')
|
||||||
parser.add_argument('-V', '--skip-videos', action='store_true',
|
parser.add_argument('-V', '--skip-videos', action='store_true',
|
||||||
|
Loading…
Reference in New Issue
Block a user