diff --git a/opi/github.py b/opi/github.py index 65817b4..b406bff 100644 --- a/opi/github.py +++ b/opi/github.py @@ -27,14 +27,14 @@ def get_release_asset(release, filters=[]): assets = [r for r in assets if f(r)] return assets[0] if assets else None -def install_rpm_release(org, repo, allow_unsigned=False): +def install_rpm_release(org, repo, filters=[lambda a: a['name'].endswith('.rpm')], allow_unsigned=False): latest_release = get_latest_release(org, repo) if not latest_release: print(f'No release found for {org}/{repo}') return if not opi.ask_yes_or_no(f"Do you want to install {repo} release {latest_release['tag_name']} RPM from {org} github repo?"): return - asset = get_release_asset(latest_release, filters=[lambda a: a['name'].endswith('.rpm')]) + asset = get_release_asset(latest_release, filters=filters) if not asset: print(f"No RPM asset found for {org}/{repo} release {latest_release['tag_name']}") return diff --git a/opi/plugins/libation.py b/opi/plugins/libation.py new file mode 100644 index 0000000..af646e8 --- /dev/null +++ b/opi/plugins/libation.py @@ -0,0 +1,16 @@ +import opi +from opi.plugins import BasePlugin +from opi import github + +class Libation(BasePlugin): + main_query = 'libation' + description = 'Tool for managing audible audiobooks' + queries = [main_query, 'Libation'] + + @classmethod + def run(cls, query): + arch = opi.get_cpu_arch().replace('aarch64', 'amd64').replace('x86_64', 'amd64') + github.install_rpm_release('rmcrackan', 'Libation', + filters=[lambda a: a['name'].endswith(f'{arch}.rpm')], + allow_unsigned=True # no key available + )