コード例 #1
0
        public static void DownloadVideo(string url, string username)
        {
            string filename = BrowserUtils.GetFileNameFromUrl(url);
            string ext      = Path.GetExtension(filename);

            using (SaveFileDialog dialog = new SaveFileDialog {
                AutoUpgradeEnabled = true,
                OverwritePrompt = true,
                Title = "Save Video",
                FileName = string.IsNullOrEmpty(username) ? filename : $"{username} {filename}".TrimStart(),
                Filter = "Video" + (string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
            }){
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    DownloadFileAuth(url, dialog.FileName, null, ex => {
                        FormMessage.Error("Video Download", "An error occurred while downloading the video: " + ex.Message, FormMessage.OK);
                    });
                }
            }
        }
コード例 #2
0
 public static string GetImageFileName(string url)
 {
     return(BrowserUtils.GetFileNameFromUrl(ExtractMediaBaseLink(url)));
 }