clara-j / media_cleaner

Python script to delete watched content on Emby
31 stars 17 forks source link

Error #1

Closed henrik9999 closed 4 years ago

henrik9999 commented 4 years ago

Traceback (most recent call last):
  File "media_cleaner.py", line 155, in <module>
    deleteItems=get_items(cfg.server_url, cfg.user_key, auth_key)
  File "media_cleaner.py", line 124, in get_items
    item_details=item['Type'] +' - '+ item['Name'] +' - ' + item['UserData']['LastPlayedDate'] + ' - ' + item['UserData']['Key'] + ' - ' + item['Id']
KeyError: 'Key'
clara-j commented 4 years ago

I have a new version coming maybe later today that adds support to ignore items marked as favorite. I will try to get this fixed with that too.

henrik9999 commented 4 years ago

Any updates?

clara-j commented 4 years ago

I have pushed a version that should fix the issue. Sorry for the delay, been busy with family and work so I just did a bug fix and will work on new version with more features later.

terrelsa13 commented 4 years ago

@henrik9999 Were you able to get this resolved? I am seeing the same error on a fresh install, as of 2 hours ago.

Items to be deleted
Traceback (most recent call last):
  File "./media_cleaner.py", line 159, in <module>
    list_items(deleteItems)
  File "./media_cleaner.py", line 145, in list_items
    item_details=item['Name'] + ' - ' + item['UserData']['LastPlayedDate'] + ' - ' + item['UserData']['Key'] + ' - ' + item['Id']
KeyError: 'Key'
terrelsa13 commented 4 years ago

After some playing around with this script I was able to determine item['UserData']['Key'] either never was, or is no longer available thru the API. Removing it resolved the error.


Option#1 Find this line:

item_details=item['Name'] + ' - ' + item['UserData']['LastPlayedDate'] + ' - ' + item['UserData']['Key'] + ' - ' + item['Id']

Make it look like this:

item_details=item['Name'] + ' - ' + item['UserData']['LastPlayedDate'] + ' - ' + item['Id']

Option#2 Comment out or delete a couple lines. If you chose option#2 your media will still be deleted as expected, but you will not get a summary of the deleted media at the end.

Comment out lines by adding # in front of them like this:

#item_details=item['Name'] + ' - ' + item['UserData']['LastPlayedDate'] + ' - ' + item['UserData']['Key'] + ' - ' + item['Id']
#print('----' + item_details)
clara-j commented 4 years ago

Let me look into this, I have re-opened the issue. I thought I had fixed it, but I guess I missed an instance of the Key value.

For some reason on my server I don't have this issue as all items have the Key value.

clara-j commented 4 years ago

I just pushed a new version that removed the other Key value.

I had thought the first fix had removed all references to it, but missed the one on that delete command.

Let me know if it is now working for you.

terrelsa13 commented 4 years ago

Thanks @clara-j that seems to have fixed it.

Now it seems like my emby server side does not like these requests. You ever get this from emby? https://pastebin.com/raw/X3jNKqCk

clara-j commented 4 years ago

Can you open another issue for this. I want to resolve this one and we can then discuss in the new ticket but looks like a permission issue.

Make sure the user emby is running under has delete permissions on the files/folders for your media. I originally had this when I had docker for emby configured as read only for the folder I was using for media.

terrelsa13 commented 4 years ago

Yep. I will open a new issue.

terrelsa13 commented 4 years ago

I would also say the original issue posted here is now closed. Unless your update did not solve it for @henrik9999