public void CompareTest()
        {
            var winner = "2.Broke.Girls.S01E01.1080p.WEB-DL.x265.HEVC-zsewdc";
            var data   = new[]
            {
                "2 Broke Girls - 1X01 - Pilot",
                "2.Broke.Girls.S01E01.REPACK.720p.HDTV.x264-IMMERSE-eng",
                winner,
                "2.Broke.Girls.S01E01.REPACK.720p.HDTV.x264-IMMERSE",
                "2.Broke.Girls.S01E01.720p.bluray.x264-psychd_ENG"
            };

            var target = new ItemDataComparer("2.Broke.Girls.S01E01.1080p.WEB-DL.x265.HEVC-zsewdc");
            var points = data.Select(n => target.GetMatchesPoints(n)).ToArray();

            Assert.AreEqual(points.Max(), target.GetMatchesPoints(winner));
        }
示例#2
0
        /// <summary>
        /// Queries this instance.
        /// </summary>
        /// <returns>The query result.</returns>
        public Status Query()
        {
            this.view.ShowProgress(this.FilePath, Literals.Data_Searching_video_subtitle);
            var subtitlesMetaResult = this.GetSubtitlesMeta();

            if (subtitlesMetaResult.Status != Status.Success)
            {
                if (!string.IsNullOrEmpty(subtitlesMetaResult.Message))
                {
                    this.view.Notify(subtitlesMetaResult.Message);
                    return(subtitlesMetaResult.Status);
                }
            }

            if (!subtitlesMetaResult.Data.HasAny())
            {
                this.view.Notify(Literals.Data_No_subtitle_for + this.FilePath);
                return(Status.Failure);
            }

            if (subtitlesMetaResult.Data.Count == 1)
            {
                return(this.Download(subtitlesMetaResult.Data[0]));
            }

            var comparer        = new ItemDataComparer(this.Title);
            var selections      = subtitlesMetaResult.Data.OrderByDescending(i => i, comparer).Cast <ItemData>().ToList();
            var selectionResult = this.view.GetSelection(
                selections,
                this.FilePath,
                string.Format(Literals.Data_Select_subtitle, AppContext.Global.LocalizedLanguage));

            if (selectionResult.Status != Status.Success || selectionResult.Data == null)
            {
                return(selectionResult.Status);
            }

            return(this.Download((Subtitle)selectionResult.Data));
        }
示例#3
0
        /// <summary>
        /// Queries this instance.
        /// </summary>
        /// <returns>The query result.</returns>
        public Status Query()
        {
            this.view.ShowProgress(this.FilePath, Literals.Data_Searching_video_subtitle);
            QueryResult<Subtitles> subtitlesMetaResult;

            try
            {
                subtitlesMetaResult = this.db.GetSubtitlesMeta(this.Title, AppContext.Global.Language);
            }
            catch (Exception ex)
            {
                Trace.TraceError(Literals.Data_Failed_to_get_subtitles_meta, this.Title, this.db.GetType().Name, ex);
                subtitlesMetaResult = new QueryResult<Subtitles>(
                    Status.Fatal,
                    null,
                    string.Format(Literals.Data_Failed_to_get_subtitles_meta, this.Title, this.db.GetType().Name, ex.Message));
            }

            if (subtitlesMetaResult.Status != Status.Success)
            {
                if (!string.IsNullOrEmpty(subtitlesMetaResult.Message))
                {
                    this.view.Notify(subtitlesMetaResult.Message);
                    return subtitlesMetaResult.Status;
                }
            }

            if (!subtitlesMetaResult.Data.HasAny())
            {
                this.view.Notify(Literals.Data_No_subtitle_for + this.FilePath);
                return Status.Failure;
            }

            if (subtitlesMetaResult.Data.Count == 1)
            {
                return this.Download(subtitlesMetaResult.Data[0]);
            }

            var comparer = new ItemDataComparer(this.Title);
            var selections = subtitlesMetaResult.Data.OrderByDescending(i => i, comparer).Cast<ItemData>().ToList();
            var selectionResult = this.view.GetSelection(
                        selections,
                        this.FilePath,
                        string.Format(Literals.Data_Select_subtitle, AppContext.Global.LocalizedLanguage));

            if (selectionResult.Status != Status.Success || selectionResult.Data == null)
            {
                return selectionResult.Status;
            }

            return this.Download((Subtitle)selectionResult.Data);
        }