Exemplo n.º 1
0
        private MediaTags GetTagsForFile(FileInfo mediaFile)
        {
            MediaTags result = new MediaTags(mediaFile);

            if (mediaFile == null) return result;

            result.tagsHigh.AddRange(GetTagsHighForFile(result.File));
            result.tagsLow.AddRange(GetTagsLowForFile(result.File));
            result.group = GetGroupForFile(result.File);

            return result;
        }
Exemplo n.º 2
0
        private double GetRank(MediaTags fileTags, MediaTags subtitleTags)
        {
            double result = 0.0;

            int sameHight, addedHigh, missingHigh;
            GetCounts(fileTags.tagsHigh, subtitleTags.tagsHigh, out sameHight, out addedHigh, out missingHigh);

            int sameLow, addedLow, missingLow;
            GetCounts(fileTags.tagsLow, subtitleTags.tagsLow, out sameLow, out addedLow, out missingLow);

            if (firstPercentage == 0 && secondPercentage == 0 && thirdPercentage == 0)
                return result; // nothing to do

            double highPoints = ((double)sameHight / (double)fileTags.tagsHigh.Count) * (double)firstPercentage;
            double lowPoints = ((double)sameLow / (double)fileTags.tagsLow.Count) * (double)secondPercentage;
            double groupPoints = 0.0;
            if (string.IsNullOrEmpty(subtitleTags.group) && fileTags.group.Length > 2 && subtitleTags.File != null)
                groupPoints = (subtitleTags.File.Contains(fileTags.group, StringComparison.InvariantCultureIgnoreCase) ? 1 : 0) * (double)thirdPercentage;
            else
                groupPoints = ((fileTags.group == subtitleTags.group) ? 1 : 0) * (double)thirdPercentage;
            highPoints = highPoints.CorrectNaN();
            lowPoints = lowPoints.CorrectNaN();

            result = highPoints + lowPoints + groupPoints;

            double highMissingPoints = 0.0;
            double lowMissingPoints = 0.0;
            if (subtitleTags.tagsHigh.Count > 0)
                highMissingPoints = (((double)missingHigh / (double)fileTags.tagsHigh.Count) * (double)firstPercentage) * 0.75;
            if (subtitleTags.tagsLow.Count > 0)
                lowMissingPoints = (((double)missingLow / (double)fileTags.tagsLow.Count) * (double)secondPercentage) * 0.75;
            highMissingPoints = highMissingPoints.CorrectNaN();
            lowMissingPoints = lowMissingPoints.CorrectNaN();

            result = result - highMissingPoints - lowMissingPoints;

            double highAddedPoints = (((double)addedHigh / (double)fileTags.tagsHigh.Count) * (double)firstPercentage) * 0.75;
            double lowAddedPoints = (((double)addedLow / (double)fileTags.tagsLow.Count) * (double)secondPercentage) * 0.75;
            highAddedPoints = highAddedPoints.CorrectNaN();
            lowAddedPoints = lowAddedPoints.CorrectNaN();

            result = result - highAddedPoints - lowAddedPoints;

            return result;
        }