File size: 3,155 Bytes
e26fba6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace MovieTube.Web.Models
{
    public class ThumbNailVm
    {
        public ThumbNailVm()
        {
            Thumbnails = new List<MovieThumbnailVm>();
        }
        public List<MovieThumbnailVm> Thumbnails { get; set; }
        public int NextPage { get; set; }
    }

    public class MovieThumbnailVm
    {
        public string Id { get; set; }
        public string Url { get; set; }
        public string ImageUrl { get; set; }
        public string Title { get; set; }
        public string PostedDate { get; set; }
        public string PostedBy { get; set; }
        public string Language { get; set; }
        public int ReleasedYear { get; set; }
        public int ViewCount { get; set; }
        public int LikeCount { get; set; }
    }

    public class MovieVm : MovieThumbnailVm
    {
        public MovieVm()
        {
            Links = new List<VideoLinkVm>();
        }
        public string Description { get; set; }
        public List<VideoLinkVm> Links { get; set; }
        public VideoLinkVm Active { get { return Links[0]; } }

         public string JsonLink
        {
            get
            {
                //[{"title":"title1","file":"httpLink"},{"title":"title2","file":"httpLink","captions.file":"httpSub.srt"}]
                var links = new List<JsonVm>();
                foreach(var v in Links)
                    links.Add(new JsonVm { file = v.Url, title = v.Title });
                return new JavaScriptSerializer().Serialize(links);
            }
        }

         class JsonVm
         {
             public string title { get; set; }
             public string file { get; set; }
         }
    }

    public class VideoLinkVm : IComparable<VideoLinkVm>
    {
        private string url;
        public int ID { get; set; }
        public string Title { get; set; }
        public string HostSite { get; set; }
        public string Url {
            get
            {
                return this.url;
            }
            set
            {
                if (value != null)
                {
                    this.url = value;// value.Replace("&", "%26");
                }
            }
        }

        public int? PartID { get; set; }
        public int? PartIndex { get; set; }

        public int CompareTo(VideoLinkVm other)
        {
            if(this.PartID == null && other.PartID == null)
                return other.ID.CompareTo(this.ID);
            if (this.PartID == null && other.PartID != null)
                return -1;
            if (this.PartID != null && other.PartID == null)
                return 1;
            if (this.PartID == other.PartID)
                return this.PartIndex.Value.CompareTo(other.PartIndex.Value);

            return other.ID.CompareTo(this.ID);
        }
    }

    public class SearchResult
    {
        public string name { get; set; }
        public string id { get; set; }
    }
}