Skip to content

Export the list of Artist / Album in the clipboard to be pasted anywhere #3

@CyberSinh

Description

@CyberSinh
// Export the list of Artist / Album in the clipboard to be pasted anywhere

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using Metatogger.Data;

var data = new Dictionary<string, HashSet<string>>(StringComparer.InvariantCultureIgnoreCase);

void ProcessAudioFiles(string artist, string album)
{
   if (artist == null || album == null) return;

   if (data.ContainsKey(artist))
      data[artist].Add(album);
   else
      data.Add(artist, new HashSet<string>(new[] { album }, StringComparer.InvariantCultureIgnoreCase));
}

foreach (var file in files)
   if (file.IsEnabled)
      ProcessAudioFiles(file.GetFirstValue(TagName.Artist), file.GetFirstValue(TagName.Album));

var sb = new StringBuilder();
foreach (var kvp in data)
{
   sb.AppendLine(kvp.Key);
   foreach (string album in kvp.Value)
      sb.AppendLine("\t" + album);
   sb.AppendLine();
}

Clipboard.SetText(sb.ToString(), TextDataFormat.UnicodeText);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions