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

Using forcethumbnail=true and Download=False using python #5008

Closed
enricoluigi opened this issue Feb 20, 2015 · 1 comment
Closed

Using forcethumbnail=true and Download=False using python #5008

enricoluigi opened this issue Feb 20, 2015 · 1 comment

Comments

@enricoluigi
Copy link

@enricoluigi enricoluigi commented Feb 20, 2015

Im pretty sure this is not the right place to post but i couldnt find an oficial forum or group.

im trying to get the thumbnail url from a video using python, how do i do that?
this is my code wich shows the Url and Title:

def getdata(url)
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s'})
result = ydl.extract_info(url,download=False)
url = result['url']
title = result['title']
writecvs(url, title, tags)

Thanks and sorry for posting in the wrong place.

@enricoluigi enricoluigi changed the title Need help, this is not an issue. Using forcethumbnail=true and Download=False using python Feb 20, 2015
@phihag
Copy link
Contributor

@phihag phihag commented Feb 20, 2015

This is the right place to post - what made you think otherwise?

You can simply look into the thumbnail property. Bear in mind that unlike id or title, it may be None or unset. That happens if the service does not provide a thumbnail, doesn't support thumbnails at all, or youtube-dl doesn't correctly extract the thumbnail (in the latter case, feel free to create a new bug report, provided you are using the latest version).

The following code works fine for me:

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)

getdata('http://www.youtube.com/watch?v=BaW_jenozKc')

I am closing this issue now, since the code works fine for me. If there is still a problem, please say so and we will reopen it. Thanks!

@phihag phihag closed this Feb 20, 2015
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.