simple user
simple user

Reputation: 383

How to manage the private YouTube videos in Video Embed Field

I have used "video_embed" field in my site to add videos from Youtube. Everything is working fine but I am doubtful on the way to implementing these two points using Video Embed Module:-

  1. Inside YouTube there are two kind of videos - one is private and other is public. There is no problem in displaying public videos in site. However when I add private YouTube videos in the site then "video_embed" does not render and show empty Video Player. This is OK but I want to stop at the save level.Currently user add YouTube URL in the textbox using FORM API. If user enters private YouTube URL in the form then I need piece of logic to check if the Youtube video is private or not and stop saving there.
  2. As part of second scenario user adds YouTube videos to my site. Now if the video has been deleted in Youtube or the URL not working after some time then is there any way to recognize those videos and delete from my site as well.

These are the basic two questions whose answer will help me in maintaining my site.

Upvotes: 1

Views: 262

Answers (1)

Bustikiller
Bustikiller

Reputation: 2508

You could implement hook_node_presave() to inject some code that should be executed before saving (new or edited) nodes. The code implementing this hook should perform a request to the Youtube API to find out the current status of the video.

In addition, you could schedule a cron task to check the status of all videos regularly, in order to remove them if they have been deleted / set private after the node insertion.

Upvotes: 0

Related Questions