|
|
@ -88,11 +88,11 @@ def main_function(url, options): |
|
|
|
|
|
|
|
|
|
|
|
# Get video transcript |
|
|
|
# Get video transcript |
|
|
|
try: |
|
|
|
try: |
|
|
|
transcript_list = YouTubeTranscriptApi.get_transcript(video_id) |
|
|
|
transcript_list = YouTubeTranscriptApi.get_transcript(video_id, languages=[options.lang]) |
|
|
|
transcript_text = " ".join([item["text"] for item in transcript_list]) |
|
|
|
transcript_text = " ".join([item["text"] for item in transcript_list]) |
|
|
|
transcript_text = transcript_text.replace("\n", " ") |
|
|
|
transcript_text = transcript_text.replace("\n", " ") |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
transcript_text = f"Transcript not available. ({e})" |
|
|
|
transcript_text = f"Transcript not available in the selected language ({options.lang}). ({e})" |
|
|
|
|
|
|
|
|
|
|
|
# Get comments if the flag is set |
|
|
|
# Get comments if the flag is set |
|
|
|
comments = [] |
|
|
|
comments = [] |
|
|
@ -126,6 +126,7 @@ def main(): |
|
|
|
parser.add_argument('--duration', action='store_true', help='Output only the duration') |
|
|
|
parser.add_argument('--duration', action='store_true', help='Output only the duration') |
|
|
|
parser.add_argument('--transcript', action='store_true', help='Output only the transcript') |
|
|
|
parser.add_argument('--transcript', action='store_true', help='Output only the transcript') |
|
|
|
parser.add_argument('--comments', action='store_true', help='Output the comments on the video') |
|
|
|
parser.add_argument('--comments', action='store_true', help='Output the comments on the video') |
|
|
|
|
|
|
|
parser.add_argument('--lang', default='en', help='Language for the transcript (default: English)') |
|
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args() |
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
|
|
|
|