Skip to content

Commit

Permalink
feat(schema): ✨ use adult data from audible in form of isAdult
Browse files Browse the repository at this point in the history
This data already comes from Audible, might as well include it
  • Loading branch information
djdembeck committed Aug 19, 2023
1 parent 5207b3a commit feec8d8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/config/models/Book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const bookSchema = schema(
})
),
image: types.string(),
isAdult: types.boolean({ required: true }),
language: types.string({ required: true }),
narrators: types.array(
types.object({
Expand Down Expand Up @@ -55,6 +56,7 @@ const bookSchema = schema(
},
{
defaults: {
isAdult: false,
region: 'us'
},
timestamps: true
Expand Down
1 change: 1 addition & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const ApiBookSchema = z.object({
formatType: z.string(),
genres: z.array(ApiGenreSchema).optional(),
image: z.string().url().optional(),
isAdult: z.boolean().default(false),
language: z.string(),
narrators: z.array(ApiNarratorOnBookSchema).optional(),
publisherName: z.string(),
Expand Down
1 change: 1 addition & 0 deletions src/helpers/books/audible/ApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class ApiHelper {
genres: [...this.getGenres(), ...this.getTags()]
}),
image: this.getHighResImage(),
isAdult: this.audibleResponse.is_adult_product,
language: this.audibleResponse.language,
narrators:
this.audibleResponse.narrators?.map((person: ApiNarratorOnBook) => {
Expand Down
1 change: 1 addition & 0 deletions tests/datasets/audible/books/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ export const minimalB0036I54I6: ApiBook = {
{ asin: '18574505011', name: 'Poetry', type: 'tag' }
],
image: 'https://m.media-amazon.com/images/I/41dNQts9Z7L.jpg',
isAdult: false,
language: 'english',
narrators: [],
publisherName: 'Stanford Audio',
Expand Down
3 changes: 3 additions & 0 deletions tests/datasets/helpers/books.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const description =
'On the edge of the galaxy, a diplomatic mission to an alien planet takes a turn when the Legionnaires, an elite special fighting force, find themselves ambushed and stranded behind enemy lines. They struggle to survive under siege, waiting on a rescue that might never come....'
const formatType = 'unabridged'
const image = 'https://m.media-amazon.com/images/I/91spdScZuIL.jpg'
const isAdult = false
const language = 'english'
const narrators = [
{
Expand Down Expand Up @@ -370,6 +371,7 @@ export const changedParsedBook: ApiBook = {
description,
formatType,
image,
isAdult,
language,
narrators,
publisherName,
Expand Down Expand Up @@ -412,6 +414,7 @@ export const parsedBookWithoutGenres: ApiBook = {
description,
formatType,
image,
isAdult,
language,
narrators,
publisherName,
Expand Down

0 comments on commit feec8d8

Please sign in to comment.