Skip to content

Instantly share code, notes, and snippets.

@dphiffer
Last active February 9, 2022 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dphiffer/25c34909b72d9e0c988c297381079604 to your computer and use it in GitHub Desktop.
Save dphiffer/25c34909b72d9e0c988c297381079604 to your computer and use it in GitHub Desktop.
Revue export script
api_keys:
your_list: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#!/usr/bin/env python
import requests
import yaml
def export_issues(name, api_key):
with open(f"{name}_issues.json", "w") as file:
file.write(load_from_revue('issues', api_key))
print(f" saved {name}_issues.json")
def export_subscribers(name, api_key):
with open(f"{name}_subscribers.json", "w") as file:
file.write(load_from_revue('subscribers', api_key))
print(f" saved {name}_subscribers.json")
def load_from_revue(list, api_key):
base_url = "https://www.getrevue.co/api"
rsp = requests.get(f"{base_url}/v2/{list}", headers={
"Authorization": f"Token {api_key}"
})
rsp.raise_for_status()
return rsp.text
if __name__ == '__main__':
api_keys = {}
with open("config.yml", "r") as file:
config = yaml.safe_load(file)
for name, api_key in config['api_keys'].items():
print(f"exporting {name}")
export_issues(name, api_key)
export_subscribers(name, api_key)
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment