Jump to content

Created 60274 Libraries (need to bulk delete)


troy_
Go to solution Solved by troy_,

Recommended Posts

I tried to add a photo's library.

When I clicked `Okay` - it just sat there... greyed out.

After an hour or so of waiting - I refreshed.

To find out that I have over sixty-thousand of the same library created.

Please... there must be a way to bulk delete libraries. Deleing them one at a time is _not_ an option.

Screenshot 2023-01-09 at 7.41.50 pm.png

Link to comment
Share on other sites

Happy2Play

Technically it can be turned on in the js file for the web client.  

But this issue really needs to be found as there are several topics on this and looks to be worse on Linux with a somewhat endless loop creating libraries.

 

Edited by Happy2Play
Link to comment
Share on other sites

  • Solution

I wrote a nasty little script in python to delete them - but it was going to take several weeks, so I had to dump everything and start again.

(token and device id are examples)

import requests
import json
import logging
import sys
import urllib

# Emby setup
emby_client = urllib.parse.quote("Emby Web")
emby_device_name = urllib.parse.quote("Google Chrome macOS")
emby_device_id = urllib.parse.quote("81bd29e9-6fb9-4074-87ad-ea2185bea2de")
emby_token = urllib.parse.quote("f463fb8786fa15808220b6964d8c6368")
emby_host = "emby.example.com"

# Logging setup
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

# Load JSON data
with open('response.json') as json_data:
    data = json.load(json_data)
    logger.info("JSON Loaded")

# Iterate over Items
for item in data["Items"]:
    # Check for locations that match
    for location in item["Locations"]:
        if location == "/data/photos":
            item_id = item["ItemId"]
            item_name = urllib.parse.quote(item["Name"])
            logger.info(f"Found Match: {item_name} ({item_id})")
            
            # Send HTTP POST
            url = f"https://{emby_host}}/emby/Library/VirtualFolders/Delete?refreshLibrary=false&id={item_id}&name={item_name}&X-Emby-Client={emby_client}&X-Emby-Device-Name={emby_device_name}&X-Emby-Device-Id={emby_device_id}&X-Emby-Client-Version=4.7.11.0&X-Emby-Token={emby_token}&X-Emby-Language=en-gb"
            try:
                response = requests.post(url, timeout=(3.05, 5))
            except requests.exceptions.Timeout:#any option that is similar?
                logger.info(f"Timed out: {item_name} ({item_id})")
                continue
            response.close()
            # Logging
            logger.info(response.url)
            logger.info(response.status_code)
            logger.info(response.text)
        else:
            logger.info("No Match: " + item["Name"])

 

Edited by troy_
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...