IFTTT Filter Code / Fix Not no_image_card
by microbians
JavaScript
let imageURL: string = Raindrop.raindropsTags.ThumbnailUrl.replace("f=webp","f=jpg");
let noImage: string = 'no_image_card';
let videoUrl: string = Raindrop.raindropsTags.Url;
let defaultThumbnailURL: string = "https://yourtsitegoeshere.com/youtdefaultthumbnail.jpg";
// Función para generar la URL de la miniatura de Vimeo Thumbnails
function getVimeoThumbnailUrl(videoUrl: string): string {
let videoIdIndex = videoUrl.lastIndexOf('/') + 1;
let videoId = videoUrl.substring(videoIdIndex);
return `https://vumbnail.com/${videoId}.jpg`;
}
// Utilizar Vimeo Thumbnails para obtener la miniatura del video de Vimeo
if (imageURL.indexOf(noImage) !== -1 ) {
if(videoUrl.indexOf('vimeo.com') !== -1) {
// No hay imagen y es un video de Vimeo
let vimeoThumbnailUrl = getVimeoThumbnailUrl(videoUrl);
Twitter.postNewTweetWithImage.setPhotoUrl(vimeoThumbnailUrl);
} else if (videoUrl.indexOf('youtube.com') !== -1) {
// No hay imagen y es un video de YouTube
let videoIdIndex = videoUrl.indexOf('v=') + 2;
let videoIdSubstring = videoUrl.substring(videoIdIndex);
let videoId: string | null = videoIdSubstring ? videoIdSubstring.substr(0, 11) : null;
if (videoId) {
let youtubeThumbnailUrl: string = 'https://img.youtube.com/vi/' + videoId + '/maxresdefault.jpg';
Twitter.postNewTweetWithImage.setPhotoUrl(youtubeThumbnailUrl);
} else {
Twitter.postNewTweetWithImage.setPhotoUrl(defaultThumbnailURL);
}
} else {
Twitter.postNewTweetWithImage.setPhotoUrl(defaultThumbnailURL);
}
} else {
Twitter.postNewTweetWithImage.setPhotoUrl(imageURL);
}