Skip to content

Instantly share code, notes, and snippets.

@lordjabez
Created September 5, 2022 22:09
Show Gist options
  • Save lordjabez/43c632c7bb9ca92c9d83d8368f9fb0ec to your computer and use it in GitHub Desktop.
Save lordjabez/43c632c7bb9ca92c9d83d8368f9fb0ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# pip3 install bitlyshortener pypng pyqrcode
import os
import sys
import bitlyshortener
import pyqrcode
long_urls = sys.argv[1:]
access_token = os.environ['BITLY_ACCESS_TOKEN']
shortener = bitlyshortener.Shortener(tokens=[access_token])
short_urls = shortener.shorten_urls(long_urls)
print(short_urls)
for short_url in short_urls:
name = short_url.split('/')[-1]
qr_code = pyqrcode.create(short_url)
qr_code.png(f'{name}.png', scale=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment