terrelsa13 / MUMC

Multi-User Media Cleaner aka MUMC (pronounced Mew-Mick) will go through movies, tv episodes, audio tracks, and audiobooks in your Emby/Jellyfin libraries deleting media items you no longer want.
GNU General Public License v3.0
92 stars 6 forks source link

KeyError: 'server_url' #99

Closed herrwusel closed 8 months ago

herrwusel commented 8 months ago

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 in var_dict and not the_dict. Happy new year!

$ python3 mumc.py 

----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Time Stamp Start: 20240101155815
MUMC Version: 5.3.12
MUMC Config Version: 5.3.12
Jellyfin Version: 10.8.13
Python Version: 3.9.2
OS Info: Linux-5.10.0-26-amd64-x86_64-with-glibc2.31
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Start...
[....]
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 11, in modify_lastPlayedDate
    serverURL=the_dict['server_url']
KeyError: 'server_url'
terrelsa13 commented 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.

herrwusel commented 8 months ago

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
terrelsa13 commented 8 months ago

Couple of things happening here:

  1. Update to the latest v5.3.14 to fix the string issue mentioned above.
  2. Re-run MUMC
  3. Post the error output here
    1. This time we are expecting the URL causing the issue to be printed out
    2. Copy that URL
  4. Open a web-browser
  5. Paste the URL into the web-browser
  6. Post what the browser is showing
herrwusel commented 8 months ago

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 :/

terrelsa13 commented 8 months ago

No problem.

  1. Open mumc_config.yaml in a text editor
  2. Change DEBUG: 0 to DEBUG: 2
  3. Run it again
  4. This time send the mumc_DEBUG.log file as an attachment
terrelsa13 commented 8 months ago

Correction - Run with DEBUG: 3

terrelsa13 commented 8 months ago

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.

terrelsa13 commented 8 months ago

Let's try this again:

  1. Update to the latest v5.3.15
  2. Open mumc_config.yaml in a text editor
  3. Change DEBUG: 0 to DEBUG: 3
  4. Run it again
  5. This time send the mumc_DEBUG.log file as an attachment
herrwusel commented 8 months ago

I still get a TypeError but see for yourself. Took some time to get redact the entire log file. mumc_DEBUG.log

terrelsa13 commented 8 months ago

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:

In the meantime, this is the only immediate work around I am aware of:

  1. Set DEBUG: 4
  2. Run MUMC again
  3. Search mumc_DEBUG.log for the itemId of the media_item causing the issue
    1. For this case it is 8e41cb350d15ba50890581804be40259
  4. Take note of the series, season, and episode name/number
    1. Or if it is a movie the movie name
    2. Or if it is an audio track the artist/album/track name/number
  5. Log into Jellyfin as the monitored_user the HTTPError is happening on
    1. In this case the user's name appears to be user
  6. Go to the media_item noted from step#4
  7. Mark the media_item as unplayed
  8. Then mark the media_item as played
    1. This should force Jellyfin to populate the LastPlayedDate: for this media_item
  9. Run MUMC again
  10. If there are multiple media_items showing as played but do not have a LastPlayedDate:, 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.

herrwusel commented 8 months ago

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
terrelsa13 commented 8 months ago

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?

herrwusel commented 8 months ago

Thanks for your effort!

I started from scratch and a minimal filter with the same result.

terrelsa13 commented 8 months ago

Update: I have learned Jellyfin has moved/removed the POST /Users/{UserId}/Items/{ItemId}/UserData endpoint from the API.

terrelsa13 commented 8 months ago

@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.

  1. Either download 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
  2. Run MUMC v5.3.16-beta
  3. Create a new mumc_config.yaml
  4. Modify mumc_config.yaml as desired
  5. Run MUMC again
  6. Let me know how it works
herrwusel commented 8 months ago

I 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.

terrelsa13 commented 8 months ago

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.

terrelsa13 commented 8 months ago

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.

terrelsa13 commented 8 months ago

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.

herrwusel commented 8 months ago

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.

terrelsa13 commented 8 months ago

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.

terrelsa13 commented 8 months ago

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

herrwusel commented 8 months ago

I don't see the v5.3.22 tag, only v5.3.20 which I checked out.

herrwusel commented 8 months ago

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!

terrelsa13 commented 8 months ago

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.

terrelsa13 commented 8 months ago

FYI - The official v5.4.0 release is available on the latest branch.