Skip to content

Commit

Permalink
Implement ExtractVideoDetailsAsync (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo authored Oct 15, 2023
1 parent 95df210 commit face170
Show file tree
Hide file tree
Showing 4 changed files with 405 additions and 338 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This is the NuGet package library that retrieves subtitles from a given YouTube
1. Extract subtitles from the given YouTube video URL. There are a few options to extract subtitles.

```csharp
// Extract video details from the given YouTube video URL.
// Extract video details, including the list of available language codes, from the given YouTube video URL.
VideoDetails details = await youtube.ExtractVideoDetailsAsync(youtubeUrl);

// Extract a single subtitle from the given YouTube video URL.
Expand Down
239 changes: 122 additions & 117 deletions src/YouTubeSubtitlesExtractor/Models/VideoDetails.cs
Original file line number Diff line number Diff line change
@@ -1,117 +1,122 @@
using Newtonsoft.Json;

namespace Aliencube.YouTubeSubtitlesExtractor.Models;

/// <summary>
/// This represents the entity of YouTube video details.
/// </summary>
public class VideoDetails
{
/// <summary>
/// Gets or sets the video ID.
/// </summary>
public virtual string? VideoId { get; set; }

/// <summary>
/// Gets or sets the video title.
/// </summary>
public virtual string? Title { get; set; }

/// <summary>
/// Gets or sets the video length in seconds.
/// </summary>
[JsonProperty("lengthSeconds")]
public virtual int? LengthInSeconds { get; set; }

/// <summary>
/// Gets or sets the list of keywords of the video.
/// </summary>
public virtual List<string> Keywords { get; set; } = new List<string>();

/// <summary>
/// Gets or sets the channel ID.
/// </summary>
public virtual string? ChannelId { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's owner view or not.
/// </summary>
public virtual bool IsOwnerViewing { get; set; }

/// <summary>
/// Gets or sets the short description of the video.
/// </summary>
public virtual string? ShortDescription { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's crawlable or not.
/// </summary>
public virtual bool IsCrawlable { get; set; }

/// <summary>
/// Gets or sets the <see cref="Aliencube.YouTubeSubtitlesExtractor.Models.Thumbnail"/> value.
/// </summary>
public virtual Thumbnail? Thumbnail { get; set; }

/// <summary>
/// Gets or sets the value indicating whether to allow ratings or not.
/// </summary>
public virtual bool AllowRatings { get; set; }

/// <summary>
/// Gets or sets the video count.
/// </summary>
public virtual int? ViewCount { get; set; }

/// <summary>
/// Gets or sets the video author.
/// </summary>
public virtual string? Author { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's private or not.
/// </summary>
public virtual bool IsPrivate { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's unplugged corpus or not.
/// </summary>
public virtual bool IsUnpluggedCorpus { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's live content or not.
/// </summary>
public virtual bool IsLiveContent { get; set; }
}

/// <summary>
/// This represents the thumbnail entity.
/// </summary>
public class Thumbnail
{
/// <summary>
/// Gets or sets the list of thumbnails.
/// </summary>
public virtual List<ThumbnailItem> Thumbnails { get; set; } = new List<ThumbnailItem>();
}

/// <summary>
/// This represents the thumbnail item entity.
/// </summary>
public class ThumbnailItem
{
/// <summary>
/// Gets or sets the thumbnail URL.
/// </summary>
public virtual string? Url { get; set; }

/// <summary>
/// Gets or sets the thumbnail width.
/// </summary>
public virtual int? Width { get; set; }

/// <summary>
/// Gets or sets the thumbnail height.
/// </summary>
public virtual int? Height { get; set; }
}
using Newtonsoft.Json;

namespace Aliencube.YouTubeSubtitlesExtractor.Models;

/// <summary>
/// This represents the entity of YouTube video details.
/// </summary>
public class VideoDetails
{
/// <summary>
/// Gets or sets the video ID.
/// </summary>
public virtual string? VideoId { get; set; }

/// <summary>
/// Gets or sets the video title.
/// </summary>
public virtual string? Title { get; set; }

/// <summary>
/// Gets or sets the video length in seconds.
/// </summary>
[JsonProperty("lengthSeconds")]
public virtual int? LengthInSeconds { get; set; }

/// <summary>
/// Gets or sets the list of keywords of the video.
/// </summary>
public virtual List<string> Keywords { get; set; } = new List<string>();

/// <summary>
/// Gets or sets the channel ID.
/// </summary>
public virtual string? ChannelId { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's owner view or not.
/// </summary>
public virtual bool IsOwnerViewing { get; set; }

/// <summary>
/// Gets or sets the short description of the video.
/// </summary>
public virtual string? ShortDescription { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's crawlable or not.
/// </summary>
public virtual bool IsCrawlable { get; set; }

/// <summary>
/// Gets or sets the <see cref="Models.Thumbnail"/> value.
/// </summary>
public virtual Thumbnail? Thumbnail { get; set; }

/// <summary>
/// Gets or sets the value indicating whether to allow ratings or not.
/// </summary>
public virtual bool AllowRatings { get; set; }

/// <summary>
/// Gets or sets the video count.
/// </summary>
public virtual int? ViewCount { get; set; }

/// <summary>
/// Gets or sets the video author.
/// </summary>
public virtual string? Author { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's private or not.
/// </summary>
public virtual bool IsPrivate { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's unplugged corpus or not.
/// </summary>
public virtual bool IsUnpluggedCorpus { get; set; }

/// <summary>
/// Gets or sets the value indicating whether it's live content or not.
/// </summary>
public virtual bool IsLiveContent { get; set; }

/// <summary>
/// Gets or sets the list of available langauge codes.
/// </summary>
public virtual List<string> AvaiableLanguageCodes { get; set; } = new List<string>();
}

/// <summary>
/// This represents the thumbnail entity.
/// </summary>
public class Thumbnail
{
/// <summary>
/// Gets or sets the list of thumbnails.
/// </summary>
public virtual List<ThumbnailItem> Thumbnails { get; set; } = new List<ThumbnailItem>();
}

/// <summary>
/// This represents the thumbnail item entity.
/// </summary>
public class ThumbnailItem
{
/// <summary>
/// Gets or sets the thumbnail URL.
/// </summary>
public virtual string? Url { get; set; }

/// <summary>
/// Gets or sets the thumbnail width.
/// </summary>
public virtual int? Width { get; set; }

/// <summary>
/// Gets or sets the thumbnail height.
/// </summary>
public virtual int? Height { get; set; }
}
Loading

0 comments on commit face170

Please sign in to comment.