Skip to content

Commit e233c88

Browse files
Fix movies
1 parent 345bef8 commit e233c88

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

movies/vanilla/src/example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ const authenticatedFetch = await v7.getAuthenticatedFetch({
1010
const listUrl = 'https://michielbdejong.solidcommunity.net/movies/';
1111
const interpretation = await fetchList(listUrl, authenticatedFetch);
1212
interpretation.listings.forEach(listing => console.log(listing));
13+
interpretation.watchActions.forEach(watchAction => console.log(watchAction));

movies/vanilla/src/movies.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { getJsonLdDateField, getJsonLdLinkField, getJsonLdStringField } from './jsonld.js';
2+
13
export type Listing = {
24
created: Date;
35
modified: Date;
@@ -13,7 +15,7 @@ export type WatchAction = {
1315
created: Date;
1416
startTime: Date;
1517
endTime: Date;
16-
listing: Listing;
18+
listingUr: string;
1719
}
1820

1921
export type Interpretation = {
@@ -46,7 +48,30 @@ export async function fetchList(
4648
return;
4749
}
4850
const listing = await getJsonLd(entry['@id'], aFetch);
49-
ret.listings.push(listing);
51+
listing.forEach(thing => {
52+
if (thing['@type'].indexOf('https://schema.org/Movie') !== -1) {
53+
ret.listings.push({
54+
created: getJsonLdDateField(thing, 'http://purl.org/dc/terms/created'),
55+
modified: getJsonLdDateField(thing, 'http://purl.org/dc/terms/modified'),
56+
movie: {
57+
published: getJsonLdDateField(thing, 'https://schema.org/datePublished'),
58+
description: getJsonLdStringField(thing, 'https://schema.org/description'),
59+
image: getJsonLdStringField(thing, 'https://schema.org/image'), // sic: string instead of link here
60+
name: getJsonLdStringField(thing, 'https://schema.org/name'),
61+
sameAs: thing['https://schema.org/sameAs'].map(x => x['@value']) as string[], // sic: string instead of link here
62+
}
63+
});
64+
} else if (thing['@type'].indexOf('https://schema.org/WatchAction') !== -1) {
65+
ret.watchActions.push({
66+
created: getJsonLdDateField(thing, 'http://purl.org/dc/terms/created'),
67+
startTime: getJsonLdDateField(thing, 'https://schema.org/startTime'),
68+
endTime: getJsonLdDateField(thing, 'https://schema.org/endTime'),
69+
listingId: getJsonLdLinkField(thing, 'https://schema.org/object'),
70+
});
71+
} else {
72+
console.log('thing type not recognised', thing);
73+
}
74+
})
5075
}));
5176
return ret;
5277
}

0 commit comments

Comments
 (0)