예제 #1
0
        private string GetTargetEpisodeName([NotNull] ShowItem show, [NotNull] Episode ep, bool urlEncode)
        {
            //note this is for an Episode and not a ProcessedEpisode
            string name = StyleString;

            string epname = ep.Name;

            name = name.ReplaceInsensitive("{ShowName}", show.ShowName);
            switch (show.Order)
            {
            case Season.SeasonType.dvd:
                name = name.ReplaceInsensitive("{Season}", ep.DvdSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.DvdSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", show.GetSeasonIndex(ep.DvdSeasonNumber).ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", show.GetSeasonIndex(ep.DvdSeasonNumber).ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.DvdEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.DvdEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.DvdEpNum.ToString("00")); break;

            case Season.SeasonType.aired:
                name = name.ReplaceInsensitive("{Season}", ep.AiredSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.AiredSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", show.GetSeasonIndex(ep.AiredSeasonNumber).ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", show.GetSeasonIndex(ep.AiredSeasonNumber).ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.AiredEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.AiredEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.AiredEpNum.ToString("00"));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            name = name.ReplaceInsensitive("{EpisodeName}", epname);
            name = name.ReplaceInsensitive("{Number}", "");
            name = name.ReplaceInsensitive("{Number:2}", "");
            name = name.ReplaceInsensitive("{Number:3}", "");
            name = name.ReplaceInsensitive("{Imdb}", ep.ImdbCode);

            SeriesInfo si = show.TheSeries();

            name = name.ReplaceInsensitive("{ShowImdb}", si?.Imdb ?? string.Empty);
            name = name.ReplaceInsensitive("{Year}", si?.MinYear.ToString() ?? string.Empty);

            Season selectedSeason = show.GetSeason(ep.GetSeasonNumber(show.Order));

            name = name.ReplaceInsensitive("{SeasonYear}", selectedSeason != null ? selectedSeason.MinYear().ToString() : string.Empty);

            name = ReplaceDates(urlEncode, name, ep.GetAirDateDt(show.GetTimeZone()));

            name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts

            name = name.Replace("\\[", "[");
            name = name.Replace("\\]", "]");

            return(name.Trim());
        }
예제 #2
0
        public DateTime?GetAirDateDt(bool inLocalTime)
        {
            LocalDateTime?x = GetAirDateDt();

            if (!inLocalTime && x.HasValue)
            {
                return(x.Value.ToDateTimeUnspecified());
            }

            if (!inLocalTime)
            {
                return(null);
            }

            // do timezone adjustment
            return(GetAirDateDt(Show.GetTimeZone()));
        }
예제 #3
0
        private void WriteEpisodeDetailsFor(Episode episode, XmlWriter writer, bool multi, bool dvdOrder)
        {
            // See: http://xbmc.org/wiki/?title=Import_-_Export_Library#TV_Episodes
            writer.WriteStartElement("episodedetails");

            XMLHelper.WriteElementToXML(writer, "title", episode.Name);
            XMLHelper.WriteElementToXML(writer, "showtitle", this.Episode.SI.ShowName);
            XMLHelper.WriteElementToXML(writer, "rating", episode.EpisodeRating);
            if (dvdOrder)
            {
                XMLHelper.WriteElementToXML(writer, "season", episode.DVDSeasonNumber);
                XMLHelper.WriteElementToXML(writer, "episode", episode.DVDEpNum);
            }
            else
            {
                XMLHelper.WriteElementToXML(writer, "season", episode.AiredSeasonNumber);
                XMLHelper.WriteElementToXML(writer, "episode", episode.AiredEpNum);
            }

            XMLHelper.WriteElementToXML(writer, "plot", episode.Overview);

            writer.WriteStartElement("aired");
            if (episode.FirstAired != null)
            {
                writer.WriteValue(episode.FirstAired.Value.ToString("yyyy-MM-dd"));
            }
            writer.WriteEndElement();

            XMLHelper.WriteElementToXML(writer, "mpaa", this.Episode.SI?.TheSeries()?.GetContentRating(), true);

            //Director(s)
            string epDirector = episode.EpisodeDirector;

            if (!string.IsNullOrEmpty(epDirector))
            {
                foreach (string daa in epDirector.Split('|'))
                {
                    XMLHelper.WriteElementToXML(writer, "director", daa, true);
                }
            }

            //Writers(s)
            string epWriter = episode.Writer;

            if (!string.IsNullOrEmpty(epWriter))
            {
                foreach (string txtWriter in epWriter.Split('|'))
                {
                    XMLHelper.WriteElementToXML(writer, "credits", txtWriter, true);
                }
            }

            // Guest Stars...
            if (!String.IsNullOrEmpty(episode.EpisodeGuestStars))
            {
                string recurringActors = "";

                if (this.Episode.SI != null)
                {
                    recurringActors = String.Join("|", this.Episode.SI.TheSeries().GetActors());
                }

                string guestActors = episode.EpisodeGuestStars;
                if (!string.IsNullOrEmpty(guestActors))
                {
                    foreach (string gaa in guestActors.Split('|'))
                    {
                        if (string.IsNullOrEmpty(gaa))
                        {
                            continue;
                        }

                        // Skip if the guest actor is also in the overal recurring list
                        if (!string.IsNullOrEmpty(recurringActors) && recurringActors.Contains(gaa))
                        {
                            continue;
                        }

                        writer.WriteStartElement("actor");
                        XMLHelper.WriteElementToXML(writer, "name", gaa);
                        writer.WriteEndElement(); // actor
                    }
                }
            }

            // actors...
            if (this.Episode.SI != null)
            {
                foreach (string aa in this.Episode.SI.TheSeries().GetActors())
                {
                    if (string.IsNullOrEmpty(aa))
                    {
                        continue;
                    }

                    writer.WriteStartElement("actor");
                    XMLHelper.WriteElementToXML(writer, "name", aa);
                    writer.WriteEndElement(); // actor
                }
            }

            if (multi)
            {
                writer.WriteStartElement("resume");
                //we have to put 0 as we don't know where the multipart episode starts/ends
                XMLHelper.WriteElementToXML(writer, "position", 0);
                XMLHelper.WriteElementToXML(writer, "total", 0);
                writer.WriteEndElement(); // resume

                //For now we only put art in for multipart episodes. Kodi finds the art appropriately
                //without our help for the others

                ShowItem episodeSi = this.Episode.SI ?? this.SI;
                string   filename  =
                    TVSettings.Instance.FilenameFriendly(
                        TVSettings.Instance.NamingStyle.GetTargetEpisodeName(episode, episodeSi.ShowName, episodeSi.GetTimeZone(), episodeSi.DVDOrder));

                string thumbFilename = filename + ".jpg";
                XMLHelper.WriteElementToXML(writer, "thumb", thumbFilename);
                //Should be able to do this using the local filename, but only seems to work if you provide a URL
                //XMLHelper.WriteElementToXML(writer, "thumb", TheTVDB.Instance.GetTVDBDownloadURL(episode.GetFilename()));
            }
            writer.WriteEndElement(); // episodedetails
        }
예제 #4
0
        private static void WriteEpisodeDetailsFor([NotNull] Episode episode, [CanBeNull] ShowItem show, [NotNull] XmlWriter writer, bool multi, bool dvdOrder)
        {
            // See: http://xbmc.org/wiki/?title=Import_-_Export_Library#TV_Episodes
            writer.WriteStartElement("episodedetails");

            writer.WriteElement("title", episode.Name);
            writer.WriteElement("originaltitle", show?.ShowName);
            writer.WriteElement("showtitle", show?.ShowName);

            string showRating = episode.EpisodeRating;

            if (showRating != null)
            {
                writer.WriteStartElement("ratings");

                writer.WriteStartElement("rating");
                writer.WriteAttributeString("name", "tvdb");
                writer.WriteAttributeString("max", "10");
                writer.WriteAttributeString("default", "true");

                writer.WriteElement("value", showRating);
                writer.WriteElement("votes", episode.SiteRatingCount ?? 0, true);

                writer.WriteEndElement(); //rating

                writer.WriteEndElement(); //ratings
            }

            if (dvdOrder)
            {
                writer.WriteElement("season", episode.DvdSeasonNumber);
                writer.WriteElement("episode", episode.DvdEpNum);
            }
            else
            {
                writer.WriteElement("season", episode.AiredSeasonNumber);
                writer.WriteElement("episode", episode.AiredEpNum);
            }

            writer.WriteElement("plot", episode.Overview);
            writer.WriteElement("studio", episode.TheSeries?.Network);

            writer.WriteStartElement("aired");
            if (episode.FirstAired != null)
            {
                writer.WriteValue(episode.FirstAired.Value.ToString("yyyy-MM-dd"));
            }

            writer.WriteEndElement();

            writer.WriteElement("mpaa", show?.TheSeries()?.ContentRating, true);

            //Director(s)
            string epDirector = episode.EpisodeDirector;

            if (!string.IsNullOrEmpty(epDirector))
            {
                foreach (string daa in epDirector.Split('|'))
                {
                    writer.WriteElement("director", daa, true);
                }
            }

            //Writers(s)
            string epWriter = episode.Writer;

            if (!string.IsNullOrEmpty(epWriter))
            {
                foreach (string txtWriter in epWriter.Split('|'))
                {
                    writer.WriteElement("credits", txtWriter, true);
                }
            }

            // Guest Stars...
            if (!string.IsNullOrEmpty(episode.EpisodeGuestStars))
            {
                string recurringActors = "";

                if (show != null)
                {
                    recurringActors = string.Join("|", show.TheSeries()?.GetActorNames() ?? new List <string>());
                }

                string guestActors = episode.EpisodeGuestStars;
                if (!string.IsNullOrEmpty(guestActors))
                {
                    foreach (string gaa in guestActors.Split('|')
                             .Where(gaa => !string.IsNullOrEmpty(gaa))
                             .Where(gaa => string.IsNullOrEmpty(recurringActors) || !recurringActors.Contains(gaa)))
                    {
                        writer.WriteStartElement("actor");
                        writer.WriteElement("name", gaa);
                        writer.WriteEndElement(); // actor
                    }
                }
            }

            // actors...
            if (show != null)
            {
                foreach (Actor aa in (show.TheSeries()?.GetActors() ?? new List <Actor>())
                         .Where(aa => !string.IsNullOrEmpty(aa.ActorName)))
                {
                    writer.WriteStartElement("actor");
                    writer.WriteElement("name", aa.ActorName);
                    writer.WriteElement("role", aa.ActorRole);
                    writer.WriteElement("order", aa.ActorSortOrder);
                    writer.WriteElement("thumb", aa.ActorImage);
                    writer.WriteEndElement(); // actor
                }
            }

            if (multi)
            {
                writer.WriteStartElement("resume");
                //we have to put 0 as we don't know where the multipart episode starts/ends
                writer.WriteElement("position", 0);
                writer.WriteElement("total", 0);
                writer.WriteEndElement(); // resume

                //For now we only put art in for multipart episodes. Kodi finds the art appropriately
                //without our help for the others

                if (show != null)
                {
                    string filename =
                        TVSettings.Instance.FilenameFriendly(
                            TVSettings.Instance.NamingStyle.GetTargetEpisodeName(show, episode, show.GetTimeZone(),
                                                                                 show.DvdOrder));

                    string thumbFilename = filename + ".jpg";
                    writer.WriteElement("thumb", thumbFilename);
                    //Should be able to do this using the local filename, but only seems to work if you provide a URL
                    //XMLHelper.WriteElementToXML(writer, "thumb", TheTVDB.Instance.GetTVDBDownloadURL(episode.GetFilename()))
                }
            }
            writer.WriteEndElement(); // episodedetails
        }
예제 #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Season   sn = (Season)value;
            ShowItem si = sn?.TheSeries?.Show;

            if (si is null)
            {
                return(Brushes.BlueViolet);
            }

            if (si.IgnoreSeasons.Contains(sn.SeasonNumber))
            {
                return(Brushes.Gray);
            }

            if (TVSettings.Instance.ShowStatusColors != null)
            {
                return(new SolidColorBrush(TVSettings.Instance.ShowStatusColors.GetEntry(true, false,
                                                                                         sn.Status(si.GetTimeZone()).ToString()) ?? Colors.Black));
            }

            return(Brushes.Black);
        }