示例#1
0
文件: HitGuide.cs 项目: drdax/Radio
		private async Task SetDefaultBroadcast() {
			if (broadcast == null || broadcast.EndTime < DateTime.Now) {
				string html=await client.DownloadStringTaskAsync("http://www.hitfm.ua/");
				var match=Regex.Match(html, @"style=""margin-right: 12px;width: 120px;"">\s+<a class=""bold"" href=""(?'url'[^""]+)"">(?'caption'[^<]+)<\/a>\s+<div>(?'description'[^<]*)<\/div>\s+<div class=""bold"">(?'start'[012][0-9]:[0-5][0-9]) - (?'end'[012][0-9]:[0-5][0-9])");
				if (match.Success) {
					DateTime today=TimeZoneInfo.ConvertTime(DateTimeOffset.Now, timezone).Date;
					broadcast=new HitBroadcast(TimeZoneInfo.ConvertTime(today.Add(TimeSpan.Parse(match.Groups["start"].Value)), timezone, TimeZoneInfo.Local),
						TimeZoneInfo.ConvertTime(today.Add(TimeSpan.Parse(match.Groups["end"].Value)), timezone, TimeZoneInfo.Local),
						match.Groups["caption"].Value, match.Groups["description"].Value, match.Groups["url"].Value);
				} else {
					DateTime now=DateTime.Now;
					broadcast=new HitBroadcast(now.Date.AddHours(now.Hour), now.Date.AddHours(now.Hour+1), "Хiт FM", null, null);
				}
			}
		}
示例#2
0
        private async Task SetDefaultBroadcast()
        {
            if (broadcast == null || broadcast.EndTime < DateTime.Now)
            {
                string html = await client.DownloadStringTaskAsync("http://www.hitfm.ua/");

                var match = Regex.Match(html, @"style=""margin-right: 12px;width: 120px;"">\s+<a class=""bold"" href=""(?'url'[^""]+)"">(?'caption'[^<]+)<\/a>\s+<div>(?'description'[^<]*)<\/div>\s+<div class=""bold"">(?'start'[012][0-9]:[0-5][0-9]) - (?'end'[012][0-9]:[0-5][0-9])");
                if (match.Success)
                {
                    DateTime today = TimeZoneInfo.ConvertTime(DateTimeOffset.Now, timezone).Date;
                    broadcast = new HitBroadcast(TimeZoneInfo.ConvertTime(today.Add(TimeSpan.Parse(match.Groups["start"].Value)), timezone, TimeZoneInfo.Local),
                                                 TimeZoneInfo.ConvertTime(today.Add(TimeSpan.Parse(match.Groups["end"].Value)), timezone, TimeZoneInfo.Local),
                                                 match.Groups["caption"].Value, match.Groups["description"].Value, match.Groups["url"].Value);
                }
                else
                {
                    DateTime now = DateTime.Now;
                    broadcast = new HitBroadcast(now.Date.AddHours(now.Hour), now.Date.AddHours(now.Hour + 1), "Хiт FM", null, null);
                }
            }
        }