Api — Myrient

class MyrientAPI: """Simple text interface for Myrient API""" BASE_URL = "https://myrient.com/api/v1" def __init__(self): self.session = requests.Session() self.session.headers.update({ 'User-Agent': 'MyrientCLI/1.0' }) def search_files(self, query: str, system: Optional[str] = None) -> List[Dict]: """Search for files by name""" params = {'query': query} if system: params['system'] = system try: response = self.session.get(f"{self.BASE_URL}/search", params=params) response.raise_for_status() return response.json().get('results', []) except requests.RequestException as e: print(f"Error searching: {e}") return [] def list_systems(self) -> List[str]: """Get available systems""" try: response = self.session.get(f"{self.BASE_URL}/systems") response.raise_for_status() return response.json().get('systems', []) except requests.RequestException as e: print(f"Error listing systems: {e}") return [] def get_file_info(self, file_id: str) -> Optional[Dict]: """Get detailed file information""" try: response = self.session.get(f"{self.BASE_URL}/file/{file_id}") response.raise_for_status() return response.json() except requests.RequestException as e: print(f"Error getting file info: {e}") return None def download_link(self, file_id: str) -> Optional[str]: """Get download link for a file""" try: response = self.session.get(f"{self.BASE_URL}/download/{file_id}") response.raise_for_status() return response.json().get('url') except requests.RequestException as e: print(f"Error getting download link: {e}") return None

def print_menu(): """Display main menu""" print("\n" + "="*50) print("MYRIENT API TEXT INTERFACE") print("="*50) print("1. Search for files") print("2. List available systems") print("3. Get file information") print("4. Get download link") print("5. Exit") print("-"*50) myrient api

def get_file_info_interactive(api: MyrientAPI): """Get file information""" print("\n--- FILE INFORMATION ---") file_id = input("Enter file ID: ").strip() if not file_id: print("File ID cannot be empty") return info = api.get_file_info(file_id) if not info: print("File not found or error occurred") return print("\nFile Information:") print("-" * 40) for key, value in info.items(): print(f"{key}: {value}") Get file information") print("4