private bool IsOK(FilmInfo finfo) { return(TitleManipulator.flattenString(finfo.titre).Contains(TitleManipulator.flattenString(finfo.HexedTitle)) || TitleManipulator.flattenString(finfo.orig_titre).Contains(TitleManipulator.flattenString(finfo.HexedTitle))); }
private void GetFilmInfos(bool bIsAuto) { try { _cache.PersistCache(); this.Cursor = Cursors.WaitCursor; FilmInfo finfo = null; if (ListeFilms.SelectedIndex != -1) { if (_cache.doesnotContainsFilmInfo(ListeFilms.SelectedItem.ToString())) { lblIndex.Text = currIndex.ToString(); finfo = AlloClient.GetFromTitleLight(ListeFilms.SelectedItem.ToString(), currIndex); if (finfo != null) { maxIndex = finfo.totalInSearch; if (bIsAuto) { if ((finfo.titre != null) && maxIndex > 1) { //Stop if the film is ok with the file title if (!IsOK(finfo)) { if (currIndex != maxIndex) { ++currIndex; btnPrev.Enabled = true; GetFilmInfos(true); } } } if (finfo.titre != null) { // Get the full info finfo = AlloClient.GetFromTitle(ListeFilms.SelectedItem.ToString(), currIndex); } } } } else { currIndex = 0; lblIndex.Text = currIndex.ToString(); finfo = _cache.GetInfo(ListeFilms.SelectedItem.ToString()); } } if (finfo != null) { pictureBox1.Image = finfo.jaquette; lblYear.Text = finfo.year; lblTitle.Text = finfo.titre + " (" + finfo.HexedTitle + ")"; lblDirector.Text = finfo.realisateur; lblResume.Text = finfo.synopsis; lblDuree.Text = finfo.duree; lblTotal.Text = finfo.totalInSearch.ToString(); lnklblFiche.Text = finfo.link; lblGenres.Text = TitleManipulator.AddSpacesToSentence(finfo.genre); lblPresse.Text = finfo.presse.ToString("0.0") + "/5"; } else { SnipFiche(); } if (ListeFilms.SelectedIndex != -1) { _cache.SetInfo(ListeFilms.SelectedItem.ToString(), finfo); } } catch (Exception e) { MessageBox.Show(e.Message); } finally { this.Cursor = Cursors.Arrow; } }