mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
@@ -22,14 +22,15 @@ def print_json(object_value, spacing=''):
|
||||
return
|
||||
if spacing:
|
||||
sys.stdout.write('\n')
|
||||
for i in range(0, len(object_value)):
|
||||
if isinstance(object_value[i], (str, int, bool)):
|
||||
for i, a_value in enumerate(object_value):
|
||||
if isinstance(a_value, (str, int, bool)):
|
||||
sys.stdout.write(f' {spacing}{i+1}) {a_value}\n')
|
||||
else:
|
||||
sys.stdout.write(f' {spacing}{i+1}) ')
|
||||
print_json(object_value[i], f' {spacing}')
|
||||
print_json(a_value, f' {spacing}')
|
||||
elif isinstance(object_value, dict):
|
||||
[object_value.pop(key, None) for key in ['kind', 'etag', 'etags']]
|
||||
for key in ['kind', 'etag', 'etags']:
|
||||
object_value.pop(key, None)
|
||||
for another_object, another_value in object_value.items():
|
||||
sys.stdout.write(f' {spacing}{another_object}: ')
|
||||
print_json(another_value, f' {spacing}')
|
||||
|
||||
@@ -7367,13 +7367,13 @@ def shorten_url(long_url):
|
||||
try:
|
||||
resp, content = simplehttp.request(url_shortnr, 'POST',
|
||||
f'{{"long_url": "{long_url}"}}', headers=headers)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return long_url
|
||||
if resp.status != 200:
|
||||
return long_url
|
||||
try:
|
||||
return json.loads(content).get('short_url', long_url)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
print(content)
|
||||
return long_url
|
||||
|
||||
|
||||
Reference in New Issue
Block a user