-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement AdSlotRenderer * Add tests for AdSlotRenderer
- Loading branch information
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Text; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace InnerTube.Renderers; | ||
|
||
public class AdSlotRenderer : IRenderer | ||
{ | ||
public string Type => "adSlotRenderer"; | ||
|
||
public IRenderer? Content { get; } | ||
|
||
public AdSlotRenderer(JToken renderer) | ||
{ | ||
JProperty? obj = renderer | ||
.GetFromJsonPath<JObject>("fulfillmentContent.fulfilledLayout.inFeedAdLayoutRenderer.renderingContent") | ||
?.First?.ToObject<JProperty>(); | ||
Content = obj != null ? RendererManager.ParseRenderer(obj.Value.ToObject<JObject>(), obj.Name)! : null; | ||
} | ||
|
||
public override string ToString() => | ||
new StringBuilder() | ||
.AppendLine($"[{Type}]") | ||
.AppendLine(string.Join('\n', | ||
Content?.ToString()?.Split('\n').Select(x => $"\t{x}") ?? Array.Empty<string>())) | ||
.ToString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters