예제 #1
0
        private string TvdbToAnidb(string tvdb)
        {
            var tvdbId = TvdbEpisodeIdentity.Parse(tvdb);

            if (tvdbId == null)
            {
                return(null);
            }

            var converted = _mapper.ToAnidb(new TvdbEpisode
            {
                Series = tvdbId.Value.SeriesId,
                Season = tvdbId.Value.SeasonIndex,
                Index  = tvdbId.Value.EpisodeNumber
            });

            if (converted == null)
            {
                return(null);
            }

            int?end = null;

            if (tvdbId.Value.EpisodeNumberEnd != null)
            {
                var convertedEnd = _mapper.ToAnidb(new TvdbEpisode
                {
                    Series = tvdbId.Value.SeriesId,
                    Season = tvdbId.Value.SeasonIndex,
                    Index  = tvdbId.Value.EpisodeNumberEnd.Value
                });

                if (convertedEnd != null && convertedEnd.Season == converted.Season)
                {
                    end = convertedEnd.Index;
                }
            }

            var id = new AnidbEpisodeIdentity(converted.Series, converted.Index, end, null);

            return(id.ToString());
        }
예제 #2
0
        private string AnidbToTvdb(string anidb)
        {
            var anidbId = AnidbEpisodeIdentity.Parse(anidb);

            if (anidbId == null)
            {
                return(null);
            }

            var converted = _mapper.ToTvdb(new AnidbEpisode
            {
                Series = anidbId.Value.SeriesId,
                Season = string.IsNullOrEmpty(anidbId.Value.EpisodeType) ? 1 : 0,
                Index  = anidbId.Value.EpisodeNumber
            });

            int?end = null;

            if (anidbId.Value.EpisodeNumberEnd != null)
            {
                var convertedEnd = _mapper.ToAnidb(new TvdbEpisode
                {
                    Series = anidbId.Value.SeriesId,
                    Season = string.IsNullOrEmpty(anidbId.Value.EpisodeType) ? 1 : 0,
                    Index  = anidbId.Value.EpisodeNumberEnd.Value
                });

                if (convertedEnd.Season == converted.Season)
                {
                    end = convertedEnd.Index;
                }
            }

            var id = new TvdbEpisodeIdentity(converted.Series, converted.Season, converted.Index, end);

            return(id.ToString());
        }