1+ import { getJsonLdDateField , getJsonLdLinkField , getJsonLdStringField } from './jsonld.js' ;
2+
13export 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
1921export 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