YouTube Jquery Scripts for getting video data

DataMine
by DataMine · 2 posts
8 years ago in Javascript
Posted 8 years ago · Author
About
These are some bits of jquery code I wrote in order to amass data for new content system here: viewtopic.php?t=10794

They get the video title and ids of YouTube videos to be processed in one of my programs and turned into multi dimensional arrays for php.

For information on running jquery on YouTube: http://stackoverflow.com/questions/7474 ... pt-console

To use these codes, simply open up your browsers console and paste these codes into the code editor.


This code will build a list of video ids and title from the search results page
[code=jquery file=Untitled.txt]//This scripts grabs the video title and video id for each video on a search results page
jQuery('.item-section > li').each(function() {
//Get the video title
var title = jQuery(this).find('.yt-lockup-title ').text();

//Clean the video title by removing unnecessary data at the end and condensing it down to single spacing
title = title.substring(0,title.lastIndexOf('-')).replace(/\s\s+/g, " ");

//Get the video id by getting the video url and removing pathing
var id = jQuery(this).find('.yt-lockup-title a').attr('href').replace("/watch?v=","");

//Output the resulting title into the sonsole for copying
console.log(title + "," + id);
});[/code]

This code will build a list of video ids and title from the playlist box on a video page
[code=jquery file=Untitled.txt]//This scripts grabs the video title and video id for each video in a playlist box
jQuery('#playlist-autoscroll-list > li').each(function() {
var id = jQuery(this).find('.yt-thumb-clip img').attr('src').replace("//i.ytimg.com/vi/","").replace("/default.jpg","");

//Grab the video title and replace all line breaks with spaces and condense multi spacing into single spacing
var title = jQuery(this).find('.playlist-video-description > h4').text().replace(/\n/g," ").replace(/\s\s+/g, " ").replace(" ,",",");

//Output the resulting title into the sonsole for copying
console.log(title + "," + id);
});[/code]
Posted 7 years ago
:dancingbannana: hell yeah !

Create an account or sign in to comment

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

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

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

REGISTER A NEW ACCOUNT