Skip to content

Commit 0aabb17

Browse files
committed
chore: added audio downloader debug
1 parent 128dbb7 commit 0aabb17

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/audioDownloader/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ async function getGeneratingAudioUrlsDataFromIframe(
9898
const isTimeout =
9999
err instanceof Error && err.message === GET_AUDIO_DATA_ERROR_MESSAGE;
100100

101+
debug.log("getGeneratingAudioUrlsDataFromIframe error", err);
101102
throw new Error(
102103
isTimeout
103104
? GET_AUDIO_DATA_ERROR_MESSAGE

src/ui/views/settings.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import SliderLabel from "../components/sliderLabel";
1616
import Textfield from "../components/textfield";
1717
import Tooltip from "../components/tooltip";
1818

19+
import { VideoService } from "@vot.js/ext/types/service";
1920
import { type VideoHandler, countryCode } from "../..";
21+
import { AudioDownloader } from "../../audioDownloader";
2022
import {
2123
authServerUrl,
2224
defaultAutoHideDelay,
@@ -1189,6 +1191,46 @@ export class SettingsView {
11891191
updateLocaleFilesButton,
11901192
);
11911193

1194+
if (
1195+
DEBUG_MODE &&
1196+
this.videoHandler &&
1197+
this.videoHandler?.site.host === VideoService.youtube
1198+
) {
1199+
// ! Available only in debug mode, translation phrase doesn't need
1200+
const debugDownloadAudio = ui.createOutlinedButton(
1201+
"[YT | DEBUG] Download Audio",
1202+
);
1203+
debugDownloadAudio.addEventListener("click", async () => {
1204+
if (!this.videoHandler?.videoData) {
1205+
return;
1206+
}
1207+
1208+
const audioDownloader = new AudioDownloader();
1209+
audioDownloader
1210+
.addEventListener(
1211+
"downloadedAudio",
1212+
async (translationId, data) => {
1213+
debug.log("Audio downloaded:", translationId, data);
1214+
},
1215+
)
1216+
.addEventListener(
1217+
"downloadedPartialAudio",
1218+
async (translationId, data) => {
1219+
debug.log("Partial audio downloaded:", translationId, data);
1220+
},
1221+
)
1222+
.addEventListener("downloadAudioError", (videoId) => {
1223+
debug.log("Audio download error for videoId:", videoId);
1224+
});
1225+
await audioDownloader.runAudioDownload(
1226+
this.videoHandler.videoData.videoId,
1227+
"debug-mode",
1228+
new AbortController().signal,
1229+
);
1230+
});
1231+
dialog.bodyContainer.appendChild(debugDownloadAudio);
1232+
}
1233+
11921234
updateLocaleFilesButton.addEventListener("click", async () => {
11931235
await votStorage.set("localeHash", "");
11941236
await localizationProvider.update(true);

0 commit comments

Comments
 (0)