Skip to content

Commit

Permalink
Merge pull request #65 from TurunWappuradio/feat/public-showlist-json
Browse files Browse the repository at this point in the history
Public showlist json
  • Loading branch information
kovipu authored Oct 25, 2023
2 parents 8845dba + 883e091 commit d822137
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions google/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ensureDirectoryExists,
getImagePath,
saveArrayBufferToFile,
writeFile,
} from 'utils/fileHelpers';

export enum Color {
Expand Down Expand Up @@ -158,6 +159,8 @@ export const fetchShowlist = async (): Promise<{
shows
);
const weekKeys = generateWeekObj(showsByDate);

saveShowlistJson(showsByDate);
return { showsByDate, weekKeys };
};

Expand Down Expand Up @@ -222,3 +225,6 @@ const generateWeekObj = (showsByDate: Record<string, Show[]>) => {

return weekObj;
};

const saveShowlistJson = (showsByDate: Record<string, Show[]>) =>
writeFile(`${FILE_URL}/ohjelmakartta.json`, JSON.stringify(showsByDate));
3 changes: 3 additions & 0 deletions utils/fileHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ const downloadFile = async (url: string, path: string, filename: string) => {
return newFilename;
};
export default downloadFile;

export const writeFile = (path: string, data: string) =>
fs.writeFileSync(path, data, 'utf-8');

0 comments on commit d822137

Please sign in to comment.