Gets the accounts from the cache. Args: provider (str): The provider to get the accounts for Returns: account (List[dict]): The accounts
(provider: str)
| 61 | raise ValueError(f"Unsupported provider '{provider}'. Expected 'twitter' or 'youtube'.") |
| 62 | |
| 63 | def get_accounts(provider: str) -> List[dict]: |
| 64 | """ |
| 65 | Gets the accounts from the cache. |
| 66 | |
| 67 | Args: |
| 68 | provider (str): The provider to get the accounts for |
| 69 | |
| 70 | Returns: |
| 71 | account (List[dict]): The accounts |
| 72 | """ |
| 73 | cache_path = get_provider_cache_path(provider) |
| 74 | |
| 75 | if not os.path.exists(cache_path): |
| 76 | # Create the cache file |
| 77 | with open(cache_path, 'w') as file: |
| 78 | json.dump({ |
| 79 | "accounts": [] |
| 80 | }, file, indent=4) |
| 81 | |
| 82 | with open(cache_path, 'r') as file: |
| 83 | parsed = json.load(file) |
| 84 | |
| 85 | if parsed is None: |
| 86 | return [] |
| 87 | |
| 88 | if 'accounts' not in parsed: |
| 89 | return [] |
| 90 | |
| 91 | # Get accounts dictionary |
| 92 | return parsed['accounts'] |
| 93 | |
| 94 | def add_account(provider: str, account: dict) -> None: |
| 95 | """ |
no test coverage detected