예제 #1
0
        private int ExecuteSecondPass(AnalyseVideo analyseVideo, ParallelLoopState loopState, int currentPass)
        {
            //pass2 (remove prefix / suffixes)
            if (analyseVideo.Candidates.Count == 0 || analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
            {
                string fileNameGuess   = analyseVideo.GetMainFileNameGuess();
                string folderNameGuess = analyseVideo.GetMainFolderNameGuess();

                string fileName = Path.GetFileNameWithoutExtension(analyseVideo.Video.Files[0].Path);
                if (fileName != null)
                {
                    List <string> fileNameGuesses = VideoTitleExtractor.GetTitleGuessesFromString(fileName.ToLower(), true);
                    analyseVideo.AddTitleGuesses(fileNameGuesses);
                }
                var directoryName = Path.GetDirectoryName(analyseVideo.Video.Files[0].Path);
                if (directoryName != null)
                {
                    string        folderName        = directoryName.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).Last().ToLower();
                    List <string> folderNameGuesses = VideoTitleExtractor.GetTitleGuessesFromString(folderName, true);
                    analyseVideo.AddTitleGuesses(folderNameGuesses);
                }

                FillCandidates(analyseVideo, fileNameGuess, folderNameGuess);
            }
            analyseVideo.HandledTitleGuesses();
            ExecuteAfterPass(currentPass);

            //if (CancellationPending)
            //{
            //	e.Cancel = true;
            //	return;
            //}
            return(currentPass);
        }
예제 #2
0
        private void FillCandidates(AnalyseVideo analyseVideo, string fileNameGuess, string folderNameGuess)
        {
            List <string> guesses = new List <string> {
                fileNameGuess
            };

            if (folderNameGuess != null)
            {
                guesses.Add(folderNameGuess);
            }
            GetVideoInfos(analyseVideo, guesses);
            analyseVideo.OrderCandidates();

            //TODO 070 add option so user can disable info being changed for this video --> none of the videoInfo's from webservice are correct (maybe video isn't famous enough) --> shouldn't change all movieinfo --> abort analyse for this video
        }
예제 #3
0
        private int ExecuteFirstPassMain(AnalyseVideo analyseVideo, ParallelLoopState loopState, int currentPass)
        {
            //TODO 070 split up in different analysing passes --> only reanalyse videos where no good match was found (or selected by user)

            string fileNameGuess   = analyseVideo.GetMainFileNameGuess();
            string folderNameGuess = analyseVideo.GetMainFolderNameGuess();

            FillCandidates(analyseVideo, fileNameGuess, folderNameGuess);

            analyseVideo.HandledTitleGuesses();
            ExecuteAfterPass(currentPass);

            //if (CancellationPending)
            //{
            //	e.Cancel = true;
            //}
            return(currentPass);
        }
예제 #4
0
        private int ExecuteThirdPass(AnalyseVideo analyseVideo, ParallelLoopState loopState, int currentPass)
        {
            if (analyseVideo.Candidates.Count == 0 || analyseVideo.MatchPercentage < Constants.GREAT_MATCH_FOUND_TRESHOLD)
            {
                analyseVideo.AddTitleGuesses(VideoTitleExtractor.GetTitleGuessesFromPath(analyseVideo.Video.Files[0].Path));
                //TODO 004 optimize this --> also gets done in pass1 --> remember somehow
                UniqueList <string> titleGuesses = analyseVideo.GetTitleGuesses();

                string fileNameGuess   = analyseVideo.GetMainFileNameGuess();
                string folderNameGuess = analyseVideo.GetMainFolderNameGuess();

                titleGuesses.Clear();
                foreach (string searchResult in BingSearch.Search(fileNameGuess))
                {
                    analyseVideo.AddTitleGuesses(VideoTitleExtractor.CleanTitle(searchResult));
                }

                if (folderNameGuess != null)
                {
                    foreach (string searchResult in BingSearch.Search(folderNameGuess))
                    {
                        analyseVideo.AddTitleGuesses(VideoTitleExtractor.CleanTitle(searchResult));
                    }
                }

                FillCandidates(analyseVideo, fileNameGuess, folderNameGuess);
            }

            analyseVideo.HandledTitleGuesses();
            ExecuteAfterPass(currentPass);
            //if (CancellationPending)
            //{
            //	e.Cancel = true;
            //	return;
            //}
            return(currentPass);
        }
예제 #5
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;
        }