2023-11-18, 02:37 AM
PHP Code:
import requests
ADMIN_API_KEY = 'myadminapikey'
JELLYFIN_SERVER_URL = 'http://127.0.0.1:8096'
JELLYFIN_USER_ID = 'a2b6823293f24f0d9620cc7336971e96'
data = {
'EnableAllChannels': False,
'EnableAllFolders': False,
'EnableContentDownloading': False,
'EnableLiveTvAccess': False,
'EnableLiveTvManagement': False,
'EnableSharedDeviceControl': False,
'SyncPlayAccess': 'None',
}
response = requests.get(f'{JELLYFIN_SERVER_URL}/Users/{JELLYFIN_USER_ID}', headers={
'Authorization': f'MediaBrowser Token="{ADMIN_API_KEY}"',
'Accept': 'application/json',
})
response.raise_for_status()
data = {**response.json()['Policy'], **data}
if 'AuthenticationProviderId' not in data:
data['AuthenticationProviderId'] = 'Jellyfin.Server.Implementations.Users.DefaultAuthenticationProvider'
if 'PasswordResetProviderId' not in data:
data['PasswordResetProviderId'] = 'Jellyfin.Server.Implementations.Users.DefaultPasswordResetProvider'
response = requests.post(f'{JELLYFIN_SERVER_URL}/Users/{JELLYFIN_USER_ID}/Policy', headers={
'Authorization': f'MediaBrowser Token="{ADMIN_API_KEY}"'
}, json=data)
response.raise_for_status()
P.S. If the automation is what I suspect it's for, then https://github.com/jellyfin/jellyfin/issues/5415 is a worthwhile read.