Skip to content

Commit

Permalink
First steps toward creating song index
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Aug 1, 2014
1 parent b6635b9 commit f4b4463
Show file tree
Hide file tree
Showing 36 changed files with 62,343 additions and 5 deletions.
Binary file removed CommandLine.pdb
Binary file not shown.
Binary file modified RSTabConverter.v12.suo
Binary file not shown.
10 changes: 9 additions & 1 deletion RSTabConverter/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
14 changes: 14 additions & 0 deletions RSTabConverter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using CommandLine;
using CommandLine.Text;
using RSTabConverterLib;

namespace RSTabConverter
{
Expand All @@ -13,6 +14,19 @@ static void Main(string[] args)
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
Console.WriteLine("Opening archive {0} ...", options.PsarcFile);
try
{
var browser = new PsarcBrowser(options.PsarcFile);
var trackList = browser.GetTrackList();
foreach (var track in trackList)
{
Console.WriteLine("{0} - {1} [{2}, {3}]", track.Artist, track.Title, track.Album, track.Year);
}
}
catch (System.IO.FileNotFoundException e)
{
Console.WriteLine("The specified psarc file does not exist: {0}", e.FileName);
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions RSTabConverter/RSTabConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\CommandLine.dll</HintPath>
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -54,6 +58,10 @@
<None Include="musicxml.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RSTabConverterLib\RSTabConverterLib.csproj">
Expand Down
5 changes: 5 additions & 0 deletions RSTabConverter/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
</packages>
71 changes: 70 additions & 1 deletion RSTabConverterLib/PSARCBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,79 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RocksmithToolkitLib;
using RocksmithToolkitLib.PSARC;


namespace RSTabConverterLib
{
public class PSARCBrowser
/// <summary>
/// Reads in a Rocksmith PSARC archive and collects information on the
/// contained tracks. Can extract specific tracks for processing.
/// </summary>
public class PsarcBrowser
{
private PSARC archive;

/// <summary>
/// Create a new PsarcBrowser from a specified archive file.
/// </summary>
/// <param name="fileName">Path of the .psarc file to open.</param>
public PsarcBrowser(string fileName)
{
archive = new PSARC();
using (var stream = File.OpenRead(fileName))
{
archive.Read(stream);
}
}

public IList<TrackInfo> GetTrackList()
{
// Each song has a corresponding .json file within the archive containing
// information about it.
var infoFiles = archive.Entries.Where(x => x.Name.StartsWith(@"manifests/songs")
&& x.Name.EndsWith(".json")).OrderBy(x => x.Name);

var trackList = new List<TrackInfo>();

foreach (var entry in infoFiles)
{
Console.WriteLine("Entry found: {0}", entry.Name);
using (var reader = new StreamReader(entry.Data))
{
JObject o = JObject.Parse(reader.ReadToEnd());
var attributes = o["Entries"].First.Last["Attributes"];
var title = attributes["SongName"].ToString();
var artist = attributes["ArtistName"].ToString();
var album = attributes["AlbumName"].ToString();
var year = attributes["SongYear"].ToString();

var info = new TrackInfo()
{
Title = attributes["SongName"].ToString(),
Artist = attributes["ArtistName"].ToString(),
Album = attributes["AlbumName"].ToString(),
Year = attributes["SongYear"].ToString()
};
trackList.Add(info);
}
}

return trackList;
}
}


public class TrackInfo
{
public string Title { get; set; }
public string Artist { get; set; }
public string Album { get; set; }
public string Year { get; set; }
public string Key { get; set; }
}
}
12 changes: 11 additions & 1 deletion RSTabConverterLib/RSTabConverterLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RocksmithToolkitLib">
<HintPath>..\RocksmithToolkitLib.dll</HintPath>
</Reference>
Expand All @@ -40,11 +43,18 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="zlib.net">
<HintPath>..\zlib.net.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PSARCBrowser.cs" />
<Compile Include="PsarcBrowser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
11 changes: 11 additions & 0 deletions RSTabConverterLib/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
4 changes: 4 additions & 0 deletions RSTabConverterLib/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
</packages>
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit f4b4463

Please sign in to comment.