async function uploadVideoToYouTube(video, channelId) { const videoMetadata = { snippet: { title: video.title, description: video.description, tags: video.tags || [], categoryId: '22' // Typically "People & Blogs" }, status: { privacyStatus: 'private' // Upload as private first } }; try { // First download the video from Instagram const videoResponse = await fetch(`/api/instagram/download?id=${video.id}`, { headers: { 'Authorization': `Bearer ${accessToken}` } }); if (!videoResponse.ok) throw new Error('Failed to download video'); const videoBlob = await videoResponse.blob(); // Upload to YouTube const uploadResponse = await gapi.client.youtube.videos.insert({ part: 'snippet,status', resource: videoMetadata, media: { body: videoBlob } }); return uploadResponse.result; } catch (error) { console.error('Error uploading video:', error); throw error; } }
Automatically download Instagram videos and upload to your YouTube channel
Enter the Instagram username without @
Choose which YouTube channel to upload to