I need to know if youtube API V3 supports searching inside a specific youtube playlist? And is there any other way to do that?
You can also use the CTRL + F keyboard shortcut on a PC or COMMAND + F on a Mac to open a search bar for the playlist specifically to search for an artist or song in a long playlist.
To find YouTube Music playlists: Visit youtube.com/music on a web browser. Search for 'Music channel' in the YouTube mobile app. select the YouTube Music channel.
You can go to the Library tab to view all of your playlists. You can also manage your playlists in YouTube Studio. If a video or channel's audience is "made for kids" and you're on a homepage, you can't add it to a playlist. You can still add content from search results into playlists.
I have read the YouTuBe API documentation regarding requests on playlists and they don't provide such functionality, however you could use this npm module to achieve that:
npm install youtube-playlist-search
or
yarn install youtube-playlist-search
The way to use it is something like this on javascript:
var search = require('youtube-playlist-search');
var params = {
part: 'snippet,contentDetails',
maxResults: 25,
key: 'your_api_key'
};
search('searchTerm', params, function(err, videos) {
if(err) return console.log(err);
console.dir(videos);
});
Or you can also take a look here where I'm using it with React, the code it will be something like:
import _ from 'lodash';
import YTSearch from 'youtube-playlist-search';
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import SearchBar from './components/search_bar';
import VideoList from './components/video_list';
import VideoDetail from './components/video_detail';
class App extends Component {
constructor(props) {
super(props);
this.state = {
videos: [],
selectedVideo: null
};
this.key = process.env.REACT_APP_YTB_API_KEY_DEV
if (process.env.NODE_ENV === 'production') {
this.key = process.env.REACT_APP_YTB_API_KEY_PROD
}
this.params = {
part: 'snippet,contentDetails',
playlistId: 'PLH99prTh-VPqO7ld0o2Sny6bLxpf80Js0',
key: this.key
};
this.videoSearch('')
}
videoSearch(term) {
YTSearch(term, this.params, (err, videos) => {
this.setState({
videos: videos,
selectedVideo: videos[0]
});
});
}
render() {
const videoSearch = _.debounce((term) => {this.videoSearch(term)}, 300);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<SearchBar onSearchTermChange={videoSearch}/>
<VideoDetail video={this.state.selectedVideo}/>
<VideoList
onVideoSelect={selectedVideo => this.setState({selectedVideo})}
videos={this.state.videos}/>
</div>
);
}
}
export default App;
For doing full-text search in closed captions (CC) in a Youtube channel you may download all the subtitles from the channel and do local text search in it:
$ youtube-dl --write-auto-sub --skip-download "https://www.youtube.com/channel/UC6oh54zIYKyW6hgBiZzLLsA"
that will download about 160 .vtt text files
$ grep -i -C 2 'autumn' *.vtt
Note: Option --write-auto-sub
should be used when author of videos didn't upload text.
Otherwise use --write-sub
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With