Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_handleSearchSubmit = q => {
const query = q;
if (ytdl.validateURL(query)) {
const videoId = ytdl.getVideoID(query);
AppInstance.startInPlayer([{ videoId }]);
} else {
AppInstance.startSearch(query);
}
database.insertSearchHistory(new Date().getTime(), query).catch(e => console.error(e));
};
const AppInstance = props.AppInstance;
[shouldFetchCurrent ? trackCurrent : {}, ...tracksToRight, ...tracksToLeft].map((item, index) => {
if (item.videoId && ytdl.validateID(item.videoId)) {
this._ytdlGetInfo(
item.videoId,
info => {
console.log(JSON.stringify(info));
const highestQualityAudio = this._filterHighestQualityAudio(info.formats);
this._updateTrackPlayerQueueItem(
tracks,
item,
{
url: highestQualityAudio,
title: info.title,
artist: info.author.name,
artwork: info.thumbnail_url,
},
_handleSearchSubmit = q => {
const query = q;
if (ytdl.validateURL(query)) {
const videoId = ytdl.getVideoID(query);
AppInstance.startInPlayer([{ videoId }]);
} else {
AppInstance.startSearch(query);
}
database.insertSearchHistory(new Date().getTime(), query).catch(e => console.error(e));
};
const AppInstance = props.AppInstance;
_filterHighestQualityAudio = formats => {
let audioFormats = ytdl.filterFormats(formats, 'audioonly');
let highestFormat = audioFormats[0];
audioFormats.map(item => {
if (highestFormat.audioBitrate < item.audioBitrate) highestFormat = item;
});
const highestQualityAudio = highestFormat.url;
return highestQualityAudio;
};
_ytdlGetInfo = (videoId, callback, errCallback) => {
_ytdlGetInfo = (videoId, callback, errCallback) => {
ytdl.getInfo(videoId, {}, (err, info) => {
if (err) errCallback(err);
callback(info);
});
};
_getHighestQualityAudioUsingYtdl = (videoId, callback, errCallback) => {