This is how I solved it, if it comes in handy for someone else later.
//Function to fetch the YouTube Id, Video Id, Title and Views
function getDom(className) {
if(className == '.yt-lockup-byline' || className == '.yt-lockup-title') {
var items = $(className).find('a');
} else if(className == '.yt-lockup-meta-info') {
var items = $(className).find('li');
}
var length = items.length;
var position = -1;
var obj_b = next();
function next() {
position = (position + 1 < length) ? position + 1 : 0;
return items.eq(position);
}
if (className == '.yt-lockup-byline') {
$.each(obj_b.prevObject, function() {
var str_result = this.attributes[2].nodeValue;
console.log("YouTube ID :- "+str_result);
});
} else if (className == '.yt-lockup-meta-info') {
$.each(obj_b.prevObject, function() {
var str_result = this.innerHTML;
console.log("Views :- "+str_result);
});
} else if (className == '.yt-lockup-title') {
$.each(obj_b.prevObject, function() {
var str_result = this.attributes[3].nodeValue;
var str_video_id = this.attributes[0].nodeValue;
console.log("YouTube Title :- "+str_result);
console.log("YouTube Video ID :- "+str_video_id);
});
}
}
//For fetching YotuTube Id
getDom('.yt-lockup-byline');
//For fetching views and release date
getDom('.yt-lockup-meta-info');
//For fetching title and video id
getDom('.yt-lockup-title');