Skip to content

Commit

Permalink
added support for online mp3 files
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmaldonisi3pd committed Dec 14, 2022
1 parent d6881bb commit 6b4d0b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![version](https://img.shields.io/badge/version-0.1.6-blue)
![version](https://img.shields.io/badge/version-0.1.7-blue)
![license](https://img.shields.io/badge/license-MIT-brightgreen)
<a href='https://ko-fi.com/jjmaldonis' target='_blank'><img height='20' style='border:0px;height:26px;margin-bottom:-2.5px;' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee :)' /></a>

Expand Down
18 changes: 12 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,18 @@ export default class AutomaticAudioNotes extends Plugin {

private _getFullAudioSrcPath(audioNote: AudioNote): string | undefined {
let audioSrcPath: string | undefined = undefined;
const tfile = this.app.vault.getAbstractFileByPath(audioNote.audioFilename);
if (!tfile) {
console.error(`AudioNotes: Could not find audio file: ${audioNote.audioFilename}`)
return undefined;
// If the filename is a link, don't look for it in the vault.
if (audioNote.audioFilename.startsWith("https")) {
audioSrcPath = audioNote.audioFilename;
} else {
// If the file isn't a link, look for it in the vault and get its full file path.
const tfile = this.app.vault.getAbstractFileByPath(audioNote.audioFilename);
if (!tfile) {
console.error(`AudioNotes: Could not find audio file: ${audioNote.audioFilename}`)
return undefined;
}
audioSrcPath = this.app.vault.getResourcePath(tfile as TFile);
}
audioSrcPath = this.app.vault.getResourcePath(tfile as TFile);
if (audioSrcPath.includes("?")) {
audioSrcPath = audioSrcPath.slice(0, audioSrcPath.indexOf("?"));
}
Expand Down Expand Up @@ -1130,7 +1136,7 @@ export default class AutomaticAudioNotes extends Plugin {
let quoteCreatedForStart = undefined;
let quoteCreatedForEnd = undefined;
if (quoteCreatedForLine) {
[quoteCreatedForStart, quoteCreatedForEnd, ] = this._getStartAndEndFromBracketString(quoteCreatedForLine);
[quoteCreatedForStart, quoteCreatedForEnd,] = this._getStartAndEndFromBracketString(quoteCreatedForLine);
}

const audioNote = new AudioNote(title, author, audioFilename, start, end, speed, transcriptFilename, quoteCreatedForStart, quoteCreatedForEnd, quote, extendAudio);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-audio-notes",
"name": "Audio Notes",
"version": "0.1.6",
"version": "0.1.7",
"minAppVersion": "0.15.0",
"description": "Create notes for audio files based on translations generated by Open AI Whisper.",
"author": "Jason Maldonis",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-audio-notes",
"version": "0.1.6",
"version": "0.1.7",
"description": "Create notes for audio files based on translations generated by Open AI Whisper.",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 6b4d0b3

Please sign in to comment.