Пример #1
0
        private static OpenSubtitle BuildSubtitle(SearchSubtitlesInfo data)
        {
            OpenSubtitlesKind kind;
            if(!Enum.TryParse(data.MovieKind, true, out kind))
            {
                kind = OpenSubtitlesKind.None;
            }

            int seriesEpisode;
            if (!int.TryParse(data.SeriesEpisode, out seriesEpisode))
            {
                seriesEpisode = 0;
            }

            int seriesSeason;
            if (!int.TryParse(data.SeriesSeason, out seriesSeason))
            {
                seriesSeason = 0;
            }

            var sub = new OpenSubtitle
            {
                IDMovie = data.IDMovie,
                IDMovieImdb = data.IDMovieImdb,
                IDSubMovieFile = data.IDSubMovieFile,
                IDSubtitleFile = data.IDSubtitleFile,
                IDSubtitle = data.IDSubtitle,
                ISO639 = data.ISO639,
                LanguageName = data.LanguageName,
                MatchedBy = data.MatchedBy,
                MovieByteSize = data.MovieByteSize,
                MovieFPS = data.MovieFPS,
                MovieName = data.MovieName,
                MovieReleaseName = data.MovieReleaseName,
                MovieHash = data.MovieHash,
                MovieImdbRating = data.MovieImdbRating,
                MovieKind = kind,
                MovieNameEng = data.MovieNameEng,
                MovieTimeMS = data.MovieTimeMS,
                MovieYear = data.MovieYear,
                QueryNumber = data.QueryNumber,
                SeriesEpisode = seriesEpisode,
                SeriesIMDBParent = data.SeriesIMDBParent,
                SeriesSeason = seriesSeason,
                SubFileName = data.SubFileName,
                SubActualCD = data.SubActualCD,
                SubAddDate = data.SubAddDate,
                SubAuthorComment = data.SubAuthorComment,
                SubBad = data.SubBad,
                SubComments = data.SubComments,
                SubDownloadLink = data.SubDownloadLink,
                SubDownloadsCnt = data.SubDownloadsCnt,
                SubEncoding = data.SubEncoding,
                SubFeatured = data.SubFeatured,
                SubFormat = data.SubFormat,
                SubHD = data.SubHD == "1",
                SubHash = data.SubHash,
                SubHearingImpaired = data.SubHearingImpaired == "1",
                SubLanguageID = data.SubLanguageID,
                SubLastTS = data.SubLastTS,
                SubRating = data.SubRating,
                SubSize = data.SubSize,
                SubSumCD = data.SubSumCD,
                SubtitlesLink = data.SubtitlesLink,
                UserID = data.UserID,
                UserNickName = data.UserNickName,
                UserRank = data.UserRank,
                ZipDownloadLink = data.ZipDownloadLink
            };

            return sub;
        }
 private static IEnumerable<OpenSubtitle> FilterOutUnwantedHits(OpenSubtitle[] results, IEnumerable<string> languages)
 {
     return results.Where(subtitle => languages.Contains(subtitle.ISO639)
                    && subtitle.MovieKind == OpenSubtitlesKind.Episode);
 }
 private Subtitle CreateSubtitle(OpenSubtitle openSubtitle)
 {
     var release = _episodeParser.ParseEpisodeInfo(openSubtitle.MovieReleaseName);
     return new Subtitle(openSubtitle.SubDownloadLink, openSubtitle.SubFileName, KnownLanguages.GetLanguageByTwoLetterIso(openSubtitle.ISO639))
     {
         SeriesName = release.SeriesName,
         Episode = openSubtitle.SeriesEpisode,
         Season = openSubtitle.SeriesSeason,
         EndEpisode = openSubtitle.SeriesEpisode,
         ReleaseGroup = release.ReleaseGroup
     };
 }
 private IEnumerable<Subtitle> FilterAndConvertResults(string[] languages, OpenSubtitle[] result)
 {
     var validResults = FilterOutUnwantedHits(result, languages);
     return validResults.Select(CreateSubtitle);
 }