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
98 stars 6 forks source link

ValueError: In user_wl_libs !!?? #42

Closed Noursanb closed 2 years ago

Noursanb commented 2 years ago

Hello, Thank you for your work, it's really great. The script is not working properly for me, I got this #error

ValueError: In user_wl_libs for user edad7076a00743d78ccca5c6a3e21e6e the libid for library with key0 is not a 32 character alphanumeric string ValueError: In user_wl_libs for user edad7076a00743d78ccca5c6a3e21e6e the libid for library with key1 is not a 32 character alphanumeric string ValueError: In user_wl_libs for user edad7076a00743d78ccca5c6a3e21e6e the libid for library with key2 is not a 32 character alphanumeric string

thank you for your help

mumc_DEBUG.log

terrelsa13 commented 2 years ago

Hey @Noursanb

The script is expecting the libraryIds to be 32 characters long. It appears you libraryIds are 1, 2, and 3 characters long.

Below you will see your libids are 33, 482, and 4.

user_wl_libs=[
    {
        "userid": "edad7076a00743d78ccca5c6a3e21e6e",
        "username": "emby",
        "0": {
            "libid": "33",
            "collectiontype": "tvshows",
            "path": "/home/Media/Datas/Anime",
            "networkpath": ""
        },
        "1": {
            "libid": "482",
            "collectiontype": "movies",
            "path": "/home/Media/Datas/Movies",
            "networkpath": ""
        },
        "2": {
            "libid": "4",
            "collectiontype": "tvshows",
            "path": "/home/Media/Datas/TvShows ",
            "networkpath": ""
        }
    }

We can verify these libIds are correct. Put the link below into the browser of your Emby server; then press ENTER.

http://localhost:8096/emby/Library/VirtualFolders/Query?api_key=5739d5bdc8ca41d8bbb4e67187ffab4c

If you are using Firefox

  1. Click the "save" button in the top left corner
  2. Name and save the file
  3. Reply back with the file you just saved

If you are using Chrome/Edge

  1. Click anywhere in the Chrome window
  2. Select Ctrl+a to highlight all text
  3. Select Ctrl+c to copy all text
  4. Open a text editor (notepad, notepad++, visual studio, ultraedit, etc...)
  5. Select Ctrl+v to paste what was copied into the text editor
  6. Name and save the file
  7. Reply back with the file you just saved
Noursanb commented 2 years ago

Hey @terrelsa13

libraryIds.txt

Thank you .

terrelsa13 commented 2 years ago

That is a first. Never seen libraries with Ids shorter than 32-characters. I will have to figure out a better way to verify the values in the config later. But for now...

Try the attached script. The check for 32-character libId length is change to check at least 1-character.

  1. Download this script: mumc.py.txt
  2. Copy/Paste mumc.py.txt into the same folder as mumc.py
  3. Rename the existing mumc.py to mumc.py.orig
  4. Rename mumc.py.txt to mumc.py
  5. Run the script
  6. Let me know if it works now?
Noursanb commented 2 years ago

👀 I have more errors but still not working .!!? mumc_DEBUG.log

terrelsa13 commented 2 years ago

The mumc_DEBUG.log shows the script finished without any errors.

Will you copy/paste or screenshot the error(s) you are seeing?

Noursanb commented 2 years ago

I don't have any error that is displayed it's just he doesn't see the tvshows seen to delete them

Screenshot_20221015-182227_Admin Hands !

terrelsa13 commented 2 years ago

That last mumc_debug.log shows the script is not configured to find media items to delete.


How To Setup The Config File

Please read Step#1 thru Step#6. This will explain how the values in the configuration file can be used to delete media.


Difference Between Blacklisting And Whitelisting Libraries During Setup

Also please read Blacklisting vs Whitelisting. As that last mumc_debug.log shows all of your libraries have been whitelisted.

Noursanb commented 2 years ago

In the config file and I changed only this setting and the rest is default still the same problem he does not see but media !!!!!

movie_played_days=0 movie_created_days=0

episode_played_days=0 episode_created_days=0

REMOVE_FILES=True

thank you for your help

terrelsa13 commented 2 years ago

If you have run the script like you are showing above, it is possible it has already deleted ALL of your movies and episodes.

Step#4 explains why setting *_created_days=0 or setting them to any low number is something you NEVER want to do.

  1. Please set REMOVE_FILES=False
  2. Set DEBUG=4
  3. Run the script again
  4. Attach the mumc_DEBUG.log to your reply.
Noursanb commented 2 years ago

no, the media have not been deleted!! mumc_DEBUG.log

terrelsa13 commented 2 years ago

Ok. I am looking at what the mumc_DEBUG.log file says and it does not match what you are telling me.

  1. Please make sure the mumc_config.py file you have changed is also in the same folder as the mumc.py script you are running.
  2. REMOVE_FILES is still set to True. Please change this to False.
  3. DEBUG is equal to 3. Please change this to 4.
  4. The mumc_config.py is not setup to delete anything. I can tell because of the values in the mumc_DEBUG.log sent in the last message. All of the *_played_days and *_created_days are equal to -1.
movie_played_days=-1
episode_played_days=-1
audio_played_days=-1
movie_created_days=-1
episode_created_days=-1
audio_created_days=-1
Noursanb commented 2 years ago

I also send you the configuration file... mumc_DEBUG.log mumc_config.py.txt

terrelsa13 commented 2 years ago

During setup you choose whitelisting and then selected all libraries. Please read the link I provided earlier about blacklisting vs whitelisting.


Difference Between Blacklisting And Whitelisting Libraries During Setup

Also please read Blacklisting vs Whitelisting. As that last mumc_debug.log shows all of your libraries have been whitelisted.

Noursanb commented 2 years ago

delete_media_item_request - url request: generic exception: Traceback (most recent call last): File "./mumc.py", line 6984, in delete_media_item requestURL(req, GLOBAL_DEBUG, 'delete_media_item_request', 3) File "./mumc.py", line 80, in requestURL appendTo_DEBUG_log("\n" + url,3) TypeError: can only concatenate str (not "Request") to str [DELETED] Episode - Grey's Anatomy - s19.e01 - Everything Has Changed - 255

mumc_DEBUG.log

terrelsa13 commented 2 years ago

I think I know what's wrong here. I will be able to take a closer look later.

terrelsa13 commented 2 years ago

Try this. It should fix the TypeError occurring when the script is writing to the debug file.

mumc.py.txt

Noursanb commented 2 years ago

thanks for your availability

terrelsa13 commented 2 years ago

Did we get you working correctly?

I see in email you were getting this error:

RuntimeError: 
AUTH_ERROR: User Not Authorized To Access Library

Likely means the user chosen as the admin user (emby) does not have permission to delete from the libraries. You can fix this by either setting up the script again using the admin account for the server and then blacklist/whitelisting libraries for non-admin users. Or, if Emby is your admin user, by logging into Emby as the admin user and selecting:

The other issue could be the admin username emby does not have the necessary Linux permissions to delete files from the OS. This usually isn't the case as emby:emby should be the default username:groupname and should have permissions. But take a look at Setting Proper Linux Permissions For Emby/Jellyfin it might help.

Noursanb commented 2 years ago

it works thank you very much for the work and that you do it is availability and the patience that you show thank you and I wish you a great day

terrelsa13 commented 2 years ago

Awesome! Glad it works.

Thank you very much. You have a great day too!