private string GetDamId(User user, Chapter chapter) { return string.Concat( user.AudioVolumeCode, GetCollectionId(chapter), user.IsDramaticAudioSelected ? '2' : '1', MediaType); }
private char GetCollectionId(Chapter chapter) { return GetCollectionId(chapter.Book.Group); }
private async Task<string> GetAudioUrl(User user, Chapter chapter) { var restClient = CreateDbtRestClient(); var request = new RestRequest("audio/path"); request.AddParameter("dam_id", GetDamId(user, chapter)); request.AddParameter("book_id", chapter.Book.DbpId); request.AddParameter("chapter_id", chapter.ChapterNumber); var response = await restClient.ExecuteGetTaskAsync<List<AudioPath>>(request); var path = response.Data.FirstOrDefault(); if (path == null) { throw new Exception("Unable to determine audio URL."); } return path.Path; }