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

get url in python #20347

Closed
Zipdox opened this issue Mar 14, 2019 · 1 comment
Closed

get url in python #20347

Zipdox opened this issue Mar 14, 2019 · 1 comment

Comments

@Zipdox
Copy link

@Zipdox Zipdox commented Mar 14, 2019

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 2019.03.09. 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 2019.03.09

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

I'm writing a python script and I need to get the direct URL in a variable.
I did this but it prints the URL on screen and doesn't end up in the variable.

from __future__ import unicode_literals
import youtube_dl



ydl_opts = {
    'format': 'bestaudio/best',
    'forceurl': 'yes',
    'skip_download': 'yes',
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    url = ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
    print('link:')
    print(str(url))
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Mar 14, 2019

This is expected behavior of forceurl. You must use extract_info.

@dstftw dstftw closed this Mar 14, 2019
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.