Пример #1
0
 public static Topic FromElement(XElement e)
 {
     return(new Topic
     {
         created_on = e.Attribute("created_on").Value,
         id = e.Attribute("id").Value,
         locked = e.Attribute("locked").Value == "1",
         name = e.Attribute("name").Value,
         sticky = e.Attribute("sticky").Value == "1",
         creator = Contact.FromElement(e.Element("creator"))
     });
 }
Пример #2
0
 public static File FromElement(XElement e)
 {
     return(new File
     {
         add_date = e.Attribute("add_date").Value,
         downloads = int.Parse(e.Attribute("downloads").Value),
         id = e.Attribute("id").Value,
         title = e.Attribute("title").Value,
         text = e.Element("text").Value,
         creator = Contact.FromElement(e.Element("creator"))
     });
 }
Пример #3
0
 public static Comment FromElement(XElement e)
 {
     return(new Comment
     {
         datecreate = e.Attribute("datecreate").Value,
         id = e.Attribute("id").Value,
         permalink = e.Attribute("permalink").Value,
         reply_to_comment_id = e.Attribute("reply_to_comment_id").Value,
         type = e.Attribute("type").Value,
         text = e.Element("text").Value,
         author = Contact.FromElement(e.Element("author"))
     });
 }
Пример #4
0
 public static Group FromElement(XElement e)
 {
     return(new Group
     {
         id = e.Attribute("id").Value,
         is_featured = e.Attribute("is_featured").Value == "1",
         name = e.Element("name").Value,
         description = e.Element("description") != null?e.Element("description").Value : "",
         created_on = e.Element("created_on").Value,
         modified_on = e.Element("modified_on").Value,
         total_videos = int.Parse(e.Element("total_videos").Value),
         total_members = int.Parse(e.Element("total_members").Value),
         total_threads = int.Parse(e.Element("total_threads").Value),
         total_files = int.Parse(e.Element("total_files").Value),
         total_events = int.Parse(e.Element("total_events").Value),
         url = e.Element("url").Value,
         //logo_url = e.Element("logo_url").Value,
         permissions = Permissions.FromElement(e.Element("permissions")),
         calendar_type = e.Element("calendar").Attribute("type").Value,
         creator = Contact.FromElement(e.Element("creator"))
     });
 }
Пример #5
0
 public static Channel FromElement(XElement e)
 {
     return(new Channel
     {
         id = e.Attribute("id").Value,
         is_featured = e.Attribute("is_featured").Value == "1",
         is_sponsored = e.Attribute("is_sponsored").Value == "1",
         name = e.Element("name").Value,
         description = e.Element("description").Value,
         created_on = e.Element("created_on").Value,
         modified_on = e.Element("modified_on").Value,
         total_videos = int.Parse(e.Element("total_videos").Value),
         total_subscribers = int.Parse(e.Element("total_subscribers").Value),
         logo_url = e.Element("logo_url").Value,
         badge_url = e.Element("badge_url").Value,
         url = e.Element("url").Value,
         layout = e.Element("layout").Value,
         theme = e.Element("theme").Value,
         privacy = e.Element("privacy").Value,
         //featured_description_short = e.Element("featured_description").Attribute("short").Value,
         //featured_description = e.Element("featured_description").Value,
         creator = Contact.FromElement(e.Element("creator"))
     });
 }
Пример #6
0
        public static Video FromElement(XElement e, bool full_response)
        {
            var v = new Video();

            if (full_response)
            {
                try
                {
                    v.embed_privacy = e.Attribute("embed_privacy").Value;
                    v.id            = e.Attribute("id").Value;
                    v.is_hd         = e.Attribute("is_hd").Value == "1";
                    //v.is_transcoding = e.Attribute("is_transcoding").Value;
                    //v.is_watchlater = e.Attribute("is_watchlater") == null ? false : e.Attribute("is_watchlater").Value == "1";
                    v.license = e.Attribute("license").Value;
                    v.privacy = e.Attribute("privacy").Value;

                    v.title         = e.Element("title").Value;
                    v.description   = e.Element("description").Value;
                    v.upload_date   = e.Element("upload_date").Value;
                    v.modified_date = e.Element("modified_date").Value;

                    //if (string.IsNullOrEmpty(e.Element("number_of_likes").Value))
                    // return v;

                    v.number_of_likes = int.Parse(e.Element("number_of_likes").Value);

                    /*if (!string.IsNullOrEmpty(e.Element("number_of_plays").Value))
                     * {
                     *  v.number_of_plays = int.Parse(e.Element("number_of_plays").Value);
                     * }
                     * else
                     * {
                     *  v.number_of_plays = 100;
                     * }*/
                    //v.number_of_comments = int.Parse(e.Element("number_of_comments").Value);
                    v.width    = int.Parse(e.Element("width").Value);
                    v.height   = int.Parse(e.Element("height").Value);
                    v.duration = int.Parse(e.Element("duration").Value);

                    v.owner = Contact.FromElement(e.Element("owner"));

                    /*v.cast = new List<CastMember>();
                     * foreach (var item in e.Element("cast").Elements("member"))
                     * {
                     *  v.cast.Add(CastMember.FromElement(item));
                     * }*/

                    v.urls = new List <Url>();
                    foreach (var item in e.Elements("urls").Elements("url"))
                    {
                        v.urls.Add(Url.FromElement(item));
                    }

                    v.thumbnails = GetThumbnails(e.Element("thumbnails"));

                    v.tags = new List <Tag>();
                    try
                    {
                        if (e.Element("tags") != null && e.Element("tags").Elements("tag") != null)
                        {
                            foreach (var item in e.Element("tags").Elements("tag"))
                            {
                                v.tags.Add(Tag.FromElement(item));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //Debug.WriteLine("snazy - " + ex);
                    }
                }
                catch (Exception ex)
                {
                }
                return(v);
            }

            v.embed_privacy = e.Attribute("embed_privacy").Value;
            v.id            = e.Attribute("id").Value;
            v.is_hd         = e.Attribute("is_hd").Value == "1";
            v.is_watchlater = e.Attribute("is_watchlater") != null && e.Attribute("is_watchlater").Value == "1";
            v.license       = e.Attribute("license").Value;
            v.modified_date = e.Attribute("modified_date").Value;
            v.owner         = new Contact()
            {
                id = e.Attribute("owner").Value
            };
            v.privacy     = e.Attribute("privacy").Value;
            v.title       = e.Attribute("title").Value;
            v.upload_date = e.Attribute("upload_date").Value;
            return(v);
        }
Пример #7
0
        public static Activity FromElement(XElement e)
        {
            var a = new Activity
            {
                id          = e.Attribute("id").Value,
                type        = e.Element("type").Value,
                time        = e.Element("time").Value,
                active_user = Contact.FromElement(e.Element("active_user")),
            };

            if (e.Element("video") != null)
            {
                a.video = new global::MediaBrowser.Plugins.Vimeo.VimeoAPI.API.Video
                {
                    id    = e.Element("video").Attribute("id").Value,
                    title = e.Element("video").Element("title").Value,
                    urls  = new List <global::MediaBrowser.Plugins.Vimeo.VimeoAPI.API.Video.Url>()
                    {
                        new global::MediaBrowser.Plugins.Vimeo.VimeoAPI.API.Video.Url {
                            type  = "video",
                            Value = e.Element("video").Element("url").Value
                        }
                    },
                    owner      = Contact.FromElement(e.Element("video").Element("owner")),
                    thumbnails = global::MediaBrowser.Plugins.Vimeo.VimeoAPI.API.Video.GetThumbnails(e.Element("video").Element("thumbnails"))
                };
            }
            if (e.Element("forum") != null)
            {
                a.forum = new Forum
                {
                    name         = e.Element("forum").Attribute("name").Value,
                    url          = e.Element("forum").Attribute("url").Value,
                    thread_id    = e.Element("forum").Element("thread").Attribute("id").Value,
                    thread_title = e.Element("forum").Element("thread").Element("title").Value,
                    thread_url   = e.Element("forum").Element("thread").Element("url").Value
                };
            }
            if (e.Element("comment") != null)
            {
                a.comment = Comment.FromElement(e.Element("comment"));
            }
            if (e.Element("group") != null)
            {
                a.group = new Group
                {
                    id          = e.Element("group").Attribute("id").Value,
                    name        = e.Element("group").Element("name").Value,
                    url         = e.Element("group").Element("url").Value,
                    description = e.Element("group").Element("image").Value
                };
            }
            if (e.Element("channel") != null)
            {
                a.channel = new Channel
                {
                    id       = e.Element("channel").Attribute("id").Value,
                    name     = e.Element("channel").Element("name").Value,
                    url      = e.Element("channel").Element("url").Value,
                    logo_url = e.Element("channel").Element("image").Value
                };
            }
            return(a);
        }