Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

youtube subtitle doesn't work #5049

Closed
dattaz opened this issue Feb 24, 2015 · 2 comments
Closed

youtube subtitle doesn't work #5049

dattaz opened this issue Feb 24, 2015 · 2 comments

Comments

@dattaz
Copy link

@dattaz dattaz commented Feb 24, 2015

subtitles item in dict is always as none with python api
My code :

!/usr/bin/env python

-- coding: utf-8 --

import youtube_dl

def getdata(url):
with youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s'}) as ydl:
result = ydl.extract_info(url, download=False)
url = result['url']
title = result['title']
thumbnail = result.get('thumbnail')
#print('url: %r, title: %r, thumbnail: %r' % (url, title, thumbnail))
# writecvs(url, title, tags)
print result
print "-------------------------------------"
print result.get('subtitles')
getdata('https://www.youtube.com/watch?v=I4jqq4Tml1s')

I have try video with auto-subtitle and real subtitle

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Feb 24, 2015

You'll have to add the writesubtitles parameter:

import youtube_dl
def getdata(url):
    with youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s', 'writesubtitles': True}) as ydl:
        result = ydl.extract_info(url, download=False)
        url = result['url']
        title = result['title']
        thumbnail = result.get('thumbnail')
        #print('url: %r, title: %r, thumbnail: %r' % (url, title, thumbnail))
        # writecvs(url, title, tags)
        print result
        print "-------------------------------------"
        print result.get('subtitles')
getdata('https://www.youtube.com/watch?v=I4jqq4Tml1s')

Youtube subtitles info is only extracted with that option because it requires an additional request, so it will take some more time to complete the extraction.

@jaimeMF jaimeMF closed this Feb 24, 2015
@dattaz
Copy link
Author

@dattaz dattaz commented Feb 24, 2015

thanks a lot, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.