public IList <Item> GetDirektePage() { String tab = "direkte"; Log.Info(NrkParserConstants.LIBRARY_NAME + ": GetDirektePage(String)", tab); string data; data = FetchUrl(MAIN_URL + tab + "/"); Regex query = new Regex( "<li><div><a href=\"/nett-tv/direkte/(.*?)\" title=\"(.*?)\"><img src=\"(.*?)\" .*?/></a><h3><a href=\".*?\" title=\".*?\">.*?</a></h3></div></li>", RegexOptions.Singleline); MatchCollection matches = query.Matches(data); List <Item> clips = new List <Item>(); Log.Info(NrkParserConstants.LIBRARY_NAME + ": Matches {0}", matches.Count); foreach (Match x in matches) { Clip c = new Clip(x.Groups[1].Value, x.Groups[2].Value); String bildeUrl = x.Groups[3].Value; c.Bilde = bildeUrl; c.Type = Clip.KlippType.DIREKTE; c.VerdiLink = tab; clips.Add(c); } return(clips); }
public IList <Item> GetSistePaaForsiden() { Log.Info(NrkParserConstants.LIBRARY_NAME + ": GetSistePaaForsiden()"); string data; data = FetchUrl(MAIN_URL); Regex query = new Regex( "<a href=\"/nett-tv/klipp/(?<id>[^\"]*)\" title=\"[^\"]*\"><img src=\"(?<imgsrc>[^\"]*)\" alt=\".*?\" width=\"\\d+\" height=\"\\d+\" /></a><h3><a href=\".*?\" title=\"(?<desc>[^\"]*)\">(?<title>[^<]*)</a></h3>", RegexOptions.Compiled | RegexOptions.Singleline); MatchCollection matches = query.Matches(data); List <Item> clips = new List <Item>(); Log.Info(NrkParserConstants.LIBRARY_NAME + ": Matches {0}", matches.Count); foreach (Match x in matches) { Clip c = new Clip(x.Groups["id"].Value, x.Groups["title"].Value); //c.TilhoerendeProsjekt = Int32.Parse(x.Groups["prosjekt"].Value); c.Description = x.Groups["desc"].Value; c.Bilde = x.Groups["imgsrc"].Value; clips.Add(c); } return(clips); }
private string GetClipUrlForIndex(Clip clip) { Regex query; Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Clip type is INDEX"); string data = FetchUrl(INDEX_URL + clip.ID); query = new Regex("<param name=\"FileName\" value=\"(.*?)\" />", RegexOptions.IgnoreCase); MatchCollection result = query.Matches(data); string urlToFetch = result[0].Groups[1].Value; urlToFetch = urlToFetch.Replace("amp;", ""); //noen ganger er det amper der..som må bort string urldata = FetchUrl(urlToFetch); Log.Debug(NrkParserConstants.LIBRARY_NAME + ": " + urldata); query = new Regex("<starttime value=\"(.*?)\" />.*?<ref href=\"(.*?)\" />", RegexOptions.Singleline); MatchCollection movie_url = query.Matches(urldata); //skip any advertisement string str_startTime = movie_url[0].Groups[1].Value; Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Starttime er: " + str_startTime); //må gjøre string representasjon på formen: 00:27:38, om til en double Double dStartTime = NrkUtils.convertToDouble(str_startTime); clip.StartTime = dStartTime; return(movie_url[0].Groups[2].Value); }
public IList <Item> GetMestSette(int dager) { Log.Info(string.Format("{0}: GetMestSette(), siste {1} dager", NrkParserConstants.LIBRARY_NAME, dager)); string data; String url = String.Format(MEST_SETTE_URL, dager); data = FetchUrl(url); Regex query = new Regex( "<li.*?><div><a href=\".*?/nett-tv/.*?/.*?\" title=\".*?\"><img src=\"(?<imgsrc>[^\"]*)\"[^/]*/></a><h3><a href=\".*?/nett-tv/(?<type>[^/]*)/(?<id>[^\"]*)\" title=\".*?\">(?<title>[^<]*)</a></h3><div class=\"summary\"><p>Vist (?<antallvist>[^ganger]*) ganger.</p></div></div></li>", RegexOptions.Singleline); MatchCollection matches = query.Matches(data); List <Item> clips = new List <Item>(); Log.Info(NrkParserConstants.LIBRARY_NAME + ": Matches {0}", matches.Count); foreach (Match x in matches) { Clip c = new Clip(x.Groups["id"].Value, x.Groups["title"].Value); c.AntallGangerVist = x.Groups["antallvist"].Value; c.Description = c.AntallGangerVist; c.Bilde = x.Groups["imgsrc"].Value; if (x.Groups["type"].Value.Trim().ToLower().Equals("indeks")) { c.Type = Clip.KlippType.INDEX; } clips.Add(c); } return(clips); }
private string GetClipUrlForVerdi(Clip clip) { Log.Info(NrkParserConstants.LIBRARY_NAME + ": Fetching verdi url"); string data = FetchUrl(STORY_URL + clip.ID); Regex query = new Regex("<media:content url=\"(.*?)&app=nett-tv\"", RegexOptions.IgnoreCase); MatchCollection result = query.Matches(data); string urlToFetch = result[0].Groups[1].Value; return(urlToFetch); }
private string GetClipUrlAndPutStartTimeForKlipp(Clip clip) { Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Clip type is: " + clip.Type); Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Parsing xml: " + string.Format(NrkParserConstants.URL_GET_MEDIAXML, clip.ID, Speed)); XmlKlippParser xmlKlippParser = new XmlKlippParser(string.Format(NrkParserConstants.URL_GET_MEDIAXML, clip.ID, Speed)); string url = xmlKlippParser.GetUrl(); clip.StartTime = xmlKlippParser.GetStartTimeOfClip(); if (urlIsQTicketEnabled(url)) { url = getDirectLinkWithTicket(url); } return(url); }
private string GetClipUrlForDirekte(Clip clip) { Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Clip type is: " + clip.Type.ToString()); string data = FetchUrl(DIREKTE_URL + clip.ID); Regex query; query = new Regex("<param name=\"FileName\" value=\"(.*?)\" />", RegexOptions.IgnoreCase); MatchCollection result = query.Matches(data); string urlToFetch; try { urlToFetch = result[0].Groups[1].Value; } catch (Exception e) { Log.Info("feilet: " + e.Message); return(null); } string urldata = FetchUrl(urlToFetch); Log.Debug(NrkParserConstants.LIBRARY_NAME + ": " + urldata); query = new Regex("<ref href=\"(.*?)\" />"); MatchCollection movie_url = query.Matches(urldata); //Usikker på en del av logikken for å hente ut url her. Ikke sikker på hvorfor //det var en try/catch //skip any advertisement String urlToReturn; try { urlToReturn = movie_url[1].Groups[1].Value; if (urlToReturn.ToLower().EndsWith(".gif")) { Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Kan ikke spille av: " + urlToReturn + ", prøver annet treff."); //vi kan ikke spille av fullt.gif, returnerer samme som i catch'en. urlToReturn = movie_url[0].Groups[1].Value; } } catch { urlToReturn = movie_url[0].Groups[1].Value; } if (urlIsQTicketEnabled(urlToReturn)) { urlToReturn = getDirectLinkWithTicket(urlToReturn); } return(urlToReturn); }
private IList <Item> GetClips(int id) { Log.Info("{0}: GetClips(int): {1}", NrkParserConstants.LIBRARY_NAME, id); string data = FetchUrl(PROGRAM_URL + id); List <Item> clips = new List <Item>(); Regex query = new Regex("<a href=\"/nett-tv/klipp/(.*?)\"\\s+title=\"(.*?)\"\\s+class=\"(.*?)\".*?>(.*?)</a>"); MatchCollection matches = query.Matches(data); foreach (Match x in matches) { Clip c = new Clip(x.Groups[1].Value, x.Groups[4].Value); c.TilhoerendeProsjekt = id; clips.Add(c); } return(clips); }
public string GetClipUrlAndPutStartTime(Clip clip) { Log.Debug("{0}: GetClipUrlAndPutStartTime(Clip): {1}", NrkParserConstants.LIBRARY_NAME, clip.ToString()); if (clip.Type == Clip.KlippType.KLIPP) { return(GetClipUrlAndPutStartTimeForKlipp(clip)); } else if (clip.Type == Clip.KlippType.KLIPP_CHAPTER) { return(clip.ID); } else if (clip.Type == Clip.KlippType.DIREKTE) { return(GetClipUrlForDirekte(clip)); } else if (clip.Type == Clip.KlippType.RSS) { return(GetClipUrlForRSS(clip)); } else if (clip.Type == Clip.KlippType.INDEX) { return(GetClipUrlForIndex(clip)); } else if (clip.Type == Clip.KlippType.NRKBETA || clip.Type == Clip.KlippType.PODCAST) { return(clip.ID); } else { try { return(GetClipUrlForVerdi(clip)); } catch (Exception e) { Log.Error("Kunne ikke finne url til klipp", e); return(null); } } }
private static string GetClipUrlForRSS(Clip clip) { Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Clip type is RSS"); return(NrkParserConstants.RSS_CLIPURL_PREFIX + clip.ID); }
public IList <Item> GetClips(Program program) { Log.Info("{0}: GetClips(Program): {1}", NrkParserConstants.LIBRARY_NAME, program.ToString()); return(GetClips(Int32.Parse(program.ID))); }