Last active
June 12, 2024 08:02
-
-
Save serinko/5beeaee5690288b7fdf9de9dca513d79 to your computer and use it in GitHub Desktop.
A python script simplifying multiple QR codes generation out of NymVPN redeem codes csv file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Dependencies: qrencode, python3, python3-pandas | |
# Save by running: wget <raw_url> | |
# Make executable: chmod u+x <file_name> | |
# Run: ./<file_name> | |
import pandas as pd | |
import sys | |
import os | |
csv = input("Insert csv filename (or path/file if the file is in another directory): ") | |
path = input("Insert path where the QR codes will be saved (without filename) - leave empty if you want to use current directory: ") | |
qr_size = input("Insert QR code size (reccomended is 2-6): ") | |
if path == "": | |
path = "./" | |
if path[-1] != "/": | |
path = path + "/" | |
try: | |
df = pd.read_csv(f"{csv}") | |
except FileNotFoundError as e: | |
print(e) | |
print(f"csv file '{csv}' does not exist! Make sure to insert a correct path and file name.") | |
sys.exit(-1) | |
for index, row in df.iterrows(): | |
redeem_code = row["redemptionCode"] | |
url = f"https://nymvpn.com/en/alpha?code={redeem_code}" | |
qren_cmd = f'qrencode -s {qr_size} -l H -o "{path}{redeem_code}.png" "{url}"' | |
if os.system(qren_cmd) == 0: | |
print(f"QR code saved as {path}{redeem_code}.png") | |
else: | |
print("Operation failed! Make sure that QR size is a number and that you insert an existing storage path.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment