Skip to content

Commit

Permalink
Fixed escaped chars
Browse files Browse the repository at this point in the history
  • Loading branch information
lstrzepek committed Sep 11, 2024
1 parent 4050ad5 commit 5689e3c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "ytranscript",
"name": "YTranscript",
"version": "0.9.2",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "This is simple plugin to fetch transcription for Youtube.",
"author": "Łukasz Strzępek",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-ytranscript",
"version": "0.9.2",
"version": "1.0.0",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
17 changes: 13 additions & 4 deletions src/fetch-transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class YoutubeTranscript {
) {
try {
const langCode = config?.lang ?? "en";
console.log(url);

const videoPageBody = await request(url);
const parsedBody = parse(videoPageBody);
Expand Down Expand Up @@ -73,16 +72,26 @@ export class YoutubeTranscript {
) ?? availableCaptions?.[0];

const captionsUrl = captionTrack?.baseUrl;
const fixedCaptionsUrl = captionsUrl.startsWith('https://') ? captionsUrl : "https://www.youtube.com" + captionsUrl;
const fixedCaptionsUrl = captionsUrl.startsWith("https://")
? captionsUrl
: "https://www.youtube.com" + captionsUrl;

const resXML = await request(fixedCaptionsUrl).then((xml) => parse(xml));
const resXML = await request(fixedCaptionsUrl).then((xml) =>
parse(xml),
);

const chunks = resXML.getElementsByTagName("text");

return {
title: title,
lines: chunks.map((cue: any) => ({
text: cue.textContent.replaceAll("'", "'"),
text: cue.textContent
.replaceAll("'", "'")
.replaceAll("&", "&")
.replaceAll(""", '"')
.replaceAll("'", "'")
.replaceAll("&lt;", "<")
.replaceAll("&gt;", ">"),
duration: parseFloat(cue.attributes.dur) * 1000,
offset: parseFloat(cue.attributes.start) * 1000,
})),
Expand Down

0 comments on commit 5689e3c

Please sign in to comment.