Skip to content

Commit ab6d4e5

Browse files
committed
[Milky] append more meta info to incoming media segments (SaltifyDev/milky/@2bbeeba18e4c165bf9cb5ed91454f1a07a26e54b)
1 parent b6369a7 commit ab6d4e5

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

Lagrange.Milky/Entity/Segment/ImageSegment.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ namespace Lagrange.Milky.Entity.Segment;
55
[method: JsonConstructor]
66
public class ImageIncomingSegment(ImageIncomingSegmentData data) : IncomingSegmentBase<ImageIncomingSegmentData>(data)
77
{
8-
public ImageIncomingSegment(string resourceId, string tempUrl, string summary, string subType) : this(new ImageIncomingSegmentData(resourceId, tempUrl, summary, subType)) { }
8+
public ImageIncomingSegment(string resourceId, string tempUrl, int width, int height, string summary, string subType) : this(new ImageIncomingSegmentData(resourceId, tempUrl, width, height, summary, subType)) { }
99
}
1010

1111
public class ImageOutgoingSegment(ImageOutgoingSegmentData data) : OutgoingSegmentBase<ImageOutgoingSegmentData>(data) { }
1212

13-
public class ImageIncomingSegmentData(string resourceId, string tempUrl, string summary, string subType)
13+
public class ImageIncomingSegmentData(string resourceId, string tempUrl, int width, int height, string summary, string subType)
1414
{
1515
[JsonPropertyName("resource_id")]
1616
public string ResourceId { get; } = resourceId;
1717

1818
[JsonPropertyName("temp_url")]
1919
public string TempUrl { get; } = tempUrl;
2020

21+
[JsonPropertyName("width")]
22+
public int Width { get; } = width;
23+
24+
[JsonPropertyName("height")]
25+
public int Height { get; } = height;
26+
2127
[JsonPropertyName("summary")]
2228
public string Summary { get; } = summary;
2329

Lagrange.Milky/Entity/Segment/VideoSegment.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ namespace Lagrange.Milky.Entity.Segment;
55
[method: JsonConstructor]
66
public class VideoIncomingSegment(VideoIncomingSegmentData data) : IncomingSegmentBase<VideoIncomingSegmentData>(data)
77
{
8-
public VideoIncomingSegment(string resourceId, string tempUrl) : this(new VideoIncomingSegmentData(resourceId, tempUrl)) { }
8+
public VideoIncomingSegment(string resourceId, string tempUrl, int width, int height, int duration) : this(new VideoIncomingSegmentData(resourceId, tempUrl, width, height, duration)) { }
99
}
1010

1111
public class VideoOutgoingSegment(VideoOutgoingSegmentData data) : OutgoingSegmentBase<VideoOutgoingSegmentData>(data) { }
1212

13-
public class VideoIncomingSegmentData(string resourceId, string tempUrl)
13+
public class VideoIncomingSegmentData(string resourceId, string tempUrl, int width, int height, int duration)
1414
{
1515
[JsonPropertyName("resource_id")]
1616
public string ResourceId { get; } = resourceId;
1717

1818
[JsonPropertyName("temp_url")]
1919
public string TempUrl { get; } = tempUrl;
20+
21+
[JsonPropertyName("width")]
22+
public int Width { get; } = width;
23+
24+
[JsonPropertyName("height")]
25+
public int Height { get; } = height;
26+
27+
[JsonPropertyName("duration")]
28+
public int Duration { get; } = duration;
2029
}
2130

2231
public class VideoOutgoingSegmentData(string uri, string? thumbUri)

Lagrange.Milky/Utility/EntityConvert.Segment.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public async Task<MessageChain> FakeSegmentsAsync(IReadOnlyList<IOutgoingSegment
5353
ImageEntity image => new ImageIncomingSegment(
5454
image.FileUuid,
5555
image.FileUrl,
56+
(int)image.ImageSize.X,
57+
(int)image.ImageSize.Y,
5658
image.Summary,
5759
image.SubType switch
5860
{
@@ -61,7 +63,13 @@ public async Task<MessageChain> FakeSegmentsAsync(IReadOnlyList<IOutgoingSegment
6163
}
6264
),
6365
RecordEntity record => new RecordIncomingSegment(record.FileUuid, record.FileUrl, (int)record.RecordLength),
64-
VideoEntity video => new VideoIncomingSegment(video.FileUuid, video.FileUrl),
66+
VideoEntity video => new VideoIncomingSegment(
67+
video.FileUuid,
68+
video.FileUrl,
69+
(int)video.VideoSize.X,
70+
(int)video.VideoSize.Y,
71+
(int)video.VideoLength
72+
),
6573
MultiMsgEntity multiMsg => new ForwardIncomingSegment(multiMsg.ResId!),
6674
// ? => new MarketFaceSegment(...),
6775
// ? => new LightAppSegment(...),

0 commit comments

Comments
 (0)