YouTube Integration with CQ5

31 / Jul / 2014 by Vivek Dhiman 1 comments

Managing multimedia content to any large scale website is much complicated if the content is dynamic and needs to be changed at regular intervals. Integration of YouTube with CQ5 is one of the use case which can help authors to manage the channel specific videos for particular page related with particular channel.

Below is the snapshot how this solution will work:

UseCase

1)      Create the configuration page for specific channel under the cloud service page of  Youtube .

createconfig

2)      Create a dialog which will accept Channel ID, API Key & Target Path (Store location in DAM) & link this to the YouTube cloud service. This will validate the Google Key/ Channel Id. On success it will configure the cloud service with that channel.

service

3)      Our dialog is configured with some hidden widgets which cause the creation of polling node just below the jcr:content of cloud service page. This binds our cloud service with one channel correspond to polling node which will invoke the generic importer.

importer

Listener will set values of polling node when we click OK.

polling

4)       Now the polling node will poll the youtube service

[html]

https://www.googleapis.com/youtube/v3/search?key=”+ key+ “
&part=snippet,id&order=date&maxResults=50&type=video
&channelId=”+ channelId + “&pageToken=” + pageToken

[/html]

via importers (A custom servlet YoutubeChannelImporter.java)

5)     Our importer is responsible for storing videos in DAM at target path which we have specified in step 2

6)      After execution of importer, we can check the nodes under target path which are assets that refer to YouTube videos for specific channel.

imageres

7) Now we need to customize the content finder to create a new tab which will show the YouTube videos stored under DAM.

How to create new contentfiner tab in CQ5.

8)  Create a servlet AssetViewHandler which render the videos from DAM to content finder tab on the request basis for particular page. We can use OOTB servlet available in package com.day.cq.wcm.core.impl.servlets.contentfinder with some changes as we are fetching assets on page basis.

9) Now click on the page properties and select the cloud service for specific channel & save.

cloudservice

10) Open the en.html page, you can find the new tab in content finder with YouTube icon. And here all the videos are populated from DAM. Add the component YouTube to parsys which use the iframe, it uses the YouTube video’s id.

component1

11) Just drag and drop the video on the Youtube component.

image

GitHub link : https://github.com/IntelligrapeAEM/IgWebCMS

Hope this helps!!!
Vivek Dhiman

FOUND THIS USEFUL? SHARE IT

comments (1 “YouTube Integration with CQ5”)

  1. housing housingnew

    Vivek – I need to pick the top posted videos from a page and do not have to bring them to DAM. If show the snippet on a page, user clicks and go to youtube. What would be the best way?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *