Forum

Thread tagged as: Question, Problem
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have curl enabled?

Yes curl is enabled.

URL support enabled
cURL Information    7.38.0
Age 3
Features
AsynchDNS   No
Debug   No
GSS-Negotiate   No
IDN Yes
IPv6    Yes
Largefile   Yes
NTLM    Yes
SPNEGO  No
SSL Yes
SSPI    No
krb4    No
libz    Yes
CharConv    No
Protocols   dict, file, ftp, ftps, gopher, http, https, imap, imaps, pop3, pop3s, rtsp, smtp, smtps, telnet, tftp
Host    x86_64-unknown-linux-gnu
SSL Version OpenSSL/1.0.1e
ZLib Version    1.2.3
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are your servers certificates for SSL up to date?

The site isn't running under SSL? The SSL for my server address are all up to date. Local setup I don't have any SSL or certificates?

Drew McLellan

Drew McLellan 2638 points
Perch Support

YouTube uses SSL, so to connect you need up to date certificate information on your server, just like your browser does.

Just to confirm Drew, in order to use the YouTube fieldtype you need to be running the website under SSL with it's own certificate? Or have I misunderstood?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You've misunderstood entirely.

The server does have up to date certificates. I think this illustrates? https://www.ssllabs.com/ssltest/analyze.html?d=amasci.uk&latest

Or am I on the wrong lines still?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's nothing to do with visitors accessing your site. I'm talking about your server accessing the YouTube API as a client.

I don't think I'm going to be able to help you with this. We'll monitor the issue in case it's reported again.

So i feel like an epic idiot on this one because I just checked my google console and it seems my Youtube API wasn't enabled... moving on... Now I'm getting data returned when using the output tag (not locally though)

Terry, maybe double check the Youtube installation and configuration - https://docs.grabaperch.com/addons/field-types/youtube/

On another note, it seems 'thumbnail' returns the default 120px version. Is there a way to return one of the higher quality images? eg hqdefault or maxresdefault etc?

Yes! Egg and Face here too.... I had two issues with my API.
1. For some reason my bloody server IP was missing?
2. I had an extra character at the end of my API Key in my config file.

I am still unable to get this working locally though (any ideas on this Drew). Which is a shame as it is easier to develop. But glad it is working on Server.

Thanks for the heads up chaps and for investigating Drew. Always going to be a PEBCAK.

Drew, one more question on this. How do I get the thumb output to be medium or high rather than default? Default is a little small (120x90px) so wanted to get the medium or high res version of the thumb?

https://developers.google.com/youtube/v3/docs/thumbnails#high

Terry Upton said:

Drew, one more question on this. How do I get the thumb output to be medium or high rather than default? Default is a little small (120x90px) so wanted to get the medium or high res version of the thumb?

https://developers.google.com/youtube/v3/docs/thumbnails#high

Drew, not sure if you missed this - but is it possible to get the large or medium thumbnails?

I saw this in the fieldtype

$thumb_key = 'high';
               if (isset($item['snippet']['thumbnails']['maxres'])) {
                    $thumb_key = 'maxres';
               }

But wasn't sure how it would/should be applied?

Drew McLellan

Drew McLellan 2638 points
Perch Support

We're just selecting the largest thumbnail that is available.

It looks like it is selecting the default thumbnail, which I think is the smallest? I only get the default version output in my template. On the docs it says you can choose from Default, Medium and High Res?

https://developers.google.com/youtube/v3/docs/thumbnails#high

The default thumbnail image for this resource. The default thumbnail for a video – or a resource that refers to a video, such as a playlist item or search result – is 120px wide and 90px tall.

medium object A higher resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 320px wide and 180px tall. For a channel, this image is 240px wide and 240px tall.

high object A high resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 480px wide and 360px tall. For a channel, this image is 800px wide and 800px tall.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can choose from them if they're available for the video in question. We try to pick the largest available.

I think perhaps there is a slight issue or bug. As only the image being pulled in for each video is default. For example; https://i.ytimg.com/vi/QN7AN9whIlE/default.jpg

But there is a bigger version - see
https://i.ytimg.com/vi/QN7AN9whIlE/hqdefault.jpg

or a medium version
https://i.ytimg.com/vi/QN7AN9whIlE/mqdefault.jpg

and max res version
https://i.ytimg.com/vi/QN7AN9whIlE/maxresdefault.jpg

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's always possible.

Drew McLellan said:

You can choose from them if they're available for the video in question. We try to pick the largest available.

How?

The docs just say output="thumb" but all I ever get is the 120px version :(

Julian, I have tweaked the YouTube field type. The revised file can be downloaded here;

The part I updated was as follows;

               $thumb_key = 'medium';
               if (isset($item['snippet']['thumbnails']['medium'])) {
                    $thumb_key = 'medium';
               } else {
                $thumb_key = 'default';
               }


               $out['thumb']         = $item['snippet']['thumbnails'][$thumb_key]['url'];
               $out['thumb_w']       = $item['snippet']['thumbnails'][$thumb_key]['width'];
               $out['thumb_h']       = $item['snippet']['thumbnails'][$thumb_key]['height'];

I have set my thumb_key to medium as this is what I wanted to get out, but you can set this to either large, maxres or default.

Drew, the original file works just need the code swapping around a little and an else statement added to fallback to the default. I believe it was checking the thumb_key AFTER it had already output the thumbnail image. So a switch around made it work.

Might be nice to enhance it so that you can set the size you want to output in the template though? So you can set it to pass in either, default, medium, large or maxres...?