Skip to content

Commit

Permalink
added support for .m4a files
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmaldonis committed Feb 3, 2023
1 parent 834ea88 commit a889e6e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 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.2.4-blue)
![version](https://img.shields.io/badge/version-0.2.5-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
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.2.4",
"version": "0.2.5",
"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.2.4",
"version": "0.2.5",
"description": "Create notes for audio files based on translations generated by Open AI Whisper.",
"main": "main.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/CreateNewAudioNoteInNewFileModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ export class CreateNewAudioNoteInNewFileModal extends FuzzySuggestModal<TFile> {
const url = urlInput.value;
const urlParts = url.split("/");
const lastPart = urlParts[urlParts.length - 1];
const title = lastPart.split("?")[0].replace(/.mp3/g, "");
let title = lastPart.split("?")[0];
if (title.includes(".mp3")) {
title = title.replace(/.mp3/g, "");
} else if (title.includes(".m4b")) {
title = title.replace(/.m4b/g, "");
} else if (title.includes(".m4a")) {
title = title.replace(/.m4a/g, "");
}
const newNoteFilename = title + ".md";
this.createNewAudioNoteFile(url, newNoteFilename, title);
this.close();
Expand Down
4 changes: 2 additions & 2 deletions src/EnqueueAudioModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class EnqueueAudioModal extends Modal {
.onClick(() => {
if (select.value && this.url) {
const splitUrl = this.url.split("?");
const endsWithMp3 = splitUrl[0].endsWith(".mp3");
const endsWithMp3 = splitUrl[0].endsWith(".mp3") || splitUrl[0].endsWith(".m4b") || splitUrl[0].endsWith(".m4a");
if (endsWithMp3) {
// Make the request to enqueue the item
request({
Expand All @@ -93,7 +93,7 @@ export class EnqueueAudioModal extends Modal {
this.close();
});
} else {
new Notice("Make sure your URL is an .mp3 file. It should end in .mp3 (excluding everything after an optional question mark).", 10000)
new Notice("Make sure your URL is an .mp3, .m4b, or .m4a file. It should end in one of those extensions (excluding everything after an optional question mark).", 10000)
}
} else {
new Notice("Please specify a .mp3 URL and an accuracy level.")
Expand Down

0 comments on commit a889e6e

Please sign in to comment.