コード例 #1
0
 private void PuttPaaBilde(Clip clip, XmlNode xmlNode)
 {
     string kapitelletsBilde = xmlNode["imageurl"].InnerText;
     string klippetsBilde = doc.SelectSingleNode("//mediadefinition/mediaitems/mediaitem/imageurl").InnerText;
     if (kapitelletsBilde == String.Empty && klippetsBilde != String.Empty)
     {
         clip.Bilde = klippetsBilde;
     }
     else if (kapitelletsBilde != String.Empty)
     {
         clip.Bilde = kapitelletsBilde;
     }
 }
コード例 #2
0
 /// <summary>
 /// Method that puts the clip type and id on the given clip by looking at the url.
 /// </summary>
 /// <param name="c"></param>
 /// <param name="url"></param>
 public static void BestemKlippTypeOgPuttPaaId(Clip c, string url)
 {
     String tmpUrl = url.Substring(url.LastIndexOf("/") + 1);
        if (url.Contains("verdi"))
        {
        c.Type = Clip.KlippType.VERDI;
        }
        else if (url.Contains("klipp"))
        {
        c.Type = Clip.KlippType.KLIPP;
        }
        c.ID = tmpUrl;
 }
コード例 #3
0
 public List<Clip> GetChapters()
 {
     List<Clip> clips = new List<Clip>();
     String clipUrl = GetUrl();
     XmlNodeList nodeList = doc.SelectNodes("//mediadefinition/mediaitems/mediaitem/chapters/chapteritem");
     foreach (XmlNode xmlNode in nodeList)
     {
         Clip clip = new Clip(clipUrl, xmlNode["title"].InnerText);
         clip.StartTime = Double.Parse(xmlNode["timeindex"].InnerText);
         PuttPaaBilde(clip, xmlNode);
         clip.Type = Clip.KlippType.KLIPP_CHAPTER;
         clips.Add(clip);
     }
     return clips;
 }
コード例 #4
0
 /**
  * Metode som sjekker om clippet er en vignett. Vi vil ikke ha disse inn i lista.
  */
 public static bool isNotShortVignett(Clip loRssItem)
 {
     return
         loRssItem.ID != NrkParserConstants.VIGNETT_ID_NATURE && loRssItem.ID != NrkParserConstants.VIGNETT_ID_SUPER && loRssItem.ID != NrkParserConstants.VIGNETT_ID_NYHETER &&
         loRssItem.ID != NrkParserConstants.VIGNETT_ID_SPORT;
 }
コード例 #5
0
 public override List<String> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)
 {
     List<string> urls = new List<string>();
     if (video.VideoUrl.StartsWith("mms://"))
     {
         urls.Add(video.VideoUrl);
     }
     else
     {
         Clip item = video.Other as Clip;
         if (item == null && video.Other is string)
         {
             string[] infos = ((string)video.Other).Split('|');
             if (infos.Length == 2)
             {
                 item = new Clip(infos[0], "") { Type = (Clip.KlippType)Enum.Parse(typeof(Clip.KlippType), infos[1]) };
             }
         }
         if (item != null)
         {
             urls.Add(nrkParser.GetClipUrlAndPutStartTime(item));
             video.StartTime = TimeSpan.FromSeconds(item.StartTime).ToString();
         }
     }
     return urls;
 }
コード例 #6
0
 protected override void PutSummaryOnItem(Clip clip, XmlNode node)
 {
     clip.Description = node.InnerText;
 }
コード例 #7
0
        protected Clip CreateClipFromChildNode(XmlNode childNode)
        {
            Clip loRssItem = new Clip("", "");
            for (int i = 0; i < childNode.ChildNodes.Count; i++)
            {
                XmlNode n = childNode.ChildNodes[i];

                switch (n.Name)
                {
                    case "title":
                        loRssItem.Title = n.InnerText;
                        break;
                    case "link":
                        PutLinkOnItem(loRssItem, n);
                        break;
                    case "guid":
                        PutGuidOnItem(loRssItem, n);
                        break;
                    case "pubDate":
                        PutPublicationDateOnItem(loRssItem, n);
                        break;
                    case "description":
                        loRssItem.Description = n.InnerText;
                        break;
                    case "summary":
                        PutSummaryOnItem(loRssItem, n);
                        break;
                    case "author":

                        break;
                    case "exInfo:image":

                        break;
                    case "exInfo:gameID":

                        break;
                    case "feedburner:origLink":

                        break;
                    case "media:group":

                        for (int j = 0; j < n.ChildNodes.Count; j++)
                        {
                            XmlNode nin = n.ChildNodes[j];
                            switch (nin.Name)
                            {
                                case "media:content":
                                    //                                        loMediaContent = new MediaContent();
                                    try
                                    {
                                        //                                            loMediaContent.url = nin.Attributes["url"].Value;
                                        //                                            loMediaContent.type = nin.Attributes["type"].Value;
                                        //                                            loMediaContent.medium = nin.Attributes["medium"].Value;
                                        //                                            loMediaContent.duration = nin.Attributes["duration"].Value;
                                        //                                            loMediaContent.height = nin.Attributes["height"].Value;
                                        //                                            loMediaContent.width = nin.Attributes["width"].Value;
                                    }
                                    catch (Exception e)
                                    {
                                        //Log.Error("catccccccccccched exception: " + e.Message);
                                        Console.Error.WriteLine(e.StackTrace);
                                    }
                                    ;
                                    break;
                                case "media:description":

                                    break;
                                case "media:thumbnail":

                                    break;
                                case "media:title":

                                    break;
                            }
                        }
                        break;
                    case "itunes:duration":
                        PutDurationOnItem(loRssItem, n);
                        break;
                    case "media:description":
                        //                            loRssItem.mediaDescription = n.InnerText;
                        break;
                    case "media:thumbnail":
                        //                            loRssItem.mediaThumbnail = n.Attributes["url"].Value;
                        break;
                    case "media:title":
                        //                            loRssItem.mediaTitle = n.InnerText;
                        break;
                    case "enclosure":
                        PutEnclosureOnItem(loRssItem, n);
                        break;
                    case "media:category":
                        //  loRssItem.mediaCategory = n.InnerText;
                        break;
                    default:
                        break;
                }
            }
            return loRssItem;
        }
コード例 #8
0
 protected override void PutGuidOnItem(Clip loRssItem, XmlNode n)
 {
 }
コード例 #9
0
 protected override string GetPicture(Clip clip)
 {
     String bilde = NrkParserConstants.NRK_BETA_THUMBNAIL_URL;
     String videoFileName = clip.ID.Substring(clip.ID.LastIndexOf("/") + 1);
     return string.Format(bilde, videoFileName);
 }
コード例 #10
0
        public IList<Item> getAnbefalte()
        {
            String data = FetchUrl(MAIN_URL);
            IList<Item> clips = new List<Item>();
            String strQuery =
                "<div class=\"summary\"><a href=\".*?/nett-tv/(?<type>[^/]*)/(?<id>[^\"]*)\".*?><img src=\"(?<imgsrc>[^\"]*)\" alt=\".*?\" width=\"\\d+\" height=\"\\d+\" /></a><h3><a href=\"[^\"]+\" title=\".*?\">(?<title>[^<]*)</a></h3><p>(?<desc>[^<]*)</p></div>";
            Regex query =
                new Regex(strQuery);
            MatchCollection matches = query.Matches(data);
            foreach (Match x in matches)
            {
                String id = x.Groups["id"].Value;
                id = id.Replace('/', ' ').Trim();
                Clip c = new Clip(id, x.Groups["title"].Value);
                c.Description = x.Groups["desc"].Value;
                c.Bilde = x.Groups["imgsrc"].Value;
                if ("klipp".Equals(x.Groups["type"].Value))
                {
                    c.Type = Clip.KlippType.KLIPP;
                }
                else
                {
                    c.Type = Clip.KlippType.INDEX;
                }
                clips.Add(c);
            }

            return clips;
        }
コード例 #11
0
 public IList<Item> GetClipsTilhoerendeSammeProgram(Clip c)
 {
     //return GetClips(c.TilhoerendeProsjekt);
     List<Item> tItems = (List<Item>)GetClips(c.TilhoerendeProsjekt);
     tItems.AddRange(GetFolders(c.TilhoerendeProsjekt));
     return tItems;
 }
コード例 #12
0
        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;
        }
コード例 #13
0
        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;
        }
コード例 #14
0
 public IList<Item> GetFolders(Clip cl)
 {
     return GetFolders(cl.TilhoerendeProsjekt);
 }
コード例 #15
0
        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;
        }
コード例 #16
0
        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;
                }
            }
        }
コード例 #17
0
 private static Clip CreateClip(string id, string title, Match x)
 {
     Clip c = new Clip(id, title);
     c.Description = x.Groups[4].Value;
     return c;
 }
コード例 #18
0
 protected override void PutDurationOnItem(Clip item, XmlNode n)
 {
     item.Duration = n.InnerText;
 }
コード例 #19
0
 private static string GetClipUrlForRSS(Clip clip)
 {
     Log.Debug(NrkParserConstants.LIBRARY_NAME + ": Clip type is RSS");
     return NrkParserConstants.RSS_CLIPURL_PREFIX + clip.ID;
 }
コード例 #20
0
 public IList<Clip> getChapters(Clip item)
 {
     XmlKlippParser xmlKlippParser = new XmlKlippParser(string.Format(NrkParserConstants.URL_GET_MEDIAXML, item.ID, Speed));
     return xmlKlippParser.GetChapters();
 }
コード例 #21
0
 protected override string GetPicture(Clip clip)
 {
     return getPodkastPicture();
 }
コード例 #22
0
        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;
        }
コード例 #23
0
 protected override void PutEnclosureOnItem(Clip item, XmlNode n)
 {
     string tmpId = n.Attributes["url"].Value;
     item.ID = tmpId.Substring(0, tmpId.LastIndexOf("?"));
     item.MediaType = n.Attributes["type"].Value;
 }
コード例 #24
0
 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;
 }
コード例 #25
0
 protected override void PutPublicationDateOnItem(Clip item, XmlNode n)
 {
     item.Klokkeslett = DateTime.Parse(n.InnerText).ToString("f");
 }
コード例 #26
0
        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;
        }
コード例 #27
0
 protected override void PutLinkOnItem(Clip clip, XmlNode node)
 {
     clip.ID = node.Attributes["href"].Value;
 }
コード例 #28
0
        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;
        }
コード例 #29
0
        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=\"(.*?)&amp;app=nett-tv\"", RegexOptions.IgnoreCase);
            MatchCollection result = query.Matches(data);
            string urlToFetch = result[0].Groups[1].Value;
            return urlToFetch;
        }
コード例 #30
0
 protected virtual void PutSummaryOnItem(Clip clip, XmlNode node)
 {
 }