Beispiel #1
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            List<DataGridViewRow> selectedRows = grdBroadcast.SelectedRows.Cast<DataGridViewRow>().ToList();
            if (!selectedRows.Any()) return;
            var selectedBroadcasts = selectedRows.Select(r => new Broadcast
            {
                username = r.Cells[0].Value.ToString(),
                id = r.Cells[1].Value.ToString()
            }).ToList();

            PDownload pDownload = new PDownload
            {
                User = selectedBroadcasts.First().username,
                SelectedBroadcasts = selectedBroadcasts.Select(b => b.id).ToList()
            };
            using (VideoDownloader videoDownloader = new VideoDownloader())
            {
                videoDownloader.DownloadAllVideos(pDownload);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            if(args.Length < 1) return;
            string user = args[0];
            string broadcast = "";
            List<int> selectedVideos = new List<int>();
            bool downloadReplayOnly = false;
            bool isReverseOrder = false;

            var p = new OptionSet
            {
                {"b|broadcast=", "the name of broadcast.", v => broadcast = v},
                {"ds|downloadselected=", "only selected videos downloaded, seperate with comma (e.g. 1,2,7), start index is 0", v => selectedVideos = v.Split(',').Select(int.Parse).ToList()},
                {"ro|replayonly", "download only replay videos", v => downloadReplayOnly = v != null},
                {"r|reverse", "download reverse order", v => isReverseOrder = v != null}
            };

            p.Parse(args);
            if(string.IsNullOrEmpty(user)) return;
            bool downloadSingle = !string.IsNullOrEmpty(broadcast);
            bool downloadSelectedVideos = selectedVideos.Any();
            if(downloadSelectedVideos && downloadSingle) return;

            PDownload pDownload = new PDownload
            {
                User = user,
                Broadcast = broadcast,
                SelectedVideos = selectedVideos,
                DownloadLiveStream = !downloadReplayOnly,
                IsReverseOrder = isReverseOrder
            };
            using (VideoDownloader videoDownloader = new VideoDownloader())
            {
                if (downloadSingle)
                    videoDownloader.DownloadVideos(pDownload);
                else
                    videoDownloader.DownloadAllVideos(pDownload);
            }
        }