2023-11-18, 07:14 AM
Thank you very much for your answer ! But it does not work.
Here new code including your solution :
import requests
API_KEY = ''
JELLYFIN_SERVER_URL = ''
JELLYFIN_USER_ID = ""
JELLYFIN_ADMIN_ID = ""
ADMIN_USERNAME = ""
ADMIN_PW = ""
def qwerty12_fix() :
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="{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="{API_KEY}"'
}, json=data)
response.raise_for_status()
headers = {
"Authorization": f'MediaBrowser Token="{API_KEY}"',
"Content-Type": "application/json"
}
def my_fix() :
headers = {
"Authorization": f'MediaBrowser Token="{API_KEY}"',
"Content-Type": "application/json"
}
data = {
"Username" : ADMIN_USERNAME,
"Pw" : ADMIN_PW
}
response = requests.post(f'{JELLYFIN_SERVER_URL}/Users/AuthenticateByName', headers=headers, json=data)
TOKEN = response.json().get("AccessToken")
headers = {
"Authorization": f'MediaBrowser Token="{TOKEN}"',
"Content-Type": "application/json"
}
data = {
"Policy" :
{
'EnableAllChannels': False,
'EnableAllFolders': False,
'EnableContentDownloading': False,
'EnableLiveTvAccess': False,
'EnableLiveTvManagement': False,
'EnableSharedDeviceControl': False,
'SyncPlayAccess': None
}
}
response = requests.post(f'{JELLYFIN_SERVER_URL}/Users/{JELLYFIN_USER_ID}', headers=headers, json=data)
print(response.status_code)
print(response.text)
print(response.reason)
so qwerty_12() raises 400 error
and my_fix() raises also 400 error
Still lost !
Here new code including your solution :
import requests
API_KEY = ''
JELLYFIN_SERVER_URL = ''
JELLYFIN_USER_ID = ""
JELLYFIN_ADMIN_ID = ""
ADMIN_USERNAME = ""
ADMIN_PW = ""
def qwerty12_fix() :
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="{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="{API_KEY}"'
}, json=data)
response.raise_for_status()
headers = {
"Authorization": f'MediaBrowser Token="{API_KEY}"',
"Content-Type": "application/json"
}
def my_fix() :
headers = {
"Authorization": f'MediaBrowser Token="{API_KEY}"',
"Content-Type": "application/json"
}
data = {
"Username" : ADMIN_USERNAME,
"Pw" : ADMIN_PW
}
response = requests.post(f'{JELLYFIN_SERVER_URL}/Users/AuthenticateByName', headers=headers, json=data)
TOKEN = response.json().get("AccessToken")
headers = {
"Authorization": f'MediaBrowser Token="{TOKEN}"',
"Content-Type": "application/json"
}
data = {
"Policy" :
{
'EnableAllChannels': False,
'EnableAllFolders': False,
'EnableContentDownloading': False,
'EnableLiveTvAccess': False,
'EnableLiveTvManagement': False,
'EnableSharedDeviceControl': False,
'SyncPlayAccess': None
}
}
response = requests.post(f'{JELLYFIN_SERVER_URL}/Users/{JELLYFIN_USER_ID}', headers=headers, json=data)
print(response.status_code)
print(response.text)
print(response.reason)
so qwerty_12() raises 400 error
and my_fix() raises also 400 error
Still lost !