def get_url()

in scripts/maintenance/get_urls.py [0:0]


def get_url(p_id, object_name):
  headers = {
    'Authorization': 'Bearer {:s}'.format(os.environ['DROPBOX_APP_KEY']),
    'Content-Type': 'application/json',
  }
  d = deepcopy(data_template)
  d['path'] = d['path'].format(p_id, object_name)
  filename = '/tmp/tmpurl.json'
  with open(filename, 'w') as f:
    json.dump(d, f)
  r = requests.post('https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings', data=open(filename), headers=headers)
  if r.status_code != 200:
    print('Unsuccessful, return status = {:d}'.format(r.status_code))
    return
  url = r.json()['url']
  url = url.replace('dl=0', 'dl=1')
  filename = osp.join('data', 'urls.json')
  with open(filename, 'r') as f:
    d = json.load(f)
  if p_id not in d['videos']['color']:
    d['videos']['color'][p_id] = {}
  d['videos']['color'][p_id][object_name] = url
  with open(filename, 'w') as f:
    json.dump(d, f, indent=4, separators=(', ', ': '))