Giter VIP home page Giter VIP logo

starise / youtube-transcript-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jdepoix/youtube-transcript-api

0.0 2.0 0.0 66 KB

This is an python API which allows you to get the transcripts/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do!

License: MIT License

Python 100.00%

youtube-transcript-api's Introduction

YouTube Transcript/Subtitle API (including automatically generated subtitles)

This is an python API which allows you to get the transcripts/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do!

Install

It is recommended to install this module by using pip:

pip install youtube_transcript_api

If you want to use it from source, you'll have to install the dependencies manually:

pip install -r requirements.txt

How to use it

You could either integrate this module into an existing application, or just use it via an CLI

In code

To get a transcript for a given video you can do:

from youtube_transcript_api import YouTubeTranscriptApi

YouTubeTranscriptApi.get_transcript(video_id)

This will return a list of dictionaries looking somewhat like this:

[
    {
        'text': 'Hey there',
        'start': 7.58,
        'duration': 6.13
    },
    {
        'text': 'how are you',
        'start': 14.08,
        'duration': 7.58
    },
    # ...
]

To get transcripts for a list fo video ids you can call:

YouTubeTranscriptApi.get_transcripts(video_ids)

CLI

Execute the CLI script using the video ids as parameters and the results will be printed out to the command line:

youtube_transcript_api <first_video_id> <second_video_id> ...

If you would prefer to write it into a file or pipe it into another application, you can also output the results as json using the following line:

youtube_transcript_api --json <first_video_id> <second_video_id> ... > transcripts.json

Warning

This code uses an undocumented part of the YouTube API, which is called by the YouTube web-client. So there is no guarantee that it won't stop working tomorrow, if they change how things work. I will however do my best to make things working again as soon as possible if that happens. So if it stops working, let me know!

youtube-transcript-api's People

Contributors

jdepoix avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.