jdepoix / youtube-transcript-api

This is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require an API key nor a headless browser, like other selenium based solutions do!
MIT License
2.55k stars 280 forks source link

Please add video title & link option to CLI Thanks #217

Closed BillionShields closed 6 months ago

BillionShields commented 11 months ago

Discussed in https://github.com/jdepoix/youtube-transcript-api/discussions/216

Originally posted by **BillionShields** July 21, 2023 Would be awesome if in 1st 2 lines of transcript you can include title and full URL to the video Example ================ The Growing Megafire Crisis – and How to Contain It | George T. Whitesides | TED https://www.youtube.com/watch?v=M66jkJMH3DI My wife grew up in Santa Rosa, California, and her best friend was a woman named Joy Durand who lived on the northeast outskirts of town. At midnight on the evening of October 8, 2017, Joy's telephone ran.....
jdepoix commented 11 months ago

Hi @BillionShields, thank you for your suggestion! Could you please elaborate what the usecase for this is and why you think this would be a good change? This would break the current API and I don't really see how this would add enough value to warrant a breaking change. Since you know the ID of the video you are retrieving the transcript for, the URL can easily be deduced anyways, so you wouldn't need this module to retrieve the URL. For retrieving the title, there are plenty of other ways to do to that. I try to keep the scope of this module concise (subtitles/transcript), so I am generally not too fond of adding retrieval of metadata which is out of that scope, unless I see a good usecase within that scope, which requires that data.

graphicmist commented 8 months ago

Would you accept a PR change request for an additional param which parses the response and returns a concise extracted information?

jdepoix commented 8 months ago

@graphicmist If you can propose a solution which doesn't break the current API and doesn't need additional requests, I would consider it.

xts-bit commented 8 months ago

@jdepoix Any option to provide it a youtube video link instead of video_Id, Anyways how to use video_id?

jdepoix commented 8 months ago

@xts-bit I don't think your question is related to this issue.

This module only works with video IDs, not with URLs. You can easily parse the video ID out of the youtube URL. However, there are many different ways YouTube URLs can be structured and I don't think it should be part of this module to support them all. For most use cases you will only work with one format anyways so it is much more reliable if you as the user of the module parse the ID as required for your usecase. For example, it could look something like this:

from urllib.parse import urlparse, parse_qs
video_url = "https://www.youtube.com/watch?v=video123"
video_id = parse_qs(urlparse(video_url).query).get("v")
jdepoix commented 6 months ago

Closed due to inactivity