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

Transcript retrieval is broken #4

Open
KTibow opened this issue Jan 3, 2025 · 1 comment · May be fixed by #5
Open

Transcript retrieval is broken #4

KTibow opened this issue Jan 3, 2025 · 1 comment · May be fixed by #5

Comments

@KTibow
Copy link

KTibow commented Jan 3, 2025

I'm getting an error like

Error: Could not retrieve a transcript for the video https://www.youtube.com/watch?v=[...] This is most likely caused by: Subtitles are disabled for this video If you are sure that the described cause is not responsible for this error and that a transcript should be retrievable, please create an issue at https://github.com/jdepoix/youtube-transcript-api/issues. Please add which version of youtube_transcript_api you are using and provide the information needed to replicate the error. Also make sure that there are no open issues which already describe your problem! 

for every video I try.

@vacmar01
Copy link
Owner

vacmar01 commented Jan 3, 2025

Thank you for bringing this up. I'm currently on vacation, but I will look into it when I'm back home.

UltimateBoi added a commit to UltimateBoi/youtube2anki that referenced this issue Jan 15, 2025
Fixes vacmar01#4

Fix transcript retrieval error for YouTube videos.

* Add a try-except block in `get_transcript` method in `y2a/clients.py` to catch `YouTubeTranscriptApi.CouldNotRetrieveTranscript` exception and log a warning if subtitles are disabled.
* Modify `create_or_get_video` method in `cards/models.py` to handle empty transcripts by setting `transcript` field to "No transcript available" if the transcript is empty.
* Update error handling in `generate` view in `cards/views.py` to display a user-friendly message if transcript retrieval fails by setting `context['error']` to "Transcript not available for this video" if the transcript is "No transcript available".

Possible solution that may have caused crashes due to videos having transcript / closed captions disabled.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/vacmar01/youtube2anki/issues/4?shareId=XXXX-XXXX-XXXX-XXXX).
@UltimateBoi UltimateBoi linked a pull request Jan 15, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants