Пример #1
0
        private void GetVideoInfos(AnalyseVideo analyseVideo, List <string> referenceNames)
        {
            //var candidates = new SortedSet<Video>(new SimilarityComparer()); //sort candidates by their match score with the original filename and foldername

            //TODO 050 analyse name => predict movie or serie => execute suitable block of code blow here

            //if not certainly an episode => alsosearch for movie
            UniqueList <string> uniqueList = analyseVideo.GetTitleGuesses();

            if (analyseVideo.AnalyseType != VideoTypeEnum.Episode)
            {
                int guessIndex = 0;
                //search for videos
                UniqueList <string> titleGuesses = uniqueList;
                while (guessIndex < titleGuesses.Count && analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
                {
                    string       titleGuess = titleGuesses[guessIndex];
                    List <Video> foundCandidates;
                    if (_searchClient.SearchMovie(titleGuess, out foundCandidates))
                    {
                        int candidateIndex = 0;
                        while (candidateIndex < foundCandidates.Count &&
                               analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
                        {
                            var videoInfo = foundCandidates[candidateIndex];
                            //add pairs of similarity and videoInfo to the list
                            //similarity == max of similarity between to the original guesses for filename and foldername and the videoinfo name from the webservice
                            List <double> similarities = new List <double>();
                            foreach (string referenceName in referenceNames)
                            {
                                similarities.Add(StringSimilarity.GetSimilarity(videoInfo.Name + " " + videoInfo.Release.Year, referenceName));
                                similarities.Add(StringSimilarity.GetSimilarity(videoInfo.Name, referenceName));
                                //TODO 005 give bonus to videoinfo where eg: "men in black" --> original file name contains: mib (first letters of every word)
                            }
                            ;
                            videoInfo.TitleMatchRatio = similarities.Max();
                            FilterAddCandidate(videoInfo, analyseVideo.Candidates);

                            analyseVideo.NotYetAnalysed = false;

                            candidateIndex++;
                        }
                    }
                    analyseVideo.NotYetAnalysed = false;
                    guessIndex++;
                }
            }

            //if no suitable candidate
            //search for tv shows
            if (analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
            {
                int guessIndex = 0;
                while (guessIndex < uniqueList.Count && analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
                {
                    string       titleGuess = uniqueList[guessIndex];
                    List <Serie> foundCandidates;
                    if (_searchClient.SearchSerie(titleGuess, out foundCandidates))
                    {
                        int candidateIndex = 0;
                        while (candidateIndex < foundCandidates.Count &&
                               analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
                        {
                            Serie serie   = foundCandidates[candidateIndex];
                            Video episode = new Video();
                            if (_searchClient.GetEpisodeDetails(serie.IdTmdb, 1, 1, ref episode))
                            {
                                //add pairs of similarity and videoInfo to the list
                                //similarity == max of similarity between to the original guesses for filename and foldername and the videoinfo name from the webservice

                                List <double> similarities = new List <double>();
                                foreach (string referenceName in referenceNames)
                                {
                                    similarities.Add(StringSimilarity.GetSimilarity(serie.Name, referenceName));
                                    //TODO 005 give bonus to videoinfo where eg: "men in black" --> original file name contains: mib (first letters of every word)
                                }

                                episode.TitleMatchRatio = similarities.Max();
                                FilterAddCandidate(episode, analyseVideo.Candidates);

                                analyseVideo.NotYetAnalysed = false;
                            }
                            candidateIndex++;
                        }
                    }
                    guessIndex++;
                    analyseVideo.NotYetAnalysed = false;
                }
            }
            analyseVideo.NotYetAnalysed = false;
        }