Exemple #1
0
 private void DownloadList(IList list)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
         if (list.Count == 0)
         {
             return;
         }
         var mediaType = (!ConvertMp3.IsChecked.HasValue) ? MediaType.Video : (ConvertMp3.IsChecked.Value) ? MediaType.Audio : MediaType.Video;
         Lists.Add(list, mediaType);
         MixpanelTrack("Download", new { Guid = _settings.ApplicationConfiguration.Guid });
     }));
 }
Exemple #2
0
        private void DownloadPage_Load(object sender, EventArgs e)
        {
            #region Read DB
            for (int i = 0; i < 20; i++)
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBName + i.ToString() + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.DBDownload();

                    break;
                }
            }

            Thread tagsDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBTags + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("tags");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBTags + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Tags.Add(sr.ReadLine());
                }
                sr.Close();
                if (!Global.SpeedLimit)
                {
                    listBox_TagAdd.Items.AddRange(SearchListBox.GetListBox(Global.Tags, String.Empty));
                    listBox_TagDelete.Items.AddRange(SearchListBox.GetListBox(Global.Tags, String.Empty));
                }
            }));
            Thread seriesDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBSeries + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("series");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBSeries + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Series.Add(sr.ReadLine());
                }
                sr.Close(); if (!Global.SpeedLimit)
                {
                    listBox_SeriesAdd.Items.AddRange(SearchListBox.GetListBox(Global.Series, String.Empty));
                }
            }));
            Thread characterDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBCharcter + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("characters");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBCharcter + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Character.Add(sr.ReadLine());
                }
                sr.Close();
                if (!Global.SpeedLimit)
                {
                    listBox_CharacterAdd.Items.AddRange(SearchListBox.GetListBox(Global.Character, String.Empty));
                    listBox_CharacterDelete.Items.AddRange(SearchListBox.GetListBox(Global.Character, String.Empty));
                }
            }));
            Thread artistsDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBArtist + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("artists");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBArtist + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Artist.Add(sr.ReadLine());
                }
                sr.Close();
                if (!Global.SpeedLimit)
                {
                    listBox_ArtistAdd.Items.AddRange(SearchListBox.GetListBox(Global.Artist, String.Empty));
                }
            }));

            tagsDB.Start();
            seriesDB.Start();
            characterDB.Start();
            artistsDB.Start();

            #endregion

            FileInfo fis = new FileInfo(Global.ReDownloadPath);
            if (!fis.Exists)
            {
                return;
            }

            BinaryFormatter binFmt = new BinaryFormatter();;
            using (FileStream rdr = new FileStream(Global.ReDownloadPath, FileMode.Open))
            {
                Global.HioDownGalleries = (DownloadGallerie)binFmt.Deserialize(rdr);
            }

            for (int i = 0; i < Global.HioDownGalleries.ID.Count; i++)
            {
                Thread th = new Thread(new ParameterizedThreadStart((data) => {
                    var g             = Global.HioDownGalleries.Galleries[(int)data];
                    HioDownloader hio = new HioDownloader(g);
                    hio.Downloads    += Pre_Download;

                    if (Global.HioDownGalleries.DownloadPage[(int)data] - 1 == -1)
                    {
                        hio.Download(Global.DownloadPath, 0);
                    }
                    else
                    {
                        hio.Download(Global.DownloadPath, Global.HioDownGalleries.DownloadPage[(int)data] - 1);
                    }
                }));
                th.Start(i);

                var gs = Global.HioDownGalleries.Galleries[i];
                DownloadLog_AddReverse(gs, Global.HioDownGalleries.DownloadPage[i] / Global.HioDownGalleries.TotalPage[i]);
                DownloadLists.Add(gs, Global.HioDownGalleries.DownloadPage[i] / Global.HioDownGalleries.TotalPage[i]);
            }
        }