Example #1
0
 public MainWindow()
 {
     InitializeComponent();
     _settings     = Settings.Instance;
     _cacheManager = CacheManager.Instance;
     Title         = "MS.Video.Downloader ver. " + _settings.Version;
     Lists         = new DownloadLists(OnDownloadStatusChange);
     Loading(false);
 }
Example #2
0
 public MainWindow()
 {
     InitializeComponent();
     _settings = Settings.Instance;
     _cacheManager = CacheManager.Instance;
     Title = "MS.Video.Downloader ver. " + _settings.Version;
     Lists = new DownloadLists(OnDownloadStatusChange);
     Loading(false);
 }
 public void SaveDownloadLists(DownloadLists lists)
 {
     try {
         var listsEntry = new DownloadEntry {
             Title           = lists.Title,
             ThumbnailUrl    = lists.ThumbnailUrl,
             ExecutionStatus = lists.ExecutionStatus
         };
         foreach (DownloadList list in lists.Entries)
         {
             if (list.DownloadState == DownloadState.AllFinished || list.Entries.Count <= 0)
             {
                 continue;
             }
             var entry = new DownloadEntry {
                 Title           = list.Title,
                 ThumbnailUrl    = list.ThumbnailUrl,
                 MediaType       = list.MediaType,
                 ExecutionStatus = list.ExecutionStatus,
                 Url             = ""
             };
             var firstEntry = list.Entries[0] as YoutubeEntry;
             if (firstEntry == null)
             {
                 continue;
             }
             if (firstEntry.Parent != null)
             {
                 entry.Url   = String.Format("{0}", firstEntry.Parent.Uri);
                 entry.Title = firstEntry.Parent.Title;
             }
             foreach (YoutubeEntry youtubeEntry in list.Entries)
             {
                 entry.List.Add(new DownloadEntry {
                     Title           = youtubeEntry.Title,
                     Url             = youtubeEntry.Uri.ToString(),
                     MediaType       = youtubeEntry.MediaType,
                     ThumbnailUrl    = youtubeEntry.ThumbnailUrl,
                     ExecutionStatus = youtubeEntry.ExecutionStatus
                 });
             }
             listsEntry.List.Add(entry);
         }
         SetDownloadLists(listsEntry);
     }
     catch {}
 }
 public bool FillDownloadLists(DownloadLists lists)
 {
     try {
         lists.Entries.Clear();
         var listsEntry = GetDownloadLists() ?? new DownloadEntry();
         if (listsEntry.List != null && listsEntry.List.Count > 0)
         {
             foreach (var itemList in listsEntry.List)
             {
                 var youtubeEntries = new List <YoutubeEntry>();
                 var mediaType      = itemList.MediaType;
                 Uri uri;
                 var youtubeListEntry =
                     YoutubeEntry.Create(Uri.TryCreate(itemList.Url, UriKind.Absolute, out uri) ? uri : null);
                 youtubeListEntry.Title = itemList.Title;
                 SetExecutionStatus(youtubeListEntry, itemList);
                 youtubeListEntry.ThumbnailUrl = itemList.ThumbnailUrl;
                 foreach (var item in itemList.List)
                 {
                     var youtubeEntry = YoutubeEntry.Create(new Uri(item.Url), youtubeListEntry);
                     youtubeEntry.ThumbnailUrl = item.ThumbnailUrl;
                     youtubeEntry.Title        = item.Title;
                     SetExecutionStatus(youtubeEntry, item);
                     youtubeEntries.Add(youtubeEntry);
                 }
                 if (youtubeEntries.Count > 0)
                 {
                     lists.SoftAdd(youtubeEntries, mediaType);
                 }
             }
         }
         return(true);
     }
     catch {
         return(false);
     }
 }
Example #5
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]);
            }
        }