Skip to content

Commit

Permalink
Fix and improve Gunloader Album hydration logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MirisWisdom committed Dec 4, 2021
1 parent c5e2d8a commit ac67ecf
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Albums/Gunloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,20 @@ public Gunloader(FileInfo file)

public override void Hydrate(Metadata metadata)
{
var records = ReadAllLines(_file.FullName)
var lines = ReadAllLines(_file.FullName)
.Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#') && !line.StartsWith(';'))
.ToArray();

Title = records[0].Trim();
Source = records[1].Trim();
var title = lines[0].Trim(); /* first line */
var source = lines[1].Trim(); /* second line */
var records = lines.Skip(2).ToList(); /* remaining lines */

/**
* Parse the Records file when the first line is NOT a YouTube video, or when no Tracks have been successfully
* inferred from YouTube chapters.
*/
Title = title;
Source = source;

for (var i = 2; i < records.Skip(2).Count(); i++)
foreach (var song in records)
{
var split = records[i].Split(' ');
var split = song.Split(' ');
var track = new Track
{
Number = split[0],
Expand Down Expand Up @@ -118,4 +117,4 @@ public override void Load(ISerialisation serialisation)
Tracks = album.Tracks;
}
}
}
}

0 comments on commit ac67ecf

Please sign in to comment.