Skip to content

Commit

Permalink
Changed the prvatekey and client_id checks to use the constants and m…
Browse files Browse the repository at this point in the history
…oved chrome_1601 to a constant - so that all magic strings and path builders are in 1 location
  • Loading branch information
thatcoderguy committed Jun 13, 2024
1 parent 8cda128 commit 43d179b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions OF DL/CDMApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;

namespace WidevineClient.Widevine
Expand All @@ -9,7 +9,7 @@ public class CDMApi

public byte[] GetChallenge(string initDataB64, string certDataB64, bool offline = false, bool raw = false)
{
SessionId = CDM.OpenSession(initDataB64, "chrome_1610", offline, raw);
SessionId = CDM.OpenSession(initDataB64, Constants.DEVICE_NAME, offline, raw);
CDM.SetServiceCertificate(SessionId, Convert.FromBase64String(certDataB64));
return CDM.GetLicenseRequest(SessionId);
}
Expand Down
9 changes: 9 additions & 0 deletions OF DL/OF DL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="auth.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="rules.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions OF DL/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public async static Task Main(string[] args)
}
}

if (!File.Exists("cdm/devices/chrome_1610/device_client_id_blob"))
if (!File.Exists(Path.Join(WidevineClient.Widevine.Constants.DEVICES_FOLDER, WidevineClient.Widevine.Constants.DEVICE_NAME, "device_client_id_blob")))
{
clientIdBlobMissing = true;
}
Expand All @@ -230,7 +230,7 @@ public async static Task Main(string[] args)
AnsiConsole.Markup($"[green]device_client_id_blob located successfully![/]\n");
}

if (!File.Exists("cdm/devices/chrome_1610/device_private_key"))
if (!File.Exists(Path.Join(WidevineClient.Widevine.Constants.DEVICES_FOLDER, WidevineClient.Widevine.Constants.DEVICE_NAME, "device_private_key")))
{
devicePrivateKeyMissing = true;
}
Expand Down
4 changes: 2 additions & 2 deletions OF DL/Widevine/CDM.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ProtoBuf;
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -14,7 +14,7 @@ public class CDM
{
static Dictionary<string, CDMDevice> Devices { get; } = new Dictionary<string, CDMDevice>()
{
["chrome_1610"] = new CDMDevice("chrome_1610", null, null, null)
[Constants.DEVICE_NAME] = new CDMDevice(Constants.DEVICE_NAME, null, null, null)
};
static Dictionary<string, Session> Sessions { get; set; } = new Dictionary<string, Session>();

Expand Down
3 changes: 2 additions & 1 deletion OF DL/Widevine/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace WidevineClient.Widevine
namespace WidevineClient.Widevine
{
public class Constants
{
public static string WORKING_FOLDER { get; set; } = System.IO.Path.GetFullPath(System.IO.Path.Join(System.IO.Directory.GetCurrentDirectory(), "cdm"));
public static string DEVICES_FOLDER { get; set; } = System.IO.Path.GetFullPath(System.IO.Path.Join(WORKING_FOLDER, "devices"));
public static string DEVICE_NAME { get; set; } = "chrome_1610";
}
}

0 comments on commit 43d179b

Please sign in to comment.