Create standalone track method

Update Iris
This commit is contained in:
Yoshi Askharoun
2023-10-09 00:57:37 -05:00
parent dbf74db8ef
commit b58ec999ff
2 changed files with 104 additions and 101 deletions
@@ -219,6 +219,8 @@ namespace Microsoft.Zune.Library
}
#endregion
var filterIds = (albumId, artistId, genreId);
string text = (string)GetProperty("QueryType");
EQueryType queryType = EQueryType.eQueryTypeInvalid;
@@ -470,7 +472,11 @@ namespace Microsoft.Zune.Library
}
var stTracks = m_dataRoot.Library.GetTracksAsync(int.MaxValue, 0);
await foreach (var stTrack in stTracks)
{
var track = await CreateTrack(stTrack, queryType, filterIds);
queryList.Add(track.Item);
}
}
else if (text == "AlbumByTOC")
{
@@ -607,9 +613,7 @@ namespace Microsoft.Zune.Library
Status = DataProviderQueryStatus.Complete;
}
private Schemas.Track CreateTrack(ZuneQueryList queryList, )
{
await foreach (var stTrack in stTracks)
private async Task<Schemas.Track> CreateTrack(ITrack stTrack, EQueryType queryType, (int? album, int? albumArtist, int? genre) filterIds)
{
var stAlbum = stTrack.Album;
var stAlbumArtist = stAlbum != null
@@ -620,28 +624,28 @@ namespace Microsoft.Zune.Library
if (queryType == EQueryType.eQueryTypeTracksForAlbumId)
{
var currentAlbumId = stAlbum?.Id.HashToInt32();
if (currentAlbumId != albumId) continue;
if (currentAlbumId != filterIds.album) return null;
}
else if (queryType == EQueryType.eQueryTypeTracksForAlbumArtistId)
{
var currentAlbumArtistId = stAlbumArtist?.Id.HashToInt32();
if (currentAlbumArtistId != albumArtistId) continue;
if (currentAlbumArtistId != filterIds.albumArtist) return null;
}
else if (queryType == EQueryType.eQueryTypeTracksByGenreId)
{
var containsCurrentGenre = await stTrack.GetGenresAsync(int.MaxValue, 0)
.Select(g => g.Name.HashToInt32())
.AnyAsync(g => g == genreId);
.AnyAsync(g => g == filterIds.genre);
if (!containsCurrentGenre && stAlbum != null)
{
// If the track doesn't have the genre, the album might.
containsCurrentGenre = await stAlbum.GetGenresAsync(int.MaxValue, 0)
.Select(g => g.Name.HashToInt32())
.AnyAsync(g => g == genreId);
.AnyAsync(g => g == filterIds.genre);
}
if (!containsCurrentGenre) continue;
if (!containsCurrentGenre) return null;
}
Schemas.Track track = new(m_dataType)
@@ -720,8 +724,7 @@ namespace Microsoft.Zune.Library
track.Genre = stGenre?.Name;
track.Item.Storage["StrixItem"] = stTrack;
queryList.Add(track.Item);
}
return track;
}
}