using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace youtubemp3convert
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool durum = false;
WebBrowser web = new WebBrowser();
private void button1_Click_1(object sender, EventArgs e)
{
web.Document.GetElementById("youtube-url").SetAttribute("value", textBox1.Text);
web.Document.GetElementById("submit").InvokeMember("click");
durum = true;
}
string dosyadi = "";
void Download(string link)
{
SaveFileDialog kaydet = new SaveFileDialog();
kaydet.Filter = "MP3 Dosyası (*.mp3) |*.mp3";
if (kaydet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
dosyadi = kaydet.FileName;
WebClient download = new WebClient();
download.DownloadFileAsync(new Uri(link),dosyadi);
download.DownloadProgressChanged += download_DownloadProgressChanged;
download.DownloadFileCompleted += download_DownloadFileCompleted;
}
}
void download_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
void download_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
Process.Start(dosyadi);
}
private void Form1_Load(object sender, EventArgs e)
{
web.ScriptErrorsSuppressed = true;
web.Navigate("http://www.youtube-mp3.org/tr");
web.DocumentCompleted += web_DocumentCompleted;
}
string link = "";
void web_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (durum)
{
HtmlElementCollection col = web.Document.GetElementsByTagName("a");
foreach (HtmlElement el in col)
{
if (el.InnerText == "Download")
{
link = el.GetAttribute("href");
Download(link);
}
}
durum = false;
}
}
}
}
BU KODDA BUTTON A BASINCA İKİ UCKERE NEREYE KAYDETCENİ SORUYO SUREKLİ Bİ KAC SORUSTAN SONRA KAYDEDİYOR NERDE HATA YAPİYORUM LUTFEN YARDIM