private static async Task <SubtitleSelection> SearchSubtitleAsync(string file) { var hash = Crypto.HashFile(file); var fileInfo = new FileInfo(file); var subs = await client.SearchSubtitlesAsync( new HashSearchQuery { LanguageIds = language.Iso6392, FileHash = Crypto.BinaryToHex(hash), FileSize = fileInfo.Length, }); var selection = SelectSubtitle(Mapper.Map <Subtitle[]>(subs)); if (selection == null) { Console.WriteLine("{0} {1}", Keyword("NotFound"), fileInfo.Name); } else { Console.WriteLine("{0} {1}", Keyword(selection.MatchMethod), fileInfo.Name); } return(new SubtitleSelection { File = file, Selection = selection }); }
private async Task <SubtitleSearchResultCollection> SearchSubtitles(SearchQuery[] query) { var subs = new SubtitleSearchResultCollection(); try { subs = await osdbClient.SearchSubtitlesAsync(query); } catch (OSDbException e) { var result = MessageBox.Show( $"Subtitle search failed: {e.Message}", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { subs = await SearchSubtitles(query); } } return(subs); }