9bcb8501ab
- Introduced `publish-with-sql.ps1` to publish Jellyfin with SQL files. - Added `remove-sqlite.ps1` to facilitate the removal of SQLite dependencies for PostgreSQL-only deployment. - Created `rollback-to-net10.ps1` to revert .NET 11 changes back to .NET 10. - Implemented `test_api.py` for testing API interactions. - Added `verify-migration.ps1` to verify PostgreSQL migration steps. - Updated various `.csproj` files to include `Microsoft.Kiota.Abstractions` package. - Enhanced `JellyfinDbContext` to handle concurrency exceptions during save operations. - Updated tests to include new package references and ensure compatibility with changes.
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
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)
|