//Parse private void ParseRSS() { try { XmlDocument rssXmlDoc = new XmlDocument(); // Load the RSS file from the RSS URL rssXmlDoc.Load(URL); //Store initial values - title and link XmlNode TL = rssXmlDoc.SelectSingleNode("rss/channel"); this.Title = TL.SelectSingleNode("title").InnerText.Trim(); this.Link = TL.SelectSingleNode("link").InnerText.Trim(); this.Language = TL.SelectSingleNode("language").InnerText.Trim(); this.PublishedDate = TL.SelectSingleNode("pubDate").InnerText.Trim(); this.LastBuildDate = TL.SelectSingleNode("lastBuildDate").InnerText.Trim(); // Parse the Items in the RSS file XmlNodeList rssNodes = rssXmlDoc.SelectNodes("rss/channel/item"); foreach (XmlNode rssNode in rssNodes) { //Title XmlNode rssSubNode = rssNode.SelectSingleNode("title"); string title = rssSubNode != null ? rssSubNode.InnerText : ""; //Link/Url rssSubNode = rssNode.SelectSingleNode("link"); string link = rssSubNode != null ? rssSubNode.InnerText : ""; link = ParseLink(link); Titles.Add(title); URLs.Add(link); TitlesURLs.Add(title + " - " + link); } } catch (Exception e) { throw e; } }
public void URLLoad() { string text; string[] items; string[] splits = new string[1]; splits[0] = OVERHEAD; try { foreach (var txtFile in urlDirectoryInfo.GetFiles()) { text = File.ReadAllText(URL_FILE_PATH + txtFile); items = text.Split(splits, StringSplitOptions.RemoveEmptyEntries); URLData url = new URLData { BookMark = Convert.ToBoolean(items[0]), Vpn = Convert.ToBoolean(items[1]), Title = items[2], Url = items[3], CategoryName = items[4], SelectThis = false, }; URLs.Add(url); } } catch (Exception ex) { Debug.WriteLine(ex + DateTime.Now.ToLongTimeString()); } }
/// <summary> /// Invoked when the URL has been parsed by the MediaManager. /// </summary> /// <param name="track">The track representing the audio at the URL</param> private void URL_Parsed(TrackData track) { URLs.Clear(); URLs.Add(track); Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { ToggleProgressbar(false); })); if (callCallback && callback != null) { callback(URLs); } }
/// <summary> /// Load Urls in AdvanScene xml /// </summary> /// <param name="xnd">Xml Node</param> private void LoadURL(XmlNode xnd) { foreach (XmlNode xndd in xnd.ChildNodes) { URLs.Add(xndd.Name, xndd.InnerText); if (xndd.Name == "datURL") { foreach (XmlAttribute xat in xndd.Attributes) { URLs.Add("datFileName", xat.InnerText); } } } }
private void UrlAdd() { URLData urlData = new URLData { Title = this.Title, Url = this.Url, Vpn = this.Vpn, CategoryName = Category, BookMark = false, SelectThis = false, }; URLs.Add(urlData); UrlSave(urlData); URLValueClear(); }
/// <summary> /// Invoked after a short delay after the user has changed the URL text. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event data</param> private void inputDelay_Tick(object sender, EventArgs e) { inputDelay.Stop(); ToggleProgressbar(true); string url = URL.Text; if (PlaylistManager.IsSupported(url)) { ThreadStart ParseThread = delegate() { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Stream str = resp.GetResponseStream(); Encoding enc = Encoding.GetEncoding("utf-8"); StreamReader read = new StreamReader(str, enc); URLs.Clear(); foreach (TrackData track in PlaylistManager.ParsePlaylist(read, PlaylistManager.GetType(url))) { track.Icon = "pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/Radio.ico"; URLs.Add(track); } resp.Close(); read.Close(); ToggleProgressbar(false); if (callCallback && callback != null) { callback(URLs); } }; Thread parse_thread = new Thread(ParseThread); parse_thread.Name = "URL Parser"; parse_thread.IsBackground = true; parse_thread.Priority = ThreadPriority.Lowest; parse_thread.Start(); } else { MediaManager.ParseURLAsync(URL.Text, URL_Parsed, true); } }
public async Task CharacterListFromArmoryAsync(Progress <Tuple <int, string> > progres) { DateTime start = DateTime.Now; this.characterNames = new SortedSet <string>(); Downloader <String> d = new Downloader <string>(this._concurrency, Parser.CharacterNameListParserString, AddCharacterNamesToList); List <string> URLs; int safeGuard = DEF_SAVEGUARD; int URLCount = 0; Program.WriteLineToConsole("Make of Character names list STARTED!"); URLs = InitNameListURLs(URLBASE1, URLCHARSUFFIX); while (URLs.Count > 0 && safeGuard-- > 0) { URLCount += URLs.Count; Task <List <Tuple <string, bool> > > nameListTask = d.StartDownloadAsync(progres, URLs); await nameListTask; Program.WriteLineToConsole(String.Format("\nPass {0} done!", (DEF_SAVEGUARD - safeGuard).ToString())); URLs.Clear(); foreach (Tuple <string, bool> res in nameListTask.Result) { if (!res.Item2) { URLs.AddRange(ExpandNameListURL(res.Item1, URLCHARSUFFIX)); } } URLs = URLs.Distinct().ToList(); } Program.WriteLineToConsole(String.Format("Character name list DONE! elapsed time: {0}", DateTime.Now.Subtract(start).ToString())); Downloader <Character> dc = new Downloader <Character>(this._concurrency, Parser.CharacterApKillsParser, DBAccess.SaveCharacterNameList); int charsPerReq = 10; start = DateTime.Now; URLs.Clear(); Program.WriteLineToConsole("Update of Character APs and Kills STARTED!"); List <string> names = characterNames.ToList(); for (int i = 0; i < names.Count; i += charsPerReq) { if ((names.Count - i) < charsPerReq) { URLs.Add(CreateCharacterAchievURLwoC(names.GetRange(i, names.Count - i))); } else { URLs.Add(CreateCharacterAchievURLwoC(names.GetRange(i, charsPerReq))); } } Task <List <Tuple <string, bool> > > task = d.StartDownloadAsync(progres, URLs); await task; Program.WriteLineToConsole(String.Format("Update of Character APs and Kills DONE! elapsed time: {0}", DateTime.Now.Subtract(start).ToString())); }
/// <summary> /// adds a url to the quarantined list /// </summary> /// <param name="url"></param> public void addQuarantineURL(string url) { URLs.Add(url); }