Exemple #1
0
        /// <summary>
        /// 添加资源到迅雷
        /// </summary>
        /// <param name="src"></param>
        public static void AddTaskToThunder(MovieInfo info)
        {
            AgentClass agent = new AgentClass();

            agent.AddTask(info.Link, info.Title);
            agent.CommitTasks();
        }
Exemple #2
0
        public void Fire()
        {
            AgentClass agent;

            try
            {
                agent = new AgentClass();
            }
            catch (Exception e)
            {
                MessageBox.Show(Strings.Call_Thunder_Error_Agent + "\n" + e.Message + "\n" + e.StackTrace);
                return;
            }
            try
            {
                agent.AddTask3(bstrUrl: Url,
                               bstrFileName: FileName);
            }
            catch (Exception)
            {
                try
                {
                    agent.AddTask(bstrUrl: Url,
                                  bstrFileName: FileName);
                }
                catch (Exception e)
                {
                    MessageBox.Show(Strings.Call_Thunder_Error_Agent + "\n" + e.Message + "\n" + e.StackTrace);
                    return;
                }
            }
            try
            {
                agent.CommitTasks4(1, 0);
            }
            catch (Exception)
            {
                try { agent.CommitTasks(); }
                catch (Exception e)
                {
                    MessageBox.Show(Strings.Call_Thunder_Error_Agent + "\n" + e.Message + "\n" + e.StackTrace);
                    return;
                }
            }
        }
Exemple #3
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(_url);
            HttpWebResponse response    = null;
            Stream receiveStream        = null;
            try
            {
            #if DEBUG
                FileStream fs = new FileStream(@"./test.xml", FileMode.Open);
                receiveStream = fs;
            #else
                request.MaximumAutomaticRedirections = 4;
                request.MaximumResponseHeadersLength = 4;
                request.Credentials = CredentialCache.DefaultCredentials;
                response = (HttpWebResponse)request.GetResponse();
                receiveStream = response.GetResponseStream();
            #endif

                XmlDocument xml = new XmlDocument();
                XmlNodeList xmllist = null;
                xml.Load(receiveStream);
                xmllist = xml.SelectNodes("//channel/item");
                AgentClass ac = new AgentClass();
                foreach (XmlNode node in xmllist)
                {
                    string url = node.SelectSingleNode("link").InnerText;
                    string[] temp = url.Split('/');
                    string fileName = temp[temp.Length - 1].Replace("m4v", "mp4");
                    if (File.Exists(_savePath + fileName))
                        continue;
                    ac.AddTask(url, fileName, @"F:\ENGLISH\StudentNews\", string.Empty, string.Empty, 0, 0, 0);
                }
                ac.CommitTasks();

            }
            finally
            {
                if (response != null)
                    response.Close();
                if (receiveStream != null)
                    receiveStream.Close();
            }
        }