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

Downloading subtitles using python script #15685

Closed
aringhosh opened this issue Feb 23, 2018 · 4 comments
Closed

Downloading subtitles using python script #15685

aringhosh opened this issue Feb 23, 2018 · 4 comments

Comments

@aringhosh
Copy link

@aringhosh aringhosh commented Feb 23, 2018

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like this: [x])
  • Use the Preview tab to see what your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2018.02.22. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2018.02.22

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones
  • Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

Description of your issue, suggested solution and other information

Explanation of your issue in arbitrary form goes here. Please make sure the description is worded well enough to be understood. Provide as much context and examples as possible.
If work on your issue requires account credentials please provide them or explain how one can obtain them.

I am trying to write a python program which can download the automatic subtitle of a given youtube video. However, it is not downloading anything. Probably I am messing up with the options. Can someone please show me the correct way to do this? I have attached my python file.

from __future__ import unicode_literals
import youtube_dl


class MyLogger(object):
    def debug(self, msg):
        pass

    def warning(self, msg):
        pass

    def error(self, msg):
        print(msg)


def my_hook(d):
    print(d)
    if d['status'] == 'finished':
        print('Done downloading, now converting ...')


ydl_opts = {
    'simulate': True,
    'logger': MyLogger(),
    'progress_hooks': [my_hook],
    'subtitleslangs': 'en',
    'writeautomaticsub': True,
}


with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=Ye8mB6VsUHw'])
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 23, 2018

-s, --simulate Do not download the video and do not write
anything to disk

@dstftw dstftw closed this Feb 23, 2018
@aringhosh
Copy link
Author

@aringhosh aringhosh commented Feb 23, 2018

Thank you @dstftw , I get it that --simulate won't work.
But what combination of options will work for the above case? This still don't work, My objective is to download the subtitle and I don't need the video

ydl_opts = {
    # 'simulate': True,
    'skip_download': True,
    'logger': MyLogger(),
    'progress_hooks': [my_hook],
    'subtitleslangs': 'en',
    'writeautomaticsub': True,
}
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 23, 2018

Provide verbose logs as clearly stated in the issue template.

@aringhosh
Copy link
Author

@aringhosh aringhosh commented Feb 23, 2018

Here's the verbose I am getting @dstftw

ydl_opts = {
    'verbose': True,
    'skip_download': True,
    'logger': MyLogger(),
    'progress_hooks': [my_hook],
    'subtitleslangs': 'en',
    'writeautomaticsub': True,
}
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.02.22
[debug] Python version 3.6.2 (CPython) - Darwin-17.4.0-x86_64-i386-64bit
[debug] exe versions: none
[debug] Proxy map: {}
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.