Select Git revision
mapping1.ts
mapping1.ts 2.59 KiB
import { Client, cacheExchange, fetchExchange, gql } from '@urql/core';
import { Response } from './types';
const audiothekApi = new Client({
url: 'https://api.ardaudiothek.de/graphql',
exchanges: [cacheExchange, fetchExchange],
});
const query = gql`
query Item {
item(id: "14278953") {
show {
coreId
externalId
title
url
publisher: publicationService {
coreId
dvbServiceId
title
url
organizationName
organization {
name
url
}
}
coreDocument
}
assetId
url: sharingUrl
title
published: publishDate
updated: core(key: "modified")
imagesList {
url
title
}
coreDocument
audioList {
title
audioCodec
href
}
}
}
`;
async function fetchData() {
const result = await audiothekApi.query<Response>(query, {}).toPromise();
if (result.error) {
throw result.error;
}
// console.log(JSON.stringify(result.data, null, 2));
return result.data;
}
function transformToActivityPub(response: Response) {
const item = response.item;
return {
"@context": "https://www.w3.org/ns/activitystreams",
"id": item.assetId,
"type": "PodcastEpisode",
"published": item.published,
"updated": item.updated,
"attributedTo": item.show.coreId,
"externalId": item.url,
"title": item.title,
"description": {
"type": "Note",