Add Windows startup config and Jellyfin API test script
Added startup.json with Windows-specific default paths and documentation for Jellyfin configuration. Introduced test_api.py, a Python script to authenticate with Jellyfin, create a backup, and list backups using the REST API.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"_comment": "Jellyfin Startup Configuration - Windows defaults - using C:/ProgramData/jellyfin",
|
||||
"_note": "These paths will be used unless overridden by environment variables or command-line arguments",
|
||||
"_priority": "Command-line args \u003E Environment variables \u003E This file \u003E Built-in defaults",
|
||||
"_examples": "See startup.linux.json or startup.windows.json in Resources/Configuration for other OS examples",
|
||||
"Paths": {
|
||||
"DataDir": "C:/ProgramData/jellyfin",
|
||||
"ConfigDir": "C:/ProgramData/jellyfin",
|
||||
"CacheDir": "C:/ProgramData/jellyfin/cache",
|
||||
"LogDir": "C:/ProgramData/jellyfin/log",
|
||||
"TempDir": "C:\\Users\\wjones\\AppData\\Local\\Temp\\jellyfin",
|
||||
"WebDir": "C:/ProgramData/jellyfin/wwwroot"
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import requests
|
||||
|
||||
# Define connection details
|
||||
server_url = 'http://localhost:8096'
|
||||
username = 'admin'
|
||||
password = 'Optimus0329'
|
||||
|
||||
backup_options = {
|
||||
"Database": True, # Include database
|
||||
"Config": True, # Include config files
|
||||
"Data": True, # Include data files
|
||||
"Root": True, # Include root folder
|
||||
"MediaFiles": False # Exclude media files
|
||||
}
|
||||
|
||||
# Build json payload with auth data
|
||||
auth_data = {
|
||||
'username': username,
|
||||
'Pw': password
|
||||
}
|
||||
|
||||
headers = {}
|
||||
|
||||
# Build required connection headers
|
||||
authorization = 'MediaBrowser Client="other", Device="my-script", DeviceId="some-unique-id", Version="0.0.0"'
|
||||
|
||||
headers['Authorization'] = authorization
|
||||
|
||||
# Authenticate to server
|
||||
r = requests.post(server_url + '/Users/AuthenticateByName', headers=headers, json=auth_data)
|
||||
|
||||
# Retrieve auth token and user id from returned data
|
||||
token = r.json().get('AccessToken')
|
||||
user_id = r.json().get('User').get('Id')
|
||||
|
||||
# Update the headers to include the auth token
|
||||
headers['Authorization'] = f'{authorization}, Token="{token}"'
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
# Requests can be made with
|
||||
#requests.get(f'{server_url}/api/endpoint', headers=headers)
|
||||
|
||||
# Create a backup (empty body is OK, will use default options)
|
||||
print("Creating backup...")
|
||||
response = requests.post(f'{server_url}/Backup/Create', headers=headers, json={})
|
||||
print(f"Status: {response.status_code}")
|
||||
print(response.text)
|
||||
|
||||
# List all backups
|
||||
print("\nListing backups...")
|
||||
response = requests.get(f'{server_url}/Backup', headers=headers)
|
||||
print(f"Status: {response.status_code}")
|
||||
print(response.text)
|
||||
Reference in New Issue
Block a user