Notebook
# code from https://github.com/speedenator/smuploader/blob/master/bin/smregister # modified for python 3.6/jupyter environment - modifications assisted by 2to3 tool # NOTE: this code cell has been turned into Raw NBConvert to prevent accidental execution # if you need to run this code turn this cell back into code. from rauth.service import OAuth1Service import requests import http.client import httplib2 import hashlib import urllib.request, urllib.parse, urllib.error import time import sys import os import json import configparser import re import shutil # depends on previously run cells #from smuploader import SmugMug def write_config(configfile, params): config = configparser.ConfigParser() config.add_section('SMUGMUG') for key, value in params: config.set('SMUGMUG', key, value) with open(SmugMug.smugmug_config, 'w') as f: config.write(f) if __name__ == '__main__': print("\n\n\n#######################################################") print("## Welcome! ") print("## We are going to go through some steps to set up this SmugMug photo manager and make it connect to the API.") print("## Step 0: What is your SmugMug username?") username = input("Username: ") print('## Step 1: Enter your local directory, e.g. c:/SmugMirror/') localdir = input("Directory: ") print("## Step 2: Go to https://api.smugmug.com/api/developer/apply and apply for an API key.") print("## This gives you unique identifiers for connecting to SmugMug.") print("## When done, you can find the API keys in your SmugMug profile.") print("## Account Settings -> Me -> API Keys") print(("## Enter them here and they will be saved to the config file (" + SmugMug.smugmug_config + ") for later use.")) consumer_key = input("Key: ") consumer_secret = input("Secret: ") write_config(SmugMug.smugmug_config, [("username", username), ("consumer_key", consumer_key), ("consumer_secret", consumer_secret), ("access_token", ''), ("access_token_secret", '')]) smugmug = SmugMug() authorize_url = smugmug.get_authorize_url() print(("## Step 2: Visit this address in your browser to authenticate your new keys for access your SmugMug account: \n## " + authorize_url)) print("## After that, enter the 6-digit key that SmugMug provided") verifier = input("6-digit key: ") access_token, access_token_secret = smugmug.get_access_token(verifier) write_config(SmugMug.smugmug_config, [("username", username), ("consumer_key", consumer_key), ("consumer_secret", consumer_secret), ("access_token", access_token), ("access_token_secret", access_token_secret)]) print("## Great! All done!")