Jump to content

Best path for cleaning up duplicate People profiles / folders?


Go to solution Solved by Smitty018210,

Recommended Posts

ginjaninja
Posted (edited)

good find..

could be this then

https://dev.emby.media/reference/pluginapi/MediaBrowser.Controller.Entities.BaseItem.html#MediaBrowser_Controller_Entities_BaseItem_GetInternalMetadataPath
and this GetImagePath(BaseItem, ImageType)

https://dev.emby.media/reference/pluginapi/MediaBrowser.Controller.Entities.BaseItemExtensions.html

edit seems the ai gods agree
 

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;

namespace Emby.PersonPathExporter
{
    public class ExportPersonPathsTask : IScheduledTask
    {
        private readonly ILibraryManager _libraryManager;
        private readonly ILogger _logger;

        // Emby automatically injects dependencies via the constructor
        public ExportPersonPathsTask(ILibraryManager libraryManager, ILogManager logManager)
        {
            _libraryManager = libraryManager;
            _logger = logManager.GetLogger(Name);
        }

        public string Name => "Export Person Paths and Metadata";
        public string Key => "ExportPersonPathsAndMetadataTask";
        public string Description => "Logs the InternalMetadataPath and ImagePath for every person in the Emby library.";
        public string Category => "Maintenance";

        public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
        {
            _logger.Info("Starting Person Path Export task...");

            // Query items of type 'Person' recursively across the entire database
            var query = new InternalItemsQuery
            {
                IncludeItemTypes = new[] { Tuple.Create(typeof(Person).Name, false) },
                Recursive = true
            };

            var people = _libraryManager.GetItemList(query);

            if (people == null || people.Length == 0)
            {
                _logger.Info("No people found in the library database.");
                progress.Report(100);
                return;
            }

            int totalCount = people.Length;
            int currentCount = 0;

            _logger.Info($"Found {totalCount} people. Iterating and logging paths...");

            foreach (var item in people)
            {
                cancellationToken.ThrowIfCancellationRequested();

                if (item is Person person)
                {
                    // Extract paths
                    string name = person.Name ?? "Unknown";
                    string internalMetadataPath = person.InternalMetadataPath ?? "No internal metadata path available";
                    
                    // Retrieve the primary image path if it exists
                    string imagePath = person.GetImagePath(ImageType.Primary) ?? "No primary image path found";

                    // Output directly to Emby server's primary logs
                    _logger.Info($"Person: {name} | MetadataPath: {internalMetadataPath} | ImagePath: {imagePath}");
                }

                currentCount++;
                progress.Report((double)currentCount / totalCount * 100);
            }

            _logger.Info("Finished exporting person paths.");
            await Task.CompletedTask;
        }

        public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
        {
            // Provides a template for manual execution, but can be scheduled to run weekly if needed
            return new[]
            {
                new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerManual }
            };
        }
    }
}

 

Edited by ginjaninja
Smitty018210
Posted (edited)
3 hours ago, Lessaj said:

Do you have Emby Data Explorer plugin installed? You can view the people data that way and it might point you in the right direction.

image.png.153e8576c51a739d11c2b72c92661356.png

image.png.99746031a959172d08cb4c13054cc528.png

EDIT: I noticed some newer people in my server don't have a path mentioned, in the data below there is still mention of where their primary image is stored, so that could still be a data point.

image.png.6ce55a2f09d8aa08c8c28001a7fc4def.png

image.thumb.png.362c7429ce9e538c1d0af8ed0bebcf7d.png

 


 

I installed this plugin, but I do not see explore item detail option. 

image.thumb.png.13e11b932de83b59450c8a151b8ff781.png

Edited by Smitty018210
Lessaj
Posted

Try hard refreshing the web UI, disabling cache with Dev tools, use incognito or another browser. I remember it didn't appear right away, something with cache.

Smitty018210
Posted (edited)
10 minutes ago, Lessaj said:

Try hard refreshing the web UI, disabling cache with Dev tools, use incognito or another browser. I remember it didn't appear right away, something with cache.

Yeah, work on different browser and in incognito. Thanks for the heads up!

Edited by Smitty018210
  • Like 1

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