aboutsummaryrefslogtreecommitdiff
path: root/Emby.XmlTv/Emby.XmlTv.Console/Classes/EntityExtensions.cs
blob: 96e508f1227cf9b848f037a98dbb5b569367c2e6 (plain)
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
using System;
using System.Linq;
using System.Text;

using Emby.XmlTv.Entities;

namespace Emby.XmlTv.Console.Classes
{
    public static class EntityExtensions
    {
        public static string GetHeader(this string text)
        {
            var channelHeaderString = " " + text;

            var builder = new StringBuilder();
            builder.AppendLine("".PadRight(5 + channelHeaderString.Length + 5, Char.Parse("*")));
            builder.AppendLine("".PadRight(5, Char.Parse("*")) + channelHeaderString + "".PadRight(5, Char.Parse("*")));
            builder.AppendLine("".PadRight(5 + channelHeaderString.Length + 5, Char.Parse("*")));

            return builder.ToString();
        }

        public static string GetChannelDetail(this XmlTvChannel channel)
        {
            var builder = new StringBuilder();
            builder.AppendFormat("Id:                {0}\r\n", channel.Id);
            builder.AppendFormat("Display-Name:      {0}\r\n", channel.DisplayName);
            builder.AppendFormat("Url:               {0}\r\n", channel.Url);
            builder.AppendFormat("Icon:              {0}\r\n", channel.Icon != null ? channel.Icon.ToString() : string.Empty);
            builder.AppendLine("-------------------------------------------------------");

            return builder.ToString();
        }

        public static string GetProgrammeDetail(this XmlTvProgram programme, XmlTvChannel channel)
        {
            var builder = new StringBuilder();
            builder.AppendFormat("Channel:           {0} - {1}\r\n", channel.Id, channel.DisplayName);
            builder.AppendFormat("Start Date:        {0:G}\r\n", programme.StartDate);
            builder.AppendFormat("End Date:          {0:G}\r\n", programme.EndDate);
            builder.AppendFormat("Name:              {0}\r\n", programme.Title);
            builder.AppendFormat("Episode Detail:    {0}\r\n", programme.Episode);
            builder.AppendFormat("Episode Title:     {0}\r\n", programme.Episode.Title);
            builder.AppendFormat("Description:       {0}\r\n", programme.Description);
            builder.AppendFormat("Categories:        {0}\r\n", string.Join(", ", programme.Categories));
            builder.AppendFormat("Countries:         {0}\r\n", string.Join(", ", programme.Countries));
            builder.AppendFormat("Credits:           {0}\r\n", string.Join(", ", programme.Credits));
            builder.AppendFormat("Rating:            {0}\r\n", programme.Rating);
            builder.AppendFormat("Star Rating:       {0}\r\n", programme.StarRating.HasValue ? programme.StarRating.Value.ToString() : string.Empty);
            builder.AppendFormat("Previously Shown:  {0:G}\r\n", programme.PreviouslyShown);
            builder.AppendFormat("Copyright Date:    {0:G}\r\n", programme.CopyrightDate);
            builder.AppendFormat("Is Repeat:         {0}\r\n", programme.IsPreviouslyShown);
            builder.AppendFormat("Icon:              {0}\r\n", programme.Icon != null ? programme.Icon.ToString() : string.Empty);
            builder.AppendLine("-------------------------------------------------------");
            return builder.ToString();
        }
    }
}