Exemple #1
0
        public async Task <List <UserOwnedMylist> > GetLoginUserMylistGroups()
        {
            if (!NiconicoSession.IsLoggedIn)
            {
                return(null);
            }

            List <UserOwnedMylist> mylistGroups = new List <UserOwnedMylist>();

            {
                var defaultMylist = await GetDefaultMylistAsync();

                mylistGroups.Add(defaultMylist);
            }

            var res = await ContextActionAsync(async context =>
            {
                return(await context.User.GetMylistGroupListAsync());
            });

            foreach (var mylistGroup in res ?? Enumerable.Empty <MylistGroupData>())
            {
                var mylistItems = await ContextActionWithPageAccessWaitAsync(async context =>
                {
                    return(await context.User.GetMylistItemListAsync(mylistGroup.Id));
                });


                var videos = mylistItems.Select(x => MylistDataToNicoVideoData(x).RawVideoId);
                var mylist = new UserOwnedMylist(mylistGroup.Id, this, new System.Collections.ObjectModel.ObservableCollection <string>(videos))
                {
                    UserId       = mylistGroup.UserId,
                    Label        = mylistGroup.Name,
                    Description  = mylistGroup.Description,
                    IsPublic     = mylistGroup.GetIsPublic(),
                    IconType     = mylistGroup.GetIconType(),
                    ThumnailUrls = mylistGroup.ThumbnailUrls?.ToList() ?? new List <Uri>(),
                };

                _ = Task.Run(() =>
                {
                    var mylistId = mylistGroup.Id;
                    Database.Temporary.MylistDb.AddItemId(
                        mylistItems.Select(x => new Database.Temporary.MylistItemIdContainer()
                    {
                        MylistGroupId = mylistId,
                        VideoId       = x.WatchId,
                        ItemId        = x.ItemId
                    }));
                });

                mylistGroups.Add(mylist);
            }

            return(mylistGroups);
        }
Exemple #2
0
        public void Update(UserOwnedMylist info)
        {
            Label       = info.Label;
            Description = info.Description;
            OptionText  = (info.IsPublic ? "公開" : "非公開") + $" - {info.ItemCount}件";

            ThemeColor = info.IconType.ToColor();

            // ユーザーマイリストの情報はそのままではサムネが取れない
            // マイリスト内の動画からサムネを取得する?
        }
Exemple #3
0
        private async Task <UserOwnedMylist> GetDefaultMylistAsync()
        {
            if (!NiconicoSession.IsLoggedIn)
            {
                throw new System.Exception("");
            }

            var defMylist = await ContextActionAsync(async context =>
            {
                return(await context.User.GetMylistItemListAsync(UserOwnedMylist.DefailtMylistId));
            });


            List <Database.NicoVideo> videoItems = new List <Database.NicoVideo>();

            foreach (var item in defMylist)
            {
                if (item.ItemType == NiconicoItemType.Video)
                {
                    var video = MylistDataToNicoVideoData(item);

                    videoItems.Add(video);
                }
            }


            var mylist = new UserOwnedMylist(UserOwnedMylist.DefailtMylistId, this, new System.Collections.ObjectModel.ObservableCollection <string>(videoItems.Select(x => x.RawVideoId)))
            {
                Label    = "とりあえずマイリスト",
                UserId   = NiconicoSession.UserId.ToString(),
                IsPublic = false,
                Sort     = MylistDefaultSort.Latest,
            };

            _ = Task.Run(() =>
            {
                var mylistId = UserOwnedMylist.DefailtMylistId;
                Database.Temporary.MylistDb.AddItemId(
                    defMylist.Select(x => new Database.Temporary.MylistItemIdContainer()
                {
                    MylistGroupId = mylistId,
                    VideoId       = x.WatchId,
                    ItemId        = x.ItemId
                }));
            });

            return(mylist);
        }
Exemple #4
0
        public async Task <ContentManageResult> UpdateMylist(UserOwnedMylist mylist)
        {
            if (mylist.IsDeflist)
            {
                throw new Exception();
            }

            return(await ContextActionAsync(async context =>
            {
                return await context.User.UpdateMylistGroupAsync(
                    mylist.GroupId,
                    mylist.Label,
                    mylist.Description,
                    mylist.IsPublic,
                    mylist.Sort,
                    mylist.IconType
                    );
            }));
        }
        public async Task <ContentManageResult> MoveMylistTo(string sourceMylistGroupId, UserOwnedMylist targetGroupInfo, params string[] videoIdList)
        {
            var items = Database.Temporary.MylistDb.GetItemIdList(sourceMylistGroupId, videoIdList);

            return(await ContextActionAsync(async context =>
            {
                return await context.User.MoveMylistItemAsync(sourceMylistGroupId, targetGroupInfo.GroupId, NiconicoItemType.Video, items.Select(x => x.ItemId).ToArray());
            }));
        }
Exemple #6
0
        public MylistGroupListItem(UserOwnedMylist info)
        {
            GroupId = info.GroupId;

            Update(info);
        }