import requests import sys def scan_library(): """ Scan library using Jellyfin API """ url = 'http://192.168.2.216:2283/api/libraries/8ea04568-fd60-4960-8b54-11e7508af1c4/scan' headers = { 'x-api-key': 'vIs1N0FLaPDCQz6CILc3fBzC7IcRgG5Tne4fyMrA' } try: response = requests.post(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print(f"Scan initiated successfully. Status code: {response.status_code}") if response.text: print("Response:", response.text) return True except requests.exceptions.RequestException as e: print(f"Error scanning library: {e}", file=sys.stderr) return False if __name__ == "__main__": success = scan_library() sys.exit(0 if success else 1)