Skip to content

Commit

Permalink
add related notes section and resolves #19
Browse files Browse the repository at this point in the history
  • Loading branch information
kinabalu committed Jun 8, 2024
1 parent 7705406 commit a9fca49
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
22 changes: 15 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ export default class VoiceNotesPlugin extends Plugin {
if (!await this.app.vault.adapter.exists(audioPath)) {
await this.app.vault.createFolder(audioPath)
}
const signedUrl = await this.vnApi.getSignedUrl(recording.recording_id)

const outputLocationPath = normalizePath(`${audioPath}/${recording.recording_id}.mp3`);
// Download file to disk
await this.vnApi.downloadFile(this.fs, signedUrl.url, outputLocationPath);

if (!await this.app.vault.adapter.exists(outputLocationPath)) {
// Get unique audio download URL and download file to disk
const signedUrl = await this.vnApi.getSignedUrl(recording.recording_id)
await this.vnApi.downloadFile(this.fs, signedUrl.url, outputLocationPath);
}

note += `![[${recording.recording_id}.mp3]]\n\n`
note += '# Transcript\n'
Expand All @@ -185,19 +187,25 @@ export default class VoiceNotesPlugin extends Plugin {
if (Array.isArray(creationData)) {
note += creationData.map(data => `- [ ] ${data}${this.settings.todoTag ? ' #' + this.settings.todoTag : ''}`).join('\n')
}
} else if (creation.type !== 'tweet') {
} else if (creation.type !== 'tweet' && creation.type !== 'summary') {
const creationData = creation.content.data as string[]

if (Array.isArray(creationData)) {
note += "- "
note += creationData.join("\n- ")
note += creationData.map(data => `- ${data}`).join('\n')
}

note += '\n'
} else {
const creationData = creation.content.data as string
note += creationData
note += '\n'
}
}

if (recording.related_notes.length > 0) {
note += '\n## Related Notes\n'
note += recording.related_notes.map(relatedNote => `- [[${sanitize(relatedNote.title)}]]`).join('\n')
}
console.debug(`Writing ${recording.recording_id} to ${recordingPath}`)

if (await this.app.vault.adapter.exists(recordingPath)) {
Expand Down
11 changes: 10 additions & 1 deletion types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export interface VoiceNoteTag {
name: string,
}

export interface RelatedVoiceNote {
id: number,
recording_id: number,
title: string,
transcript: string,
created_at: string,
}

export interface VoiceNoteEntry {
created_at: string,
creations: VoiceNoteCreation[],
Expand All @@ -75,7 +83,8 @@ export interface VoiceNoteEntry {
tags: VoiceNoteTag[],
title: string,
transcript: string,
updated_at: string
updated_at: string,
related_notes: RelatedVoiceNote[],
}

export interface VoiceNotesLinks {
Expand Down

0 comments on commit a9fca49

Please sign in to comment.