diff --git a/README.md b/README.md index 90d0736..b18abe1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # andotp2freeotp -Convert the JSON backup of unmaintained andOTP app to a format readable by FreeOTP. -Current conversion to JSON format doesn't work since I have an math issue converting the andOTP secrets to FreeOTP ones. +Convert the JSON backup from Gnome Authenticator or the unmaintained andOTP app to a format readable by FreeOTP. +Current conversion to JSON format doesn't work since I have an math issue converting the secrets to FreeOTP ones. See https://github.com/freeotp/freeotp-android/issues/368 and give me a hand with my math skills. But URI format works as a charm. @@ -29,7 +29,7 @@ sudo python3 setup.py install andotp2freeotp.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters -l, --log-file TEXT File to store all debug messages. - -i, --input TEXT JSON file from andOTP to convert [required] + -i, --input TEXT JSON file from andOTP or Gnome Authenticator to convert [required] -o, --output TEXT JSON/URI file to write for FreeOTP [required] -f, --format [uris|json] Format for the output. Either URIs or JSON. JSON doesn't work right now, pending on minor issue with conversion of secrets. See https://github.com/freeotp/freeotp-android/issues/368 and help me. --config FILE Read configuration from FILE. diff --git a/andotp2freeotp/andotp2freeotp.py b/andotp2freeotp/andotp2freeotp.py index a0b0d96..2da94cb 100644 --- a/andotp2freeotp/andotp2freeotp.py +++ b/andotp2freeotp/andotp2freeotp.py @@ -98,7 +98,10 @@ https://github.com/freeotp/freeotp-android/issues/368""" self.uris = [] for item in self.data: uri_type = item['type'].lower() - label = quote(f"{item['label']}@{item['issuer']}") + issuer = item.get('issuer', '') + if issuer == '' and 'tags' in item and len(item['tags']) > 0: + issuer = item['tags'][0] + label = quote(f"{item['label']}@{issuer}") uri = f"otpauth://{uri_type}/{label}?secret={item['secret']}" other_fields = [ 'algorithm', 'digits', 'period', 'issuer', 'counter' @@ -172,7 +175,8 @@ https://github.com/freeotp/freeotp-android/issues/368""" # @click.option("--dummy","-n", is_flag=True, # help="Don't do anything, just show what would be done.") @click.option( - '--input', '-i', required=True, help='JSON file from andOTP to convert' + '--input', '-i', required=True, + help='JSON file from andOTP or Gnome Authenticator to convert' ) @click.option( '--output', '-o', required=True, help='JSON/URI file to write for FreeOTP' diff --git a/pyproject.toml b/pyproject.toml index 23f5ef1..2d5288c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ Homepage = "" [project] name = "andotp2freeotp" -version = "0.0.1" +version = "0.0.2" description = "Convert andOTP json backups to FreeOTP format" readme = "README.md" authors = [{ name = "Antonio J. Delgado", email = "" }] @@ -22,4 +22,4 @@ dependencies = [ "click", "click_config_file", ] -requires-python = ">=3" \ No newline at end of file +requires-python = ">=3" diff --git a/setup.cfg b/setup.cfg index 630a215..d21f5a7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = andotp2freeotp -version = 0.0.1 +version = 0.0.2 [options] packages = andotp2freeotp