0

I am trying to create a chrome extension which transcribes a Youtube video into text allowing the user to save time. In order to obtain the transcript of the specific video, I use an external Python API called the 'youtube-transcript-api' which returns a dictionary and I then convert it into JSON so that my javascript can access it.

from youtube_transcript_api import YouTubeTranscriptApi
import json

# assigning srt variable with the list of dictonaries
# obtained by the the .get_transcript() function
# and this time it gets only teh subtitles that
# are of english langauge.
srt = YouTubeTranscriptApi.get_transcript("TA_Wk53oHT8",
                                       languages=['en'])


# writing the json file 
out_file = open("subtitles.json", "w")
out_file.truncate(0) # emptying the contents of the JSON file
json.dump(srt, out_file, indent = 4, sort_keys = False)
out_file.close()

The javascript then parses the JSON and displays it on the page.

I want to use this Python + JavaScript in a chrome extension while also using the external youtube-transcript-api. How to do so by providing step-by-step instructions including the permissions required in the manifest.json file by the external python api? I am new and just in high school.

I have spent days googling but can't come up with a solution.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Check out this link. https://pythonspot.com/create-a-chrome-plugin-with-python/ it may help you – TheFishTheySay Aug 06 '21 at 04:41
  • Read the documentation for [nativeMessaging](https://3-72-0-dot-chrome-apps-doc.appspot.com/extensions/nativeMessaging) and then see the [example](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/mv2-archive/api/nativeMessaging). – wOxxOm Aug 06 '21 at 10:26

0 Answers0