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); }
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; }