Coder Social home page Coder Social logo

getyoutubecc's Introduction

NOTE: NOT WORKING!!!!!!

Youtube changed the API so this script is outdated and not working... Not planing on fixing it anytime soon. Sorry

As an alternative use youtube-dl with the --write-auto-sub option (thanks to coderholic)

DESCRIPTION

This class allows you to download the caption from a video from you tube It support: - Downloading a track if video has multiple tracks (you have to know the name of the track) - Automatic translation to another language

PYTHON CLASS USAGE

Example:
        >>> import getyoutubecc
        #import the library
        >>> cc = getyoutubecc.getyoutubecc('2XraaWefBd8','en')
        # Now in cc.caption_obj are the parsed captions, its syntax is like:
        # [{'texlines': [u"caption first line", 'caption second line'],
        #    'time': {'hours':'1', 'min':'2','sec':44,'msec':232} }]
        # Modify the caption as you want if desired
        >>> cc.writeSrtFile('captionsfile.srt')
        #write the contents to a srt file
     
     Notes:
       MULTITRACK VIDEO
       if video is a multitrack video (or the track has a name) you need
       to specify the name of the track:
        >>> cc = getyoutubecc.getyoutubecc('pNiFoYt69-w','fr','french')
       TRANSLATE VIDEO
       if you prefer the automatic translation to another language use 
       the lang code
        >>> cc = getyoutubecc.getyoutubecc('pNiFoYt69-w','fr','french', tlang:'es')

COMMAND LINE USAGE

If you prefer the command line version of this, or just to test it:

        $ ./getyoutubecc.py -h
        getyoutubecc -v <video_id> -l <language_id> [-t <track_name>] [-T <translate_to>]
        Example: getyoutubecc -v pNiFoYt69-w -l fr -t french -T es
        Example: getyoutubecc -v 2XraaWefBd8 -l en 
        NOTE: if video has a track name, the -t argument is mandatory 

OPTIONS:

-v --videoid        Video id. Like 2XraaWefBd8. It appears in every youtube URL
-l --language       iso lang code. Like en, es, fr..
-t --track          The name of the track if video has several. You will have to find out
                    this name in the youtube page of the video
-T --translate      iso lang code. Like en,es, fr of the language you want to tranlate to

COPYRIGHT

this code is released into the public domain by the copyright holders.

TODO

  • Test the code, different languages in diferent videos for instance
  • Improve regular expresion
  • Add support for the automatic generate captions service in youtube

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.