Beispiel #1
0
        public VodList(DownloadForm parent)
        {
            InitializeComponent();
            DownloadWindow       = parent;
            comboBoxService.Text = "Twitch (Recordings)";
            objectListViewVideos.SecondarySortColumn = objectListViewVideos.GetColumn("Video ID");
            objectListViewVideos.SecondarySortOrder  = SortOrder.Ascending;

            comboBoxKnownUsers.Items.Add(" == No Preset == ");
            comboBoxKnownUsers.Items.AddRange(UserInfoPersister.GetKnownUsers().ToArray());
            comboBoxKnownUsers.SelectedIndex = 0;

            buttonClear.Enabled          = false;
            checkBoxAutoDownload.Enabled = false;

            if (!Util.ShowDownloadFetched)
            {
                buttonDownloadFetched.Enabled = false;
                buttonDownloadFetched.Hide();
                buttonDownloadAllKnown.Enabled = false;
                buttonDownloadAllKnown.Hide();
                checkBoxAutoDownload.Hide();
            }
            if (!Util.ShowAnySpecialButton)
            {
                objectListViewVideos.Size = new Size(objectListViewVideos.Size.Width, objectListViewVideos.Size.Height + 29);
            }
        }
        private async Task Run()
        {
            while (true)
            {
                try {
                    await Task.Delay(3000, CancelToken);
                } catch (Exception) { }

                if (CancelToken.IsCancellationRequested)
                {
                    return;
                }

                try {
                    IUserInfo earliestUserInfo = null;
                    lock (ContainerLock) {
                        foreach (IUserInfo u in UserInfos)
                        {
                            if (u.AutoDownload && (earliestUserInfo == null || u.LastRefreshedOn < earliestUserInfo.LastRefreshedOn))
                            {
                                earliestUserInfo = u;
                            }
                        }
                    }

                    if (earliestUserInfo != null)
                    {
                        DateTime earliestStartTime = earliestUserInfo.LastRefreshedOn.AddHours(7.0);
                        DateTime now = DateTime.UtcNow;
                        if (earliestStartTime <= now)
                        {
                            try {
                                await DoFetch(RNG, earliestUserInfo, Form, CancelToken);
                            } finally {
                                if (!CancelToken.IsCancellationRequested)
                                {
                                    earliestUserInfo.LastRefreshedOn = now;
                                    if (earliestUserInfo.Persistable)
                                    {
                                        UserInfoPersister.AddOrUpdate(earliestUserInfo);
                                        UserInfoPersister.Save();
                                    }
                                }
                            }
                        }
                    }
                } catch (Exception ex) {
                    Form.AddStatusMessage("Error during fetch: " + ex.ToString());
                }
            }
        }
Beispiel #3
0
        private void checkBoxAutoDownload_CheckedChanged(object sender, EventArgs e)
        {
            IUserInfo u = comboBoxKnownUsers.SelectedItem as IUserInfo;

            if (u != null)
            {
                if (u.AutoDownload != checkBoxAutoDownload.Checked)
                {
                    u.AutoDownload = checkBoxAutoDownload.Checked;
                    if (u.Persistable)
                    {
                        UserInfoPersister.AddOrUpdate(u);
                        UserInfoPersister.Save();
                    }
                }
            }
        }
Beispiel #4
0
        private static async Task <FetchReturnValue> Fetch(IUserInfo userInfo, int offset, bool flat)
        {
            FetchReturnValue frv = await userInfo.Fetch(offset, flat);

            userInfo.LastRefreshedOn = DateTime.UtcNow;

            if (!frv.Success)
            {
                return(frv);
            }

            if (userInfo.Persistable)
            {
                UserInfoPersister.AddOrUpdate(userInfo);
                UserInfoPersister.Save();
            }

            return(frv);
        }
Beispiel #5
0
        private void StartTimedAutoFetch()
        {
            if (Util.AllowTimedAutoFetch)
            {
                FetchTaskGroups = new Dictionary <ServiceVideoCategoryType, FetchTaskGroup>();
                foreach (List <ServiceVideoCategoryType> types in ServiceVideoCategoryGroups.Groups)
                {
                    FetchTaskGroup ftg = new FetchTaskGroup(this, CancellationTokenSource.Token);
                    foreach (ServiceVideoCategoryType svc in types)
                    {
                        FetchTaskGroups.Add(svc, ftg);
                        foreach (IUserInfo ui in UserInfoPersister.GetKnownUsers())
                        {
                            if (ui.AutoDownload && ui.Type == svc)
                            {
                                ftg.Add(ui);
                            }
                        }
                    }
                }

                StatusMessageTask = StatusMessageThreadFunc(CancellationTokenSource.Token);
            }
        }