/// <summary> /// Initializes a new instance of the <see cref="YoutubePlaylist"/> class with the specified /// URL pointing to the video on Youtube and the specified <see cref="PlaylistRefreshFlags"/> and <see cref="VideoRefreshFlags"/> /// which will be passed to the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> method when the <see cref="YoutubePlaylist"/> /// object is done initializing. /// </summary> /// /// <param name="url"> /// URL pointing to the video on Youtube. /// </param> /// <param name="flags"> /// The <see cref="PlaylistRefreshFlags"/> which will be passed to the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> method /// when the <see cref="YoutubePlaylist"/> is done initializing. /// </param> /// <param name="vidFlags"> /// The <see cref="VideoRefreshFlags"/> which will be passed to the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> method /// when the <see cref="YoutubePlaylist"/> is done initializing. /// </param> public YoutubePlaylist(Uri url, PlaylistRefreshFlags flags, VideoRefreshFlags vidFlags) { if (url == null) { throw new ArgumentNullException(nameof(url)); } Url = url; if (flags != PlaylistRefreshFlags.None) { Refresh(flags, vidFlags); } }
/// <summary> /// Initializes a new instance of the <see cref="YoutubePlaylist"/> class with the specified /// Youtube playlist ID and the specified <see cref="PlaylistRefreshFlags"/> and <see cref="VideoRefreshFlags"/> /// which will be passed to the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> method when the <see cref="YoutubePlaylist"/> /// object is done initializing. /// </summary> /// /// <param name="playlistId"> /// Youtube playlist ID. /// </param> /// <param name="flags"> /// The <see cref="PlaylistRefreshFlags"/> which will be passed to the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> method /// when the <see cref="YoutubePlaylist"/> is done initializing. /// </param> /// <param name="vidFlags"> /// The <see cref="VideoRefreshFlags"/> which will be passed to the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> method /// when the <see cref="YoutubePlaylist"/> is done initializing. /// </param> public YoutubePlaylist(string playlistId, PlaylistRefreshFlags flags, VideoRefreshFlags vidFlags) { if (string.IsNullOrWhiteSpace(playlistId)) { throw new ArgumentNullException(nameof(playlistId)); } _playlist = new List <YoutubeVideo>(); Url = new Uri(BaseUrl.OriginalString + playlistId); if (flags != PlaylistRefreshFlags.None) { Refresh(flags, vidFlags); } }
/// <summary> /// Refreshes the <see cref="YoutubePlaylist"/> object with the specified <see cref="PlaylistRefreshFlags"/> and /// the specified <see cref="VideoRefreshFlags"/> with which to update the <see cref="YoutubeVideo"/> objects in /// the <see cref="YoutubePlaylist"/>. /// </summary> /// /// <param name="flags"> /// <see cref="PlaylistRefreshFlags"/> with which to update the <see cref="YoutubePlaylist"/> object. /// </param> /// <param name="vidFlags"> /// <see cref="VideoRefreshFlags"/> with which to update the <see cref="YoutubeVideo"/> objects in the /// <see cref="YoutubePlaylist"/>. /// </param> public void Refresh(PlaylistRefreshFlags flags, VideoRefreshFlags vidFlags) { if (_url == null) { throw new InvalidOperationException("Cannot Refresh YoutubePlaylist object when Url is null."); } if (flags == PlaylistRefreshFlags.None) { return; } var webpage = (string)null; using (var client = new WebClient()) webpage = client.DownloadString(_url); var extractor = new YoutubePlaylistExtractor(webpage); if (!extractor.ExtractAvailability()) { throw new YoutubePlaylistNotAvailableException(this, "Youtube playlist is unavailable."); } if (flags.HasFlag(PlaylistRefreshFlags.Title)) { _title = extractor.ExtractTitle(); } if (flags.HasFlag(PlaylistRefreshFlags.ViewCount)) { _views = extractor.ExtractViews(); } if (flags.HasFlag(PlaylistRefreshFlags.Playlist)) { _playlist = extractor.ExtractPlaylist(vidFlags); } }
/// <summary> /// Initializes a new instance of the <see cref="YoutubePlaylist"/> class with the specified /// Youtube playlist ID and the specified <see cref="PlaylistRefreshFlags"/> which will be passed to /// the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> with <see cref="VideoRefreshFlags.None"/> /// method when the <see cref="YoutubePlaylist"/> object is done initializing. /// </summary> /// /// <param name="playlistId"> /// Youtube playlist ID. /// </param> /// <param name="flags"> /// The <see cref="PlaylistRefreshFlags"/> which will be passed to the <see cref="Refresh(PlaylistRefreshFlags)"/> method /// when the <see cref="YoutubePlaylist"/> is done initializing. /// </param> public YoutubePlaylist(string playlistId, PlaylistRefreshFlags flags) : this(playlistId, flags, VideoRefreshFlags.None) { // Space }
/// <summary> /// Refreshes the <see cref="YoutubePlaylist"/> object with the specified <see cref="PlaylistRefreshFlags"/> and updates it. /// </summary> /// /// <param name="flags"> /// <see cref="PlaylistRefreshFlags"/> with which to update the <see cref="YoutubePlaylist"/> object. /// </param> public void Refresh(PlaylistRefreshFlags flags) { Refresh(flags, VideoRefreshFlags.None); }
/// <summary> /// Initializes a new instance of the <see cref="YoutubePlaylist"/> class with the specified /// URL pointing to the video on Youtube and the specified <see cref="PlaylistRefreshFlags"/> which will be passed to /// the <see cref="Refresh(PlaylistRefreshFlags, VideoRefreshFlags)"/> with <see cref="VideoRefreshFlags.None"/> /// method when the <see cref="YoutubePlaylist"/> object is done initializing. /// </summary> /// /// <param name="url"> /// URL pointing to the video on Youtube. /// </param> /// <param name="flags"> /// The <see cref="PlaylistRefreshFlags"/> which will be passed to the <see cref="Refresh(PlaylistRefreshFlags)"/> method /// when the <see cref="YoutubePlaylist"/> is done initializing. /// </param> public YoutubePlaylist(Uri url, PlaylistRefreshFlags flags) : this(url, flags, VideoRefreshFlags.None) { // Space }