Closed herrwusel closed 8 months ago
@herrwusel Ahh yes. Good find!
Both server_url
and auth_key
were being referenced incorrectly.
Old:
serverURL=the_dict['server_url']
authKey=the_dict['auth_key']
Updated:
serverURL=the_dict['admin_settings']['server']['url']
authKey=the_dict['admin_settings']['server']['auth_key']
Both are now fixed in the latest (i.e. v5.3.13).
Let me know how the update works out.
Thanks for the quick answer! Now I get:
HTTPError: Unable to get information from server during processing of: add_missing_LastPlayedDate
Traceback (most recent call last):
File "/home/user/MUMC/mumc_modules/mumc_url.py", line 75, in requestURL
with urlrequest.urlopen(url) as response:
File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/usr/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/MUMC/mumc.py", line 105, in <module>
MUMC()
File "/home/user/MUMC/mumc.py", line 76, in MUMC
cfg=init_getMedia(cfg)
File "/home/user/MUMC/mumc_modules/mumc_get_media.py", line 789, in init_getMedia
episode_returns=get_mediaItems(the_dict,the_dict['episode_dict']['media_type'],user_info,episode_returns)
File "/home/user/MUMC/mumc_modules/mumc_get_media.py", line 472, in get_mediaItems
item=prepare_EPISODEoutput(the_dict,item,user_info,var_dict)
File "/home/user/MUMC/mumc_modules/mumc_prepare_item.py", line 102, in prepare_EPISODEoutput
modify_lastPlayedDate(item,user_info['user_id'],the_dict)
File "/home/user/MUMC/mumc_modules/mumc_trakt_fix.py", line 32, in modify_lastPlayedDate
requestURL(req, the_dict['DEBUG'], 'add_missing_LastPlayedDate', 3, the_dict)
File "/home/user/MUMC/mumc_modules/mumc_url.py", line 136, in requestURL
print('\n URL: ' + url + '')
TypeError: can only concatenate str (not "Request") to str
Couple of things happening here:
TypeError: can only concatenate str (not "Request") to str
looks like a conversion to string was missed.urllib.error.HTTPError: HTTP Error 404: Not Found
the server does not like the request from MUMC to add the missing "last played date" to media item(s) that are showing as played but do not have a "last played date".
I updated to v5.3.14
and now I get this:
HTTPError: Unable to get information from server during processing of: add_missing_LastPlayedDate
URL: <urllib.request.Request object at 0x7f09cc3679d0>
404
Not Found
No URL shown :/
No problem.
mumc_config.yaml
in a text editorDEBUG: 0
to DEBUG: 2
mumc_DEBUG.log
file as an attachmentCorrection - Run with DEBUG: 3
And I am looking at the DEBUG code for the Trakt fix and see the debug level is missing from the v5 code refactor. Hold off until I get a chance to look over the Trakt code again. Apologies, I do not use Trakt so this part of the code does not get much attention.
Let's try this again:
mumc_config.yaml
in a text editorDEBUG: 0
to DEBUG: 3
mumc_DEBUG.log
file as an attachmentI still get a TypeError but see for yourself. Took some time to get redact the entire log file. mumc_DEBUG.log
still get a TypeError but see for yourself.
Did you mean, still getting theHTTPError
?
I can reproduce the HTTPError
on my Jellyfin test server. It appears Jellyfin has changed something with respect to POSTING updates. This means it is now different from the way Emby does it. I will look into what changed.
Debug log is showing the media item as Played: True
and PlayCount: 1
but LastPlayedDate:
is missing.
['UserData'] from server before requesting update:
{
"PlaybackPositionTicks": 0,
"PlayCount": 1,
"IsFavorite": false,
"Played": true,
"Key": "73244004015"
}
If you are using Trakt to import the watched state this is the reason why. Trakt should also populate LastPlayedDate:
along with Played:
and PlayCount:
DEBUG: 4
mumc_DEBUG.log
for the itemId
of the media_item causing the issue
8e41cb350d15ba50890581804be40259
HTTPError
is happening on
user
LastPlayedDate:
for this media_itemLastPlayedDate:
, this will need to be repeated for all of them.Like i mentioned, I will look into addressing this in MUMC. Maybe instead of inserting the current date as the last played date, MUMC will instead mark the media_item unplayed then palyed and let Emby/Jellyfin handle populating the date. I will have to see what I can do to keep this portion of the code common between Emby/Jellyfin if possible.
Thanks for the immediate work around - that worked.
This was the error I was getting:
HTTPError: Unable to get information from server during processing of: add_missing_LastPlayedDate
URL: <urllib.request.Request object at 0x7fdcd8bccdf0>
404
Not Found
Traceback (most recent call last):
File "/home/user/MUMC/mumc_modules/mumc_url.py", line 75, in requestURL
with urlrequest.urlopen(url) as response:
File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/usr/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/MUMC/mumc.py", line 105, in <module>
MUMC()
File "/home/user/MUMC/mumc.py", line 76, in MUMC
cfg=init_getMedia(cfg)
File "/home/user/MUMC/mumc_modules/mumc_get_media.py", line 789, in init_getMedia
episode_returns=get_mediaItems(the_dict,the_dict['episode_dict']['media_type'],user_info,episode_returns)
File "/home/user/MUMC/mumc_modules/mumc_get_media.py", line 472, in get_mediaItems
item=prepare_EPISODEoutput(the_dict,item,user_info,var_dict)
File "/home/user/MUMC/mumc_modules/mumc_prepare_item.py", line 102, in prepare_EPISODEoutput
modify_lastPlayedDate(item,user_info['user_id'],the_dict)
File "/home/user/MUMC/mumc_modules/mumc_trakt_fix.py", line 39, in modify_lastPlayedDate
requestURL(req, the_dict['DEBUG'], 'add_missing_LastPlayedDate', 3, the_dict)
File "/home/user/MUMC/mumc_modules/mumc_url.py", line 140, in requestURL
appendTo_DEBUG_log('\n URL: ' + url + '',2,the_dict)
TypeError: can only concatenate str (not "Request") to str
FYI - I have posted for help in the Jellyfin forums. Hopefully someone smarter than myself can help guide me to the right path.
Unable To POST an UserData Update
Question: If you rename your current config to something like mumc_config.yaml.orig
are you able to make a new mumc_config.yaml
from scratch?
Thanks for your effort!
I started from scratch and a minimal filter with the same result.
Update: I have learned Jellyfin has moved/removed the POST /Users/{UserId}/Items/{ItemId}/UserData
endpoint from the API.
UserData
?
POST /Users/{UserId}/Items/{ItemId}/UserData
API endpoint?UserData
?@herrwusel
I think we have a working solution. It can be found in the MUMC_dev branch or in the releases folder.
Look for v5.3.16-beta
.
v5.3.16-beta
to a different directory; or update the current MUMC directory and rename the existing mumc_config.yaml
to something like mumc_config.yaml.orig
v5.3.16-beta
mumc_config.yaml
mumc_config.yaml
as desiredI checked out the tag and I think an argument is missing here?
EDIT: 2nd run it doesn't complain about the missing argument any more. Now I get an internal server error:
HTTPError: Unable to get information from server during processing of: delete_media_item_request
Object: <bound method Request.header_items of <urllib.request.Request object at 0x7fd8bedecfd0>>
URL: https://tld.com/jellyfin/Items/018224f0e60bfda66635093c97782fab?api_key=xxx
Method: DELETE
Header: {}
Data: None
HTTPError: 500 - Internal Server Error
On jellyfin side:
[2024-01-08 09:52:53.437 +01:00] [ERR] Error processing request. URL "DELETE" "/Items/82ae806eae31e18eaaa03a84db8aa9c0".
System.NullReferenceException: Object reference not set to an instance of an object.
at MediaBrowser.Controller.Entities.BaseItem.IsAuthorizedToDelete(User user, List`1 allCollectionFolders)
at Jellyfin.Api.Controllers.LibraryController.DeleteItem(Guid itemId)
at lambda_method691(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Jellyfin.Server.Middleware.ServerStartupMessageMiddleware.Invoke(HttpContext httpContext, IServerApplicationHost serverApplicationHost, ILocalizationManager localizationManager)
at Jellyfin.Server.Middleware.WebSocketHandlerMiddleware.Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
at Jellyfin.Server.Middleware.IpBasedAccessValidationMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager)
at Jellyfin.Server.Middleware.LanFilteringMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Jellyfin.Server.Middleware.QueryStringDecodingMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.ReDoc.ReDocMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Jellyfin.Server.Middleware.RobotsRedirectionMiddleware.Invoke(HttpContext httpContext)
at Jellyfin.Server.Middleware.LegacyEmbyRouteRewriteMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
at Jellyfin.Server.Middleware.ResponseTimeMiddleware.Invoke(HttpContext context, IServerConfigurationManager serverConfigurationManager)
at Jellyfin.Server.Middleware.ExceptionMiddleware.Invoke(HttpContext context)
[2024-01-08 09:52:55.458 +01:00] [ERR] Error processing request. URL "DELETE" "/Items/82ae806eae31e18eaaa03a84db8aa9c0".
System.NullReferenceException: Object reference not set to an instance of an object.
at MediaBrowser.Controller.Entities.BaseItem.IsAuthorizedToDelete(User user, List`1 allCollectionFolders)
at Jellyfin.Api.Controllers.LibraryController.DeleteItem(Guid itemId)
at lambda_method691(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Jellyfin.Server.Middleware.ServerStartupMessageMiddleware.Invoke(HttpContext httpContext, IServerApplicationHost serverApplicationHost, ILocalizationManager localizationManager)
at Jellyfin.Server.Middleware.WebSocketHandlerMiddleware.Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
at Jellyfin.Server.Middleware.IpBasedAccessValidationMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager)
at Jellyfin.Server.Middleware.LanFilteringMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Jellyfin.Server.Middleware.QueryStringDecodingMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.ReDoc.ReDocMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Jellyfin.Server.Middleware.RobotsRedirectionMiddleware.Invoke(HttpContext httpContext)
at Jellyfin.Server.Middleware.LegacyEmbyRouteRewriteMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
at Jellyfin.Server.Middleware.ResponseTimeMiddleware.Invoke(HttpContext context, IServerConfigurationManager serverConfigurationManager)
at Jellyfin.Server.Middleware.ExceptionMiddleware.Invoke(HttpContext context)
Said item does exist and is marked as watched.
I checked out the tag and I think an argument is missing here?
You are correct. This has been fixed for v5.3.18-beta.
EDIT: 2nd run it doesn't complain about the missing argument any more. Now I get an internal server error:
I get the same error on my jellyfin test server. Looks like something else API related has changed. Found a similar issue here. Trying to understand if this is still an issue or if there is something that needs to be changed in MUMC to properly use the DELETE endpoint.
With v5.3.18-beta you should be able to do everything, except the most important part; delete media. Once I have a solution for this I will let you know.
Starting to worry there may be other API related things for jellyfin not working the same as emby now.
Got a reply on the thread with the similar issue I mentioned yesterday: Jellyfin API Authorization
A quick read through looks promising. Unfortunately, for me, it appears jellyfin has decided to make changes to the API authorization method that differ from emby. This means every API request for jellyfin will need to be updated to reflect those changes.
Try the latest v5.3.22-beta.
Also make sure jellyfin owns the media files and the admin user has Allow media deletion from:
enabled.
Dashboard > Users > "AdminUserName" > Profile > Allow media deletion from:
Select all libraries that apply.
Again, thank you for your efforts! With v5.30.20-beta
I get
HTTPError: Unable to get information from server during processing of: delete_media_item_request
Object: <bound method Request.header_items of <urllib.request.Request object at 0x7f1df7fabca0>>
URL: https://tld.com/jellyfin/Items/018224f0e60bfda66635093c97782fab?api_key=xxx
Method: DELETE
Header: {'Accept': 'application/json'}
Data: None
HTTPError: 500 - Internal Server Error
generic exception: Traceback (most recent call last):
File "/home/user/MUMC/mumc_modules/mumc_url.py", line 79, in requestURL
with urlrequest.urlopen(url) as response:
File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/usr/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/MUMC/mumc_modules/mumc_delete.py", line 26, in delete_media_item
requestURL(req, the_dict['DEBUG'], 'delete_media_item_request', 3, the_dict)
File "/home/user/MUMC/mumc_modules/mumc_url.py", line 184, in requestURL
exit(0)
File "/usr/lib/python3.9/_sitebuiltins.py", line 26, in __call__
raise SystemExit(code)
SystemExit: 0
[DELETED] Movie - High Life - 018224f0e60bfda66635093c97782fab
for every item that should be deleted.
Were you able to try the latest v5.3.22?
The API key is no longer at the end of the URL, the new scheme moves it to the header.
URL: https://tld.com/jellyfin/Items/018224f0e60bfda66635093c97782fab?api_key=xxx
Becomes
URL: https://tld.com/jellyfin/Items/018224f0e60bfda66635093c97782fab
Header: {authorization : 'MediaBrowser Client="' + client + '", Device="' + device + '", DeviceId="' + deviceId + '", Version="' + version + '", Token="'+ token + '"', 'Content-Type' : 'application/json'}
Where the API key is now the Token in the header.
I was not able to delete media until these two items were addressed.
Also make sure jellyfin owns the media files and the admin user has Allow media deletion from: enabled. Dashboard > Users > "AdminUserName" > Profile > Allow media deletion from: Select all libraries that apply.
This is a link to help with permission issues. https://github.com/terrelsa13/MUMC/wiki/OS-Permissions
I don't see the v5.3.22 tag, only v5.3.20 which I checked out.
Alright — it worked. Since I didn't find the latest tag, I used the beta branch. After recreating the config.yaml, deleting media items now works again — thank you a lot!
Ahh that's my mistake. I didn't make a tag for v5.3.22 I just checked it into the MUMC_dev branch. At some point in the near future I will get these updates pushed into the MUMC_v5 branch and make an official release tag.
Glad we were able to get you working!
Let me know if you run into any other issues.
FYI - The official v5.4.0 release is available on the latest branch.
I don't know if I messed something up, but from a brief look at the code, it seems that the key
server_url
is invar_dict
and notthe_dict
. Happy new year!