Skip to content

Commit 10169eb

Browse files
authored
Fix metadata model parsing in probe. (#20)
1 parent 66af4b0 commit 10169eb

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

src/Ytdlp.NET.Console/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ private static async Task TestGetMetadataAsync(Ytdlp ytdlp)
130130

131131
var url1 = "https://www.youtube.com/watch?v=YyepU5ztLf4&list=PLXCoHsJ9oLef1c83KIbl9_h7tYyodL15J"; //playlist
132132
var url2 = "https://www.youtube.com/watch?v=JOIqPThxFb8"; // video
133-
var metadata = await ytdlp.GetMetadataAsync(url2);
133+
var url3 = "https://www.youtube.com/watch?v=lY5V4hSLWY8&list=RDlY5V4hSLWY8&start_radio=1&pp=ygUJcGxheWxpc3RzoAcB";
134+
var metadata = await ytdlp.GetMetadataAsync(url3);
134135
stopwatch.Stop(); // stop timer
135136

136137
Console.WriteLine($"Detailed metedata took {stopwatch.Elapsed.TotalSeconds:F3} seconds");

src/Ytdlp.NET/Metadata.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,32 @@ namespace ManuHub.Ytdlp.NET;
44

55
public class Metadata
66
{
7+
/// <summary>
8+
/// Video identifier
9+
/// </summary>
710
[JsonPropertyName("id")]
811
public string? Id { get; set; } // playlist/video
912

1013
[JsonPropertyName("_type")]
1114
public string? Type { get; set; } // playlist/video
1215

16+
/// <summary>
17+
/// Video title
18+
/// </summary>
1319
[JsonPropertyName("title")]
1420
public string? Title { get; set; } // playlist/video
1521

22+
/// <summary>
23+
/// The description of the video
24+
/// </summary>
1625
[JsonPropertyName("description")]
1726
public string? Description { get; set; } // playlist/video
1827

1928
[JsonPropertyName("thumbnail")]
2029
public string? Thumbnail { get; set; } // video
2130

2231
[JsonPropertyName("playlist_count")]
23-
public long PlaylistCount { get; set; } // playlist
32+
public long? PlaylistCount { get; set; } // playlist
2433

2534
[JsonPropertyName("categories")]
2635
public List<string>? Categories { get; set; } // video
@@ -71,13 +80,15 @@ public class Metadata
7180
[JsonPropertyName("extractor_key")]
7281
public string? ExtractorKey { get; set; } // playlist/video
7382

74-
83+
/// <summary>
84+
/// How many users have watched the video on the platform
85+
/// </summary>
7586
[JsonPropertyName("view_count")]
76-
public long? ViewCount { get; set; } // playlist/video
87+
public float? ViewCount { get; set; } // playlist/video
7788

7889

7990
[JsonPropertyName("duration")]
80-
public double? Duration { get; set; } // video
91+
public float? Duration { get; set; } // video
8192

8293
[JsonPropertyName("age_limit")]
8394
public int? AgeLimit { get; set; } // video
@@ -151,6 +162,9 @@ public class FormatMetadata
151162
[JsonPropertyName("format_note")]
152163
public string? FormatNote { get; set; }//
153164

165+
/// <summary>
166+
/// Video filename extension
167+
/// </summary>
154168
[JsonPropertyName("ext")]
155169
public string? Ext { get; set; }//
156170

@@ -317,7 +331,7 @@ public class Entry
317331
public string? Description { get; set; }
318332

319333
[JsonPropertyName("duration")]
320-
public int Duration { get; set; }
334+
public float Duration { get; set; }
321335

322336
[JsonPropertyName("channel_id")]
323337
public string? ChannelId { get; set; }
@@ -340,7 +354,10 @@ public class Entry
340354
[JsonPropertyName("thumbnails")]
341355
public List<ThumbnailMetadata>? Thumbnails { get; set; }
342356

357+
/// <summary>
358+
/// How many users have watched the video on the platform
359+
/// </summary>
343360
[JsonPropertyName("view_count")]
344-
public int ViewCount { get; set; }
361+
public float? ViewCount { get; set; }
345362

346363
}

0 commit comments

Comments
 (0)