Jump to content

Youtube And Vimeo Thumbnail Grabber


adrian
 Share

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      FieldtypeQRCode
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      Options
      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Formatting
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      Examples
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
×
×
  • Create New...