Whole album matching and fingerprinting (#592)

* Cache result of GetAllArtists

* Fixed: Manual import not respecting album import notifications

* Fixed: partial album imports stay in queue, prompting manual import

* Fixed: Allow release if tracks are missing

* Fixed: Be tolerant of missing/extra "The" at start of artist name

* Improve manual import UI

* Omit video tracks from DB entirely

* Revert "faster test packaging in build.sh"

This reverts commit 2723e2a7b8.

-u and -T are not supported on macOS

* Fix tests on linux and macOS

* Actually lint on linux

On linux yarn runs scripts with sh not bash so ** doesn't recursively glob

* Match whole albums

* Option to disable fingerprinting

* Rip out MediaInfo

* Don't split up things that have the same album selected in manual import

* Try to speed up IndentificationService

* More speedups

* Some fixes and increase power of recording id

* Fix NRE when no tags

* Fix NRE when some (but not all) files in a directory have missing tags

* Bump taglib, tidy up tag parsing

* Add a health check

* Remove media info setting

* Tags -> audioTags

* Add some tests where tags are null

* Rename history events

* Add missing method to interface

* Reinstate MediaInfo tags and update info with artist scan

Also adds migration to remove old format media info

* This file no longer exists

* Don't penalise year if missing from tags

* Formatting improvements

* Use correct system newline

* Switch to the netstandard2.0 library to support net 461

* TagLib.File is IDisposable so should be in a using

* Improve filename matching and add tests

* Neater logging of parsed tags

* Fix disk scan tests for new media info update

* Fix quality detection source

* Fix Inexact Artist/Album match

* Add button to clear track mapping

* Fix warning

* Pacify eslint

* Use \ not /

* Fix UI updates

* Fix media covers

Prevent localizing URL propaging back to the metadata object

* Reduce database overhead broadcasting UI updates

* Relax timings a bit to make test pass

* Remove irrelevant tests

* Test framework for identification service

* Fix PreferMissingToBadMatch test case

* Make fingerprinting more robust

* More logging

* Penalize unknown media format and country

* Prefer USA to UK

* Allow Data CD

* Fix exception if fingerprinting fails for all files

* Fix tests

* Fix NRE

* Allow apostrophes and remove accents in filename aggregation

* Address codacy issues

* Cope with old versions of fpcalc and suggest upgrade

* fpcalc health check passes if fingerprinting disabled

* Get the Artist meta with the artist

* Fix the mapper so that lazy loaded lists will be populated on Join

And therefore we can join TrackFiles on Tracks by default and avoid an
extra query

* Rename subtitle -> lyric

* Tidy up MediaInfoFormatter
This commit is contained in:
ta264
2019-02-16 14:49:24 +00:00
committed by Qstick
parent 8bf364945f
commit bb02d73c42
174 changed files with 11577 additions and 3490 deletions

View File

@@ -165,7 +165,7 @@ namespace Marr.Data
/// </summary>
public void AddLazyRelationship(Relationship childRelationship)
{
_children.Add(new EntityGraph(childRelationship.RelationshipInfo.EntityType.GetGenericArguments()[0], this, childRelationship));
_children.Add(new EntityGraph(childRelationship.RelationshipInfo.EntityType, this, childRelationship));
}
/// <summary>
@@ -297,16 +297,30 @@ namespace Marr.Data
private void InitOneToManyChildLists(EntityReference entityRef)
{
// Get a reference to the parent's the childrens' OwningLists to the parent entity
for (int i = 0; i < Relationships.Count; i++)
foreach (var child in _children)
{
Relationship relationship = Relationships[i];
Relationship relationship = child._relationship;
if (relationship.RelationshipInfo.RelationType == RelationshipTypes.Many)
{
try
{
IList list = (IList)_repos.ReflectionStrategy.CreateInstance(relationship.MemberType);
relationship.Setter(entityRef.Entity, list);
var memberType = relationship.MemberType;
object memberInstance;
object childList;
if (typeof(ILazyLoaded).IsAssignableFrom(memberType))
{
childList = _repos.ReflectionStrategy.CreateInstance(memberType.GetGenericArguments()[0]);
memberInstance = Activator.CreateInstance(relationship.MemberType, childList);
}
else
{
childList = _repos.ReflectionStrategy.CreateInstance(memberType);
memberInstance = childList;
}
IList list = (IList) childList;
relationship.Setter(entityRef.Entity, memberInstance);
// Save a reference to each 1-M list
entityRef.AddChildList(relationship.Member.Name, list);
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Linq;
using System.Linq.Expressions;
using Marr.Data.Mapping.Strategies;
@@ -65,8 +66,21 @@ namespace Marr.Data.Mapping
public RelationshipBuilder<TEntity> LazyLoad<TChild>(Func<IDataMapper, TEntity, TChild> query, Func<TEntity, bool> condition = null)
{
AssertCurrentPropertyIsSet();
var relationship = Relationships[_currentPropertyName];
Relationships[_currentPropertyName].LazyLoaded = new LazyLoaded<TEntity, TChild>(query, condition);
relationship.LazyLoaded = new LazyLoaded<TEntity, TChild>(query, condition);
// work out if it's one to many or not
if (typeof(ICollection).IsAssignableFrom(typeof(TChild)))
{
relationship.RelationshipInfo.RelationType = RelationshipTypes.Many;
relationship.RelationshipInfo.EntityType = typeof(TChild).GetGenericArguments()[0];
}
else
{
relationship.RelationshipInfo.EntityType = typeof(TChild);
}
return this;
}

View File

@@ -568,6 +568,23 @@ namespace Marr.Data.QGen
return Join(joinType, rightMember, filterExpression);
}
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, LazyLoaded<List<TRight>>>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression)
{
_isJoin = true;
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
foreach (var item in EntGraph)
{
if (item.EntityType == typeof(TLeft))
{
var relationship = item.Relationships.Single(v => v.Member == rightMember);
item.AddLazyRelationship(relationship);
}
}
return Join(joinType, rightMember, filterExpression);
}
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression)
{
_isJoin = true;