-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support custom tags provided by plugin (scripts).
Settings dialog has new tab to define custom tags. These tags can be then be consumed by other scripts (library/playlist) or read directly. The values are persisted to the database so can be searched etc like normal meta data.
- Loading branch information
pudding
committed
Jan 28, 2024
1 parent
7d460da
commit 7bd0218
Showing
50 changed files
with
1,561 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
FoxTunes.Core/Interfaces/Factories/IMetaDataDecoratorFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes.Interfaces | ||
{ | ||
public interface IMetaDataDecoratorFactory : IStandardFactory | ||
{ | ||
IEnumerable<KeyValuePair<string, MetaDataItemType>> Supported { get; } | ||
|
||
bool CanCreate { get; } | ||
|
||
IMetaDataDecorator Create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
FoxTunes.Core/Interfaces/Managers/IMetaDataProviderManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace FoxTunes.Interfaces | ||
{ | ||
public interface IMetaDataProviderManager : IStandardManager, IDatabaseInitializer | ||
{ | ||
IMetaDataProvider GetProvider(MetaDataProvider metaDataProvider); | ||
|
||
MetaDataProvider[] GetProviders(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes.Interfaces | ||
{ | ||
public interface IMetaDataDecorator : IBaseComponent | ||
{ | ||
IEnumerable<string> GetWarnings(string fileName); | ||
|
||
void Decorate(string fileName, IList<MetaDataItem> metaDataItems, ISet<string> names = null); | ||
|
||
void Decorate(IFileAbstraction fileAbstraction, IList<MetaDataItem> metaDataItems, ISet<string> names = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes.Interfaces | ||
{ | ||
public interface IMetaDataProvider : IBaseComponent | ||
{ | ||
MetaDataProviderType Type { get; } | ||
|
||
bool AddOrUpdate(string fileName, IList<MetaDataItem> metaDataItems, MetaDataProvider provider); | ||
|
||
bool AddOrUpdate(IFileAbstraction fileAbstraction, IList<MetaDataItem> metaDataItems, MetaDataProvider provider); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
FoxTunes.Core/Interfaces/MetaData/IMetaDataProviderCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes.Interfaces | ||
{ | ||
public interface IMetaDataProviderCache : IStandardComponent | ||
{ | ||
MetaDataProvider[] GetProviders(Func<IEnumerable<MetaDataProvider>> factory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using FoxDb; | ||
using FoxTunes.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace FoxTunes | ||
{ | ||
[ComponentDependency(Slot = ComponentSlots.Database)] | ||
public class MetaDataProviderManager : StandardManager, IMetaDataProviderManager | ||
{ | ||
public MetaDataProviderManager() | ||
{ | ||
this._Providers = new Lazy<IDictionary<MetaDataProviderType, IMetaDataProvider>>( | ||
() => ComponentRegistry.Instance.GetComponents<IMetaDataProvider>().ToDictionary( | ||
component => component.Type | ||
) | ||
); | ||
} | ||
|
||
public Lazy<IDictionary<MetaDataProviderType, IMetaDataProvider>> _Providers { get; private set; } | ||
|
||
public IMetaDataProviderCache MetaDataProviderCache { get; private set; } | ||
|
||
public IDatabaseFactory DatabaseFactory { get; private set; } | ||
|
||
public override void InitializeComponent(ICore core) | ||
{ | ||
this.MetaDataProviderCache = core.Components.MetaDataProviderCache; | ||
this.DatabaseFactory = core.Factories.Database; | ||
base.InitializeComponent(core); | ||
} | ||
|
||
public IMetaDataProvider GetProvider(MetaDataProvider metaDataProvider) | ||
{ | ||
var provider = default(IMetaDataProvider); | ||
if (!this._Providers.Value.TryGetValue(metaDataProvider.Type, out provider)) | ||
{ | ||
return null; | ||
} | ||
return provider; | ||
} | ||
|
||
public MetaDataProvider[] GetProviders() | ||
{ | ||
return this.MetaDataProviderCache.GetProviders(this.GetProvidersCore); | ||
} | ||
|
||
public IEnumerable<MetaDataProvider> GetProvidersCore() | ||
{ | ||
using (var database = this.DatabaseFactory.Create()) | ||
{ | ||
using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel)) | ||
{ | ||
var set = database.Set<MetaDataProvider>(transaction); | ||
//It's easier to just filter enabled/disabled in memory, there isn't much data. | ||
//set.Fetch.Filter.AddColumn( | ||
// set.Table.GetColumn(ColumnConfig.By("Enabled", ColumnFlags.None)) | ||
//).With(filter => filter.Right = filter.CreateConstant(1)); | ||
foreach (var element in set) | ||
{ | ||
yield return element; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public string Checksum | ||
{ | ||
get | ||
{ | ||
return "6E3C885D-65D6-4A69-9991-CEC5156121A5"; | ||
} | ||
} | ||
|
||
public void InitializeDatabase(IDatabaseComponent database, DatabaseInitializeType type) | ||
{ | ||
//IMPORTANT: When editing this function remember to change the checksum. | ||
if (!type.HasFlag(DatabaseInitializeType.MetaData)) | ||
{ | ||
return; | ||
} | ||
using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel)) | ||
{ | ||
var set = database.Set<LibraryHierarchy>(transaction); | ||
set.Clear(); | ||
//No default data, yet. | ||
if (transaction.HasTransaction) | ||
{ | ||
transaction.Commit(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using System; | ||
|
||
namespace FoxTunes | ||
{ | ||
public class MetaDataProvider : PersistableComponent | ||
{ | ||
public MetaDataProvider() | ||
{ | ||
|
||
} | ||
|
||
private string _Name { get; set; } | ||
|
||
public string Name | ||
{ | ||
get | ||
{ | ||
return this._Name; | ||
} | ||
set | ||
{ | ||
this._Name = value; | ||
this.OnNameChanged(); | ||
} | ||
} | ||
|
||
protected virtual void OnNameChanged() | ||
{ | ||
if (this.NameChanged != null) | ||
{ | ||
this.NameChanged(this, EventArgs.Empty); | ||
} | ||
this.OnPropertyChanged("Name"); | ||
} | ||
|
||
public event EventHandler NameChanged; | ||
|
||
private MetaDataProviderType _Type { get; set; } | ||
|
||
public MetaDataProviderType Type | ||
{ | ||
get | ||
{ | ||
return this._Type; | ||
} | ||
set | ||
{ | ||
this._Type = value; | ||
this.OnTypeChanged(); | ||
} | ||
} | ||
|
||
protected virtual void OnTypeChanged() | ||
{ | ||
if (this.TypeChanged != null) | ||
{ | ||
this.TypeChanged(this, EventArgs.Empty); | ||
} | ||
this.OnPropertyChanged("Type"); | ||
} | ||
|
||
public event EventHandler TypeChanged; | ||
|
||
private string _Script { get; set; } | ||
|
||
public string Script | ||
{ | ||
get | ||
{ | ||
return this._Script; | ||
} | ||
set | ||
{ | ||
this._Script = value; | ||
this.OnScriptChanged(); | ||
} | ||
} | ||
|
||
protected virtual void OnScriptChanged() | ||
{ | ||
if (this.ScriptChanged != null) | ||
{ | ||
this.ScriptChanged(this, EventArgs.Empty); | ||
} | ||
this.OnPropertyChanged("Script"); | ||
} | ||
|
||
public event EventHandler ScriptChanged; | ||
|
||
private bool _Enabled { get; set; } | ||
|
||
public bool Enabled | ||
{ | ||
get | ||
{ | ||
return this._Enabled; | ||
} | ||
set | ||
{ | ||
this._Enabled = value; | ||
this.OnEnabledChanged(); | ||
} | ||
} | ||
|
||
protected virtual void OnEnabledChanged() | ||
{ | ||
if (this.EnabledChanged != null) | ||
{ | ||
this.EnabledChanged(this, EventArgs.Empty); | ||
} | ||
this.OnPropertyChanged("Enabled"); | ||
} | ||
|
||
public event EventHandler EnabledChanged; | ||
} | ||
|
||
public enum MetaDataProviderType : byte | ||
{ | ||
None = 0, | ||
Script = 1 | ||
} | ||
} |
Oops, something went wrong.