Jump to content

Youtube And Vimeo Thumbnail Grabber


adrian

Recommended Posts

Sorry about that.

I have a quick fix for you. Replace line#113 with this:

$videoID = strpos($matches[2][$key],'#') !== false ? strstr($matches[2][$key], '#', true) : $matches[2][$key];

I need to get a more complete fix though because there are other ways to define the start time, but haven't got time right now as I want to check out all the options for vimeo as well.

This should get you going in the meantime though.

  • Like 2
Link to comment
Share on other sites

Sorry about that.

I have a quick fix for you. Replace line#113 with this:

$videoID = strpos($matches[2][$key],'#') !== false ? strstr($matches[2][$key], '#', true) : $matches[2][$key];

I need to get a more complete fix though because there are other ways to define the start time, but haven't got time right now as I want to check out all the options for vimeo as well.

This should get you going in the meantime though.

Ok, thanks Adrian :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi Ralf,

Glad you are enjoying using it.

I just tested it with:


and it works fine for me.

See attached screenshot

post-985-0-62822300-1399394283_thumb.png

Can you see anything different that you think might be affecting things?

Link to comment
Share on other sites

I have just updated this module with better support for video links that have a start time and other additional parameters in the url. It also now supports embed links and other variations.

Please let me know if you find any issues with this new version.

  • Like 3
Link to comment
Share on other sites

Hey adrian - quick question - what about supporting getting the video title? I used to have clients put in the youtube ID and then i could get the thumbnail and the video title from yt api at runtime, but now i'm using your module since i prefer storing the poster image locally; but now i can't get the title of the video unless i somehow regex out the video id from the URL..

tia!

Link to comment
Share on other sites

last i checked this was still working:

<?php 
	
	$id = $video->youtube_video_id; // this needs to be the ID
	
	$content = file_get_contents("http://youtube.com/get_video_info?video_id=".$id);
	
	parse_str($content, $ytarr);
	
	echo stripslashes($ytarr['title']);  // title of video
Link to comment
Share on other sites

Yeah, that is still working, but from a quick read I get the feeling it won't be in the future, but not certain. I did read something that suggested that maybe basic info like the title will still be available this way. Maybe I should just go with this for now and adapt later if needed. I might go with curl though to avoid issues with get_file_contents and those on hosts with allow_url_fopen disabled.

  • Like 1
Link to comment
Share on other sites

Ok, so I have added support for automatic populating the video title into the image description field for both Youtube and Vimeo. Not sure how much longer this method will work with Youtube, but I think it's simpler to keep using v2 of their API for the moment. I implemented both cURL and file_get_contents methods for Youtube and simplexml_load_file for Vimeo.

Let me know how it works for everyone and I'll tweak methods if needed.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Actually, that was an oversight on my part. I have just committed an update so that GetVideoThumbs now supports CropImage fieldtypes, and any other fieldtypes that are an instanceof FieldtypeImage. Before I was limiting it just to FieldtypeImage. 

Let me know if it works ok for you.

As for the configuration options of CropImage - ie changing the fieldtype (basics tab) vs the inputfield (details tab). I haven't tested, but I always assumed you needed to change both. Might be a more appropriate question for the support thread for that module though.

Still had to report back...

Everything works as expected... thank you for that!

Regards!

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

What a superb module. I'm using it conjunction with Ryan's youtube and vimeo module.

I just thought i'd post this error message i occasionally  get. However, it doesn't stop the module working and everything appears correct regardless:

Error: Call to a member function children() on a non-object (line 145 of /var/www/clients/client2/web37/web/site/modules/GetVideoThumbs-master/ProcessGetVideoThumbs.module)

This error message was shown because you are logged in as a Superuser. Error has been logged. 
Link to comment
Share on other sites

Hi davo,

Thanks for the kudos. That error is part of the recently added functionality to grab the video title and add it to the image's description field.

Do you know whether it occurs randomly with the same video, or does it happen only with certain videos? It's an easy check to prevent the error, but I am curious as to why the entry item is sometimes not available in the YouTube xml feed.

Also, I noticed that you have the module installed under: GetVideoThumbs-master

It's unfortunate that Github does this, but it suggests to me that you are manually downloading modules, so I thought I'd suggest using the Download and Install functionality under the New tab in PW's module page. You'd simply paste in "ProcessGetVideoThumbs" into there and it would download and install everything for you automatically. This also means that you can then use the automatic updating when a new version of a module is released because it will be installed in the correct folder. Then of course there is also Soma's modules manager which makes things even easier: http://modules.processwire.com/modules/modules-manager/

Link to comment
Share on other sites

Unfortunately, I'd already gone past the offending video so can't recall which one threw the error. The thumbnail certainly downloads ok, I'll have to go back and check to see if all the titles have also been pulled. All the videos are youtube videos. It's only happened twice on about forty videos. I have about ten more to go so I'll let you know if it happens again.

Have I installed the module in the wrong folder?

Hi davo,

Thanks for the kudos. That error is part of the recently added functionality to grab the video title and add it to the image's description field.

Do you know whether it occurs randomly with the same video, or does it happen only with certain videos? It's an easy check to prevent the error, but I am curious as to why the entry item is sometimes not available in the YouTube xml feed.

Also, I noticed that you have the module installed under: GetVideoThumbs-master

It's unfortunate that Github does this, but it suggests to me that you are manually downloading modules, so I thought I'd suggest using the Download and Install functionality under the New tab in PW's module page. You'd simply paste in "ProcessGetVideoThumbs" into there and it would download and install everything for you automatically. This also means that you can then use the automatic updating when a new version of a module is released because it will be installed in the correct folder. Then of course there is also Soma's modules manager which makes things even easier: http://modules.processwire.com/modules/modules-manager/

Link to comment
Share on other sites

davo - I have committed an update which should take care of the error and also try another method to get the title if the first one fails.

Please let me know if you notice any problems with this new version or if the error shows up again.

As for whether you have installed it in the wrong folder - it won't stop it working, but it is not the intended folder due to the addition of "master" by github when downloading zip files.

Link to comment
Share on other sites

ok cheers. I'll give it a try.

As I'm obvioudly running an older version of pw, would it be best to remove the core pw files, add in the latest pw files. Then uninstall the module and reinstall it via the pw search and install method?

Link to comment
Share on other sites

Not sure what version you are running. If it's < 2.4 then you should definitely upgrade. Lots of us are running the latest dev version - currently 2.4.3. However 2.5 is probably not very far away either if you are more comfortable with officially stable versions.

In general it is easier to install modules via one of the automated methods, but at times you may want to try out modules that aren't yet in the modules directory, so you'll need to rely on downloading from Github and installing manually - just be aware in future to remove the -master part of the folder name.

Thanks for letting me know how this new version goes.

Link to comment
Share on other sites

Not sure what version you are running. If it's < 2.4 then you should definitely upgrade. Lots of us are running the latest dev version - currently 2.4.3. However 2.5 is probably not very far away either if you are more comfortable with officially stable versions.

In general it is easier to install modules via one of the automated methods, but at times you may want to try out modules that aren't yet in the modules directory, so you'll need to rely on downloading from Github and installing manually - just be aware in future to remove the -master part of the folder name.

Thanks for letting me know how this new version goes.

I tried to do the upgrade an all went well until upgrading the module and now the site has gone off line. I've started a new thread here:

https://processwire.com/talk/topic/6608-upgrade-issue/

Link to comment
Share on other sites

Went to modules,  ProcessGetVideoThumbs

Clicked the upgrade to latest version.

 

It through an error that I don't remember  :(

 

Now all the site produces is the internal server error.

 

The previous version I was using 2.3.something so not an old one..

 

I'm sure this is an easy fix, but what is the likely cause and what should I do to repair it please?

I am thinking this is probably due to the change of install folder for this module. Did you uninstall and remove the version you had installed in the GetVideoThumbs-master folder before installing the new version?

If you are still getting the internal server error, I would first remove all the video module folders from the modules directory and see if that solves it. If not, you might need to go into PHPMyAdmin and remove the entries for this module from the modules DB table. Please let me know if you are not familiar with this and I'll give you some step by step instructions.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...