GithubHelp home page GithubHelp logo

profanitas / ytsapi Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 15 KB

YouTube Transcribe API for The Abuse Project

Python 100.00%
youtube-api youtube-downloader theabuseproject video-downloader python-library python3

ytsapi's Introduction

YTSAPI

YTSAPI (YouTube Transcribe API) for The Abuse Project is a python API (Application Programming Interface) which allows you to get the transcript/subtitle for a given YouTube video in a nice list consisting of dictionaries. It also works for videos which have automatically generated subtitles. It does not use any hacky mechanisms.

Install

For using this library in your project, simple use pip to install the module.

pip install ytsapi

The module published is in it's early stage as of now, as it's being used internally in The Abuse Project. If you want to develop it further, you'll have to use this source repository.

git clone https://github.com/theabuseproject/YTSAPI.git

After cloning, install the dependencies using pip,

pip install -r requirements.txt

Usage

The implemented API class can be found under ytsapi/ytsapi.py.

import ytsapi
ytsapi.YTSAPI.get_transcript("Youtube Video ID")

Example Usage

Obtaining transcript of a YouTube video

>>> import ytsapi
>>> video = 'http://www.youtube.com/watch?v=BaW_jenozKc'
>>> video_id = video.split('?v=')[1]
>>> video_subtitles = ytsapi.YTSAPI.get_transcript(video_id)
>>> print(video_subtitles)
[{'text': 'This a test video\nfor youtube-dl', 'start': 0.26, 'duration': 3.33}, {'text': 'For more information\ncontact [email protected]', 'start': 3.59, 'duration': 6.08}]
>>>
>>> type(video_subtitles)
<class 'list'>
>>> type(video_subtitles[0])
<class 'dict'>
>>>

Downloading a YouTube video

>>> import ytsapi
>>> ytsapi.YTSAPI.get_video('BaW_jenozKc')
YoutubeDL - Starting the download (BaW_jenozKc)
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
WARNING: Unable to extract video title
[download] BaW_jenozKc.mp4 has already been downloaded
[download] 100% of 1.74MiB
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
WARNING: Unable to extract video title
[download] BaW_jenozKc.mp4 has already been downloaded
[download] 100% of 1.74MiB
YoutubeDL - Writing video in current working directory.
YoutubeDL - Done.
>>>

ytsapi's People

Contributors

0x48piraj avatar aniketchaudhari3 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ytsapi's Issues

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.