예제 #1
0
        private void addMediaItemRow(string title, string type, string url, string opts, string filePath)
        {
            var li = new ListViewItem(new string[] { title, "Waiting", type, "-", "", "0%", "0.0 KB/s", url, filePath });

            li.Tag = Common.RandomString(5) + DateTime.UtcNow.Ticks;
            listItems.Items.Add(li);

            Process          p   = YouTubeDL.run(opts);
            ProcessUpdateRow pur = new ProcessUpdateRow();

            pur.proc    = p;
            pur.item    = listItems.Items[listItems.Items.Count - 1];
            pur.results = new List <string>
            {
                "" // intentional
            };

            dict.Add(li.Tag.ToString(), pur);

            int index = 0; // video

            if (type == "audio")
            {
                index = 1;
            }
            pur.item.ImageIndex = index;
        }
예제 #2
0
        private void addMediaItemRow(string title, string type, string url, string opts, string filePath)
        {
            var li = new ListViewItem(new string[] { title, "Waiting", type, "-", "", "0%", "0.0 KB/s", url, filePath });

            li.Tag = DateTime.Now.ToString("yyyyMMddhmmsstt");
            listItems.Items.Add(li);

            Process          p   = YouTubeDL.run(opts);
            ProcessUpdateRow pur = new ProcessUpdateRow();

            pur.proc    = p;
            pur.item    = listItems.Items[listItems.Items.Count - 1];
            pur.results = new List <string>
            {
                "" // intentional
            };

            Task.Run(() =>
            {
                // spawns a new thread to read standard out data
                while (pur.proc != null && !pur.proc.HasExited)
                {
                    pur.results.Add(pur.proc.StandardOutput.ReadLine());
                }
            });

            Task.Run(() =>
            {
                // spawns a new thread to read error stream data
                while (pur.proc != null && !pur.proc.HasExited)
                {
                    string line = pur.proc.StandardError.ReadLine();
                    if (!String.IsNullOrEmpty(line))
                    {
                        pur.results.Add(line);
                    }
                }
            });

            dict.Add(li.Tag.ToString(), pur);

            int index = 0; // video

            if (type == "audio")
            {
                index = 1;
            }
            pur.item.ImageIndex = index;
        }