protected override VideoInfoControlViewModel NicoVideoToTemplatedItem( NicoVideo sourceItem , int index ) { return(new VideoInfoControlViewModel(sourceItem, _PageManager)); }
public SummaryVideoInfoContentViewModel(NicoVideo nicoVideo, Uri descriptionHtmlUri, PageManager pageManager) { _PageManager = pageManager; var user = Models.Db.UserInfoDb.Get(nicoVideo.OwnerId.ToString()); OwnerId = user.UserId; UserName = user.Name; UserIconUrl = user.IconUri; SubmitDate = nicoVideo.PostedAt; // UserName = response.UserName; PlayCount = nicoVideo.ViewCount; CommentCount = nicoVideo.CommentCount; MylistCount = nicoVideo.MylistCount; VideoDescriptionUri = descriptionHtmlUri; if (nicoVideo.Tags != null) { Tags = nicoVideo.Tags .Select(x => new TagViewModel(x, _PageManager)) .ToList(); } }
public CacheVideoViewModel(NicoVideo nicoVideo, PageManager pageManager) : base(nicoVideo, pageManager, isNgEnabled: false) { CacheRequestTime = nicoVideo.ObserveProperty(x => x.CachedAt) .ToReadOnlyReactiveProperty() .AddTo(_CompositeDisposable); }
private void button1_Click(object sender, EventArgs e) { if (txtVidId.Text == "") { return; } Console.WriteLine("button1_Click"); // クッキー確認 foreach (Cookie c in cc.GetCookies(new Uri("https://secure.nicovideo.jp/"))) { Console.WriteLine("クッキー名:" + c.Name.ToString()); Console.WriteLine("値:" + c.Value.ToString()); Console.WriteLine("ドメイン名:" + c.Domain.ToString()); } var client = NicoVideo.GetWebClientForFlv(txtVidId.Text, cc); client.DownloadProgressChanged += client_DownloadProgressChanged; client.DownloadFileCompleted += client_DownloadFileCompleted; var info = FlvInfo.Create(txtVidId.Text, cc); string url = info.FlvUrl; string deurl = HttpUtility.UrlDecode(url); var uri = new Uri(deurl); client.DownloadFileAsync(uri, txtVidId.Text + ".flv"); }
protected override CacheVideoViewModel NicoVideoToTemplatedItem( NicoVideo itemSource , int index ) { return(new CacheVideoViewModel( itemSource , _PageManager )); }
public static string MakeShareText(NicoVideo video) { if (!string.IsNullOrEmpty(video.VideoAliasId)) { return(MakeShareText(video.VideoAliasId)); } else { return(MakeShareText(video.Id)); } }
public RelatedVideosSidePaneContentViewModel(NicoVideo video, string jumpVideoId) { Video = video; _JumpVideoId = jumpVideoId; CurrentVideoId = video.RawVideoId; _VideoViewerHelpInfo = video.GetVideoRelatedInfomationWithVideoDescription();; HasVideoDescription = _VideoViewerHelpInfo != null; var _ = InitializeRelatedVideos(); }
protected override RankedVideoInfoControlViewModel NicoVideoToTemplatedItem( NicoVideo itemSource , int index ) { return(new RankedVideoInfoControlViewModel( (uint)(index + 1) , itemSource , _PageManager )); }
public VideoInfoPlaylistViewModel(string name, string id, NicoVideo video) { Name = name; Id = id; AddPlaylistCommand = new DelegateCommand(() => { var hohoemaPlaylist = video.HohoemaApp.Playlist; var playlist = hohoemaPlaylist.Playlists.FirstOrDefault(x => x.Id == Id); if (playlist == null) { return; } playlist.AddVideo(video.RawVideoId, video.Title); }); }
// 個別マイリストから取得したデータによる初期化 public VideoInfoControlViewModel(VideoInfo data, NicoVideo nicoVideo, PageManager pageManager) : this(nicoVideo, pageManager) { Title = data.Video.Title; RawVideoId = data.Video.Id; OptionText = data.Video.UploadTime.ToString(); if (!string.IsNullOrWhiteSpace(data.Video.ThumbnailUrl.OriginalString)) { ImageUrlsSource.Add(data.Video.ThumbnailUrl.OriginalString); } if (!nicoVideo.IsDeleted) { Description = $"再生:{data.Video.ViewCount}"; } ImageCaption = data.Video.Length.ToString(); // TODO: ユーザーフレンドリィ時間 VideoId = RawVideoId; }
public VideoListItemControlViewModel( NicoVideo videoItem ) : this(videoItem.Id, videoItem.Title, videoItem.ThumbnailUrl, videoItem.Length, videoItem.PostedAt) { if (videoItem.Owner is not null) { _ProviderId = videoItem.Owner.OwnerId; ProviderType = videoItem.Owner.UserType; _ProviderName = videoItem.Owner.ScreenName; ProviderIconUrl = videoItem.Owner.IconUrl; } UpdateIsHidenVideoOwner(this); if (VideoId != VideoId && VideoId != null) { SubscribeAll(VideoId); } }
public void SetupFromThumbnail(NicoVideo info) { // NG判定 if (_IsNGEnabled) { var ngResult = NicoVideo.CheckUserNGVideo(); IsVisible = ngResult == null; if (ngResult != null) { var ngDesc = !string.IsNullOrWhiteSpace(ngResult.NGDescription) ? ngResult.NGDescription : ngResult.Content; InvisibleDescription = $"NG動画"; } } Title = info.Title; OptionText = info.PostedAt.ToString("yyyy/MM/dd HH:mm"); if (!string.IsNullOrWhiteSpace(info.ThumbnailUrl)) { if (!ImageUrlsSource.Any(x => x == info.ThumbnailUrl)) { ImageUrlsSource.Add(info.ThumbnailUrl); } } if (!info.IsDeleted) { Description = $"再生:{info.ViewCount.ToString("N0")} コメ:{info.CommentCount.ToString("N0")} マイ:{info.MylistCount.ToString("N0")}"; } string timeText; if (info.VideoLength.Hours > 0) { timeText = info.VideoLength.ToString(@"hh\:mm\:ss"); } else { timeText = info.VideoLength.ToString(@"mm\:ss"); } ImageCaption = timeText; }
static public void CopyToClipboard(NicoVideo video) { CopyToClipboard(Helpers.ShareHelper.MakeShareTextWithTitle(video)); }
public static async Task ShareToTwitter(NicoVideo video) { await ShareToTwitter(MakeShareTextWithTitle(video)); }
public FeedVideoInfoControlViewModel(FeedItem feedItem, IFeedGroup feedGroup, NicoVideo nicoVideo, PageManager pageMan) : base(nicoVideo, pageMan) { IsUnread = feedItem.ToReactivePropertyAsSynchronized(x => x.IsUnread) .AddTo(_CompositeDisposable); _FafFeedItem = feedItem; _FeedGroup = feedGroup; }
protected override FeedVideoInfoControlViewModel NicoVideoToTemplatedItem(NicoVideo itemSource, int index) { var currentItem = _FeedGroup.FeedItems.ElementAtOrDefault(index); return(new FeedVideoInfoControlViewModel(currentItem, _FeedGroup, itemSource, _PageManager)); }
private async Task UpdateVideoDescription() { var videoDescriptionHtml = string.Empty; using (var releaser = await _UpdateLock.LockAsync()) { if (VideoId == null) { return; } IsLoadFailed.Value = false; try { var res = await NicoVideo.VisitWatchPage(VideoId); if (res is WatchApiResponse) { var watchApi = res as WatchApiResponse; VideoTitle = watchApi.videoDetail.title; Tags = watchApi.videoDetail.tagList.Select(x => new TagViewModel(x.tag)) .ToList(); ThumbnailUrl = watchApi.videoDetail.thumbnail; VideoLength = TimeSpan.FromSeconds(watchApi.videoDetail.length.Value); SubmitDate = DateTime.Parse(watchApi.videoDetail.postedAt); ViewCount = (uint)watchApi.videoDetail.viewCount.Value; CommentCount = (uint)watchApi.videoDetail.commentCount.Value; MylistCount = (uint)watchApi.videoDetail.mylistCount.Value; ProviderName = watchApi.UserName; OwnerIconUrl = watchApi.UploaderInfo?.icon_url ?? watchApi.channelInfo?.icon_url; IsChannelOwnedVideo = watchApi.channelInfo != null; videoDescriptionHtml = watchApi.videoDetail.description; } else if (res is DmcWatchData) { var dmcWatchApi = (res as DmcWatchData).DmcWatchResponse; VideoTitle = dmcWatchApi.Video.Title; Tags = dmcWatchApi.Tags.Select(x => new TagViewModel(x.Name)) .ToList(); ThumbnailUrl = dmcWatchApi.Video.ThumbnailURL; VideoLength = TimeSpan.FromSeconds(dmcWatchApi.Video.Duration); SubmitDate = DateTime.Parse(dmcWatchApi.Video.PostedDateTime); ViewCount = (uint)dmcWatchApi.Video.ViewCount; CommentCount = (uint)dmcWatchApi.Thread.CommentCount; MylistCount = (uint)dmcWatchApi.Video.MylistCount; ProviderId = dmcWatchApi.Owner?.Nickname ?? dmcWatchApi.Channel?.Name; ProviderName = dmcWatchApi.Owner?.Nickname ?? dmcWatchApi.Channel?.Name; OwnerIconUrl = dmcWatchApi.Owner?.IconURL ?? dmcWatchApi.Channel?.IconURL; IsChannelOwnedVideo = dmcWatchApi.Channel != null; videoDescriptionHtml = dmcWatchApi.Video.Description; } } catch { IsLoadFailed.Value = true; return; } RaisePropertyChanged(nameof(VideoTitle)); RaisePropertyChanged(nameof(Tags)); RaisePropertyChanged(nameof(ThumbnailUrl)); RaisePropertyChanged(nameof(VideoLength)); RaisePropertyChanged(nameof(SubmitDate)); RaisePropertyChanged(nameof(ViewCount)); RaisePropertyChanged(nameof(CommentCount)); RaisePropertyChanged(nameof(MylistCount)); RaisePropertyChanged(nameof(ProviderName)); RaisePropertyChanged(nameof(OwnerIconUrl)); } try { DescriptionHtmlFileUri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(VideoId, videoDescriptionHtml); RaisePropertyChanged(nameof(DescriptionHtmlFileUri)); } catch { IsLoadFailed.Value = true; return; } try { var htmlDocument = new HtmlAgilityPack.HtmlDocument(); htmlDocument.LoadHtml(videoDescriptionHtml); var root = htmlDocument.DocumentNode; var anchorNodes = root.Descendants("a"); foreach (var anchor in anchorNodes) { VideoDescriptionHyperlinkItems.Add(new HyperlinkItem() { Label = anchor.InnerText, Url = new Uri(anchor.Attributes["href"].Value) }); Debug.WriteLine($"{anchor.InnerText} : {anchor.Attributes["href"].Value}"); } var matches = GeneralUrlRegex.Matches(videoDescriptionHtml); foreach (var match in matches.Cast <Match>()) { if (!VideoDescriptionHyperlinkItems.Any(x => x.Url.OriginalString == match.Value)) { VideoDescriptionHyperlinkItems.Add(new HyperlinkItem() { Label = match.Value, Url = new Uri(match.Value) }); Debug.WriteLine($"{match.Value} : {match.Value}"); } } RaisePropertyChanged(nameof(VideoDescriptionHyperlinkItems)); } catch { Debug.WriteLine("動画説明からリンクを抜き出す処理に失敗"); } }
private async Task UpdateVideoDescription() { using (var releaser = await _UpdateLock.LockAsync()) { if (VideoInfo.RawVideoId == null) { return; } IsLoadFailed.Value = false; try { var res = await NicoVideo.PreparePlayVideoAsync(VideoInfo.RawVideoId); VideoDetals = res.GetVideoDetails(); //VideoTitle = details.VideoTitle; //Tags = details.Tags.ToList(); //ThumbnailUrl = details.ThumbnailUrl; //VideoLength = details.VideoLength; //SubmitDate = details.SubmitDate; //ViewCount = details.ViewCount; //CommentCount = details.CommentCount; //MylistCount = details.MylistCount; //ProviderId = details.ProviderId; //ProviderName = details.ProviderName; //OwnerIconUrl = details.OwnerIconUrl; //IsChannelOwnedVideo = details.IsChannelOwnedVideo; } catch { IsLoadFailed.Value = true; return; } } try { ApplicationTheme appTheme; if (_appearanceSettings.Theme == ElementTheme.Dark) { appTheme = ApplicationTheme.Dark; } else if (_appearanceSettings.Theme == ElementTheme.Light) { appTheme = ApplicationTheme.Light; } else { appTheme = Views.Helpers.SystemThemeHelper.GetSystemTheme(); } DescriptionHtmlFileUri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(VideoInfo.VideoId, VideoDetals.DescriptionHtml, appTheme); RaisePropertyChanged(nameof(DescriptionHtmlFileUri)); } catch { IsLoadFailed.Value = true; return; } VideoDescriptionHyperlinkItems.Clear(); try { var htmlDocument = new HtmlAgilityPack.HtmlDocument(); htmlDocument.LoadHtml(VideoDetals.DescriptionHtml); var root = htmlDocument.DocumentNode; var anchorNodes = root.Descendants("a"); foreach (var anchor in anchorNodes) { var href = anchor.Attributes["href"].Value; if (!Uri.IsWellFormedUriString(href, UriKind.Absolute)) { Debug.WriteLine("リンク抽出スキップ: " + anchor.InnerText); continue; } VideoDescriptionHyperlinkItems.Add(new HyperlinkItem() { Label = anchor.InnerText, Url = new Uri(href) }); Debug.WriteLine($"{anchor.InnerText} : {anchor.Attributes["href"].Value}"); } var matches = GeneralUrlRegex.Matches(VideoDetals.DescriptionHtml); foreach (var match in matches.Cast <Match>()) { if (!VideoDescriptionHyperlinkItems.Any(x => x.Url.OriginalString == match.Value)) { VideoDescriptionHyperlinkItems.Add(new HyperlinkItem() { Label = match.Value, Url = new Uri(match.Value) }); Debug.WriteLine($"{match.Value} : {match.Value}"); } } RaisePropertyChanged(nameof(VideoDescriptionHyperlinkItems)); } catch { Debug.WriteLine("動画説明からリンクを抜き出す処理に失敗"); } }
public VideoInfoControlViewModel(NicoVideo nicoVideo, PageManager pageManager, bool isNgEnabled = true, PlaylistItem playlistItem = null) { PageManager = pageManager; HohoemaPlaylist = nicoVideo.HohoemaApp.Playlist; NicoVideo = nicoVideo; PlaylistItem = playlistItem; _CompositeDisposable = new CompositeDisposable(); _IsNGEnabled = isNgEnabled; Title = nicoVideo.Title; RawVideoId = nicoVideo.RawVideoId; VideoId = nicoVideo.VideoId; if (nicoVideo.IsDeleted) { Description = "Deleted"; } IsRequireConfirmDelete = new ReactiveProperty <bool>(nicoVideo.IsRequireConfirmDelete); PrivateReasonText = nicoVideo.PrivateReasonType.ToString() ?? ""; SetupFromThumbnail(nicoVideo); QualityDividedVideos = new ObservableCollection <QualityDividedNicoVideoListItemViewModel>(); NicoVideo.QualityDividedVideos.CollectionChangedAsObservable() .Subscribe(_ => ResetQualityDivideVideosVM()) .AddTo(_CompositeDisposable); if (QualityDividedVideos.Count == 0 && NicoVideo.QualityDividedVideos.Count != 0) { ResetQualityDivideVideosVM(); } IsCacheRequested = NicoVideo.QualityDividedVideos .ObserveElementProperty(x => x.IsCacheRequested) .Select(x => NicoVideo.QualityDividedVideos.Any(y => y.IsCacheRequested)) .ToReadOnlyReactiveProperty() .AddTo(_CompositeDisposable); IsCacheEnabled = nicoVideo.HohoemaApp.UserSettings.CacheSettings.IsEnableCache; Observable.CombineLatest( IsCacheRequested, NicoVideo.ObserveProperty(x => x.IsPlayed) ) .Select(x => { if (x[0]) { return(Windows.UI.Colors.Green); } else if (x[1]) { return(Windows.UI.Colors.Transparent); } else { return(Windows.UI.Colors.Gray); } }) .Subscribe(color => ThemeColor = color) .AddTo(_CompositeDisposable); }
public static string MakeShareTextWithTitle(NicoVideo video) { return($"{video.Title} {MakeShareText(video)}"); }
public ShereVideoInfoContentViewModel(NicoVideo nicoVideo, TextInputDialogService textInputService, ToastNotificationService toastService) { _NicoVideo = nicoVideo; _TextInputDialogService = textInputService; _ToastNotificationService = toastService; }
public HistoryVideoInfoControlViewModel(uint viewCount, NicoVideo nicoVideo, PageManager pageManager) : base(nicoVideo, pageManager) { UserViewCount = viewCount; }
public RankedVideoInfoControlViewModel(uint rank, NicoVideo nicoVideo, PageManager pageManager) : base(nicoVideo, pageManager) { Rank = rank; }
protected abstract T NicoVideoToTemplatedItem(NicoVideo sourceNicoVideos, int index);