Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add previously-unknown fields including sampleCount #1

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: 'Canary Release'
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled

jobs:
release:
name: 'Release Canary'
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'release:canary')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9'
dotnet-quality: 'ga'

- name: Package Library
run: dotnet pack ./src/Clickwheel/Clickwheel.csproj /p:VersionSuffix=canary.${HEAD_SHA::7}
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}

- name: Get Filename
id: get_filename
run: |
path_to_nupkg=$(find ./src/Clickwheel/bin/Release -type f -name "*.nupkg" | head -n 1)
version=$(echo "$path_to_nupkg" | sed -n 's/.*Clickwheel\.\([-0-9A-Za-z.]*\)\.nupkg/\1/p')
echo "path_to_nupkg=$path_to_nupkg" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT

- name: Publish to NuGet
run: |
dotnet nuget push ${{ steps.get_filename.outputs.path_to_nupkg }} \
--api-key ${{ secrets.CLICKWHEEL_NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate

- name: Comment
uses: marocchino/sticky-pull-request-comment@v2
if: success()
with:
header: 'canary-release'
message: |
### :package: Canary Package Published

Latest commit: ${{ github.event.pull_request.head.sha }}

#### Clickwheel@${{ steps.get_filename.outputs.version }}

```
dotnet add package Clickwheel --version ${{ steps.get_filename.outputs.version }}
```
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Test'
on:
pull_request:
push:
branches: [main]

jobs:
test:
name: 'Run Tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9'
dotnet-quality: 'ga'

- name: Run Tests
run: dotnet test Clickwheel.Filter.slnf
9 changes: 9 additions & 0 deletions Clickwheel.Filter.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"solution": {
"path": "Clickwheel.sln",
"projects": [
"src\\Clickwheel\\Clickwheel.csproj",
"tests\\Clickwheel.Tests\\Clickwheel.Tests.csproj"
]
}
}
4 changes: 2 additions & 2 deletions src/Clickwheel/Clickwheel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<PackageTags>iPod</PackageTags>
<Description>A modern cross-platform iPod management API for .NET</Description>
<PackageIcon>clickwheel.128.png</PackageIcon>
<Version>0.1.1</Version>
<VersionPrefix>0.1.2</VersionPrefix>
<TargetFramework>net7.0</TargetFramework>
<AnalysisLevel>latest-All</AnalysisLevel>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.4" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\ArtworkDB-empty" />
Expand Down
2 changes: 2 additions & 0 deletions src/Clickwheel/NewTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class NewTrack
/// </summary>
public uint Length;

public ulong SampleCount;

/// <summary>
/// Bitrate in kb (e.g. 192)
/// </summary>
Expand Down
46 changes: 44 additions & 2 deletions src/Clickwheel/Parsers/iTunesDB/Track.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public class Track : BaseDatabaseElement
private ulong _dbId2;
bool _hasLyrics,
_isVideoFile;
private bool _playedMark;
private byte _unk17;
private byte[] _unk21;
private int _pregap;
private ulong _sampleCount;
private byte[] _unk25;
private int _postgap;
private byte[] _unk27;
private byte[] _unk4,
_unk5;
private int _mediaType;
Expand Down Expand Up @@ -152,7 +160,15 @@ internal override void Read(IPod iPod, BinaryReader reader)
_dbId2 = reader.ReadUInt64();
_hasLyrics = reader.ReadBoolean();
_isVideoFile = reader.ReadBoolean();
_unk4 = reader.ReadBytes(30);
_playedMark = reader.ReadBoolean();
_unk17 = reader.ReadByte();
_unk21 = reader.ReadBytes(4);
_pregap = reader.ReadInt32();
_sampleCount = reader.ReadUInt64();
_unk25 = reader.ReadBytes(4);
_postgap = reader.ReadInt32();
_unk27 = reader.ReadBytes(4);
_unk4 = reader.ReadBytes(0);

_mediaType = reader.ReadInt32();
_unk5 = reader.ReadBytes(44);
Expand Down Expand Up @@ -222,6 +238,14 @@ internal override void Write(BinaryWriter writer)
writer.Write(_dbId2);
writer.Write(_hasLyrics);
writer.Write(_isVideoFile);
writer.Write(_playedMark);
writer.Write(_unk17);
writer.Write(_unk21);
writer.Write(_pregap);
writer.Write(_sampleCount);
writer.Write(_unk25);
writer.Write(_postgap);
writer.Write(_unk27);
writer.Write(_unk4);
writer.Write(_mediaType);
writer.Write(_unk5);
Expand Down Expand Up @@ -540,6 +564,16 @@ public uint Bitrate

public uint SampleRate => _sampleRate / 0x10000;

public ulong SampleCount
{
get => _sampleCount;
set
{
_sampleCount = value;
_isDirty = true;
}
}

/// <summary>
/// Volume Adjustment can be between -255 and 255. 0 is default. Use to make songs louder or quieter than normal.
/// </summary>
Expand Down Expand Up @@ -856,7 +890,15 @@ internal void Create(IPod iPod, NewTrack newTrack)

_unk1 = new byte[12];
_unk3 = new byte[38];
_unk4 = new byte[30];
_playedMark = false;
_unk17 = 0;
_unk21 = new byte[4];
_pregap = 0;
_sampleCount = newTrack.SampleCount;
_unk25 = new byte[4];
_postgap = 0;
_unk27 = new byte[4];
_unk4 = new byte[0];
_unk5 = new byte[44];
_unusedHeader = new byte[_headerSize - _requiredHeaderSize];
_type = new byte[2];
Expand Down
28 changes: 3 additions & 25 deletions src/Clickwheel/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
},
"SixLabors.ImageSharp": {
"type": "Direct",
"requested": "[2.1.0, )",
"resolved": "2.1.0",
"contentHash": "H8npUDq3VRagzRsJVxaNoUSMmD+kjAs7sR1Ip85eWbN5c0O1medMw/FiQ32dSNfWz/gVrc+xHs3es9SFlAiNBw==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "5.0.0",
"System.Text.Encoding.CodePages": "5.0.0"
}
"requested": "[3.1.6, )",
"resolved": "3.1.6",
"contentHash": "dHQ5jugF9v+5/LCVHCWVzaaIL6WOehqJy6eju/0VFYFPEj2WtqkGPoEV9EVQP83dHsdoqYaTuWpZdwAd37UwfA=="
},
"Microsoft.Data.Sqlite.Core": {
"type": "Transitive",
Expand All @@ -30,11 +26,6 @@
"SQLitePCLRaw.core": "2.0.6"
}
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ=="
},
"SQLitePCLRaw.bundle_e_sqlite3": {
"type": "Transitive",
"resolved": "2.0.6",
Expand Down Expand Up @@ -70,19 +61,6 @@
"type": "Transitive",
"resolved": "4.5.3",
"contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA=="
},
"System.Runtime.CompilerServices.Unsafe": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "NyscU59xX6Uo91qvhOs2Ccho3AR2TnZPomo1Z0K6YpyztBPM/A5VbkzOO19sy3A3i1TtEnTxA7bCe3Us+r5MWg==",
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0"
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Clickwheel.Tests/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static string DumpTrack(Track track)
track.FileType,
track.Bitrate.ToString(),
track.SampleRate.ToString(),
track.SampleCount.ToString(),
track.Length.ToString(),
track.FileSize.ToString(),
track.DateAdded.DateTime.ToString("o"),
Expand Down
23 changes: 3 additions & 20 deletions tests/Clickwheel.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,8 @@
},
"SixLabors.ImageSharp": {
"type": "Transitive",
"resolved": "2.1.0",
"contentHash": "H8npUDq3VRagzRsJVxaNoUSMmD+kjAs7sR1Ip85eWbN5c0O1medMw/FiQ32dSNfWz/gVrc+xHs3es9SFlAiNBw==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "5.0.0",
"System.Text.Encoding.CodePages": "5.0.0"
}
"resolved": "3.1.6",
"contentHash": "dHQ5jugF9v+5/LCVHCWVzaaIL6WOehqJy6eju/0VFYFPEj2WtqkGPoEV9EVQP83dHsdoqYaTuWpZdwAd37UwfA=="
},
"SQLitePCLRaw.bundle_e_sqlite3": {
"type": "Transitive",
Expand Down Expand Up @@ -808,11 +804,6 @@
"Microsoft.NETCore.Targets": "1.1.0"
}
},
"System.Runtime.CompilerServices.Unsafe": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA=="
},
"System.Runtime.Extensions": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -1039,14 +1030,6 @@
"System.Runtime": "4.3.0"
}
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "NyscU59xX6Uo91qvhOs2Ccho3AR2TnZPomo1Z0K6YpyztBPM/A5VbkzOO19sy3A3i1TtEnTxA7bCe3Us+r5MWg==",
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0"
}
},
"System.Text.Encoding.Extensions": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -1161,7 +1144,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Data.Sqlite": "[6.0.4, )",
"SixLabors.ImageSharp": "[2.1.0, )"
"SixLabors.ImageSharp": "[3.1.6, )"
}
}
}
Expand Down
Loading