Simple js only module to search YouTube Doesn't need any login or GoogleAPI key
const ytsr = require('ytsr');
let filter;
ytsr.getFilters('github', function(err, filters) {
if(err) throw err;
filter = filters.get('Type').find(o => o.name === 'Video');
ytsr.getFilters(filter.ref, function(err, filters) {
if(err) throw err;
filter = filters.get('Duration').find(o => o.name.startsWith('Short'));
var options = {
limit: 5,
nextpageRef: filter.ref,
}
ytsr(null, options, function(err, searchResults) {
if(err) throw err;
dosth(searchResults);
});
});
});
Searches for the given string
-
searchString
- string to search for
-
options
- object with options
- possible settings:
- limit[integer] -> limits the pulled items
- nextpageRef[String] -> if u wanna continue a previous search or use filters
-
callback(err, result)
- function
- getting fired after the request is done
- contains an error or a result
-
returns a Promise when no callback is defined
Pulls avaible filters for the given string/ref
-
searchString
- string to search for
- or previously optained filter ref
-
callback(err, result)
- function
- getting fired after the request is done
- contains an error or a result
-
returns a Promise when no callback is defined
npm install --save ytsr
MIT