Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT WORKİNG AT ALL #15

Open
Medullitus opened this issue May 27, 2024 · 7 comments
Open

NOT WORKİNG AT ALL #15

Medullitus opened this issue May 27, 2024 · 7 comments

Comments

@Medullitus
Copy link

When I try to add YT video url and push the "Generate summary" button it gives me error! The error is that "Error: [YoutubeTranscript] TypeError: Cannot read properties of undefinied (reading 'transcriptBodyRenderer'). So I can't use the plugin...

@jeffscottward
Copy link

Same. Just tried now

@mariusursache
Copy link

Does not work for me either.

@hardchor
Copy link

hardchor commented Jun 3, 2024

See langchain-ai/langchainjs#4994

@rshmhrj
Copy link

rshmhrj commented Jul 14, 2024

@Medullitus thanks for opening this issue -- I was also experiencing it, but haven't had time to dig in or debug
@hardchor -- thanks for the reference link -- very helpful!

@ozdemir08 I started looking into this today.

I updated my local package.json with the latest version of youtube-transcript "youtube-transcript": "^1.2.1" and ran some tests:

Created a new test.mjs file:

import { YoutubeTranscript } from "youtube-transcript";
YoutubeTranscript.fetchTranscript("https://www.youtube.com/watch?v=nJ660t5ku9A").then(console.log);

And ran it with node src/test.mjs and was able to get the transcript data back -- no issues.

While running it in the plugin loaded in Obsidian though, I'm seeing a CORS error:
image

This fetch from YoutubeTranscript seems to be failing:
image

I found one possible solution, but haven't tried it out yet: https://github.com/wanadev/obsidian-http-request -- this runs a proxy and wraps the requests so that CORS errors are bypassed. Implementing this would probably require us to bring in the fetchTranscript functionality from YoutubeTranscript, which I don't really like.

@hardchor @ozdemir08 & others -- do you have any suggestions?

@rshmhrj
Copy link

rshmhrj commented Jul 25, 2024

FYI: Just created this issue in the YoutubeTranscript repo

I think we can resolve the new CORS error by making the fetch using obsidian.request and piping the output to YoutubeTranscript but they'll need to expose some parseTranscript function for us to call.

Will create a PR there and see how it goes.

@rshmhrj
Copy link

rshmhrj commented Jul 30, 2024

YoutubeTranscript Pull Request created here: Kakulukian/youtube-transcript#35
@ozdemir08 @hardchor & others - please review

Once these changes are in, then TranscriptSummarizer.ts can be updated with this:

import { request } from "obsidian";
...
export class TranscriptSummarizer {
...
  async getSummaryFromUrl(url: string): Promise<string> {
  ...
  const ytt = new ObsidianYoutubeTranscript(url);
  const transcriptList = await ytt.fetchTranscript();
  ...
  }
...
}

class ObsidianYoutubeTranscript extends YoutubeTranscript {
	videoId: string;
	videoPageBody: string;
	transcriptBody: string;

	constructor(videoId: string) {
		super();
		this.videoId = YoutubeTranscript.retrieveVideoId(videoId);
	}

	public async getPageBody(): Promise<string> {
		const videoPageResponse = await request(
			`https://www.youtube.com/watch?v=${this.videoId}`
		);
		this.videoPageBody = videoPageResponse;
		return this.videoPageBody;
	}

	public async getTranscriptResponse(transcriptURL: string): Promise<string> {
		const transcriptResponse = await request(transcriptURL);
		this.transcriptBody = transcriptResponse;
		return this.transcriptBody;
	}
}

And the plugin seems to work:
image

@KoBruh
Copy link

KoBruh commented Jan 1, 2025

Hey ! has this been fixed / added yet ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants