saved.js
1 import { cli } from '@jackwener/opencli/registry'; 2 cli({ 3 site: 'instagram', 4 name: 'saved', 5 description: 'Get your saved Instagram posts', 6 domain: 'www.instagram.com', 7 args: [ 8 { name: 'limit', type: 'int', default: 20, help: 'Number of saved posts' }, 9 ], 10 columns: ['index', 'user', 'caption', 'likes', 'comments', 'type'], 11 pipeline: [ 12 { navigate: 'https://www.instagram.com' }, 13 { evaluate: `(async () => { 14 const limit = \${{ args.limit }}; 15 const res = await fetch( 16 'https://www.instagram.com/api/v1/feed/saved/posts/', 17 { 18 credentials: 'include', 19 headers: { 'X-IG-App-ID': '936619743392459' } 20 } 21 ); 22 if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram'); 23 const data = await res.json(); 24 return (data?.items || []).slice(0, limit).map((item, i) => { 25 const m = item?.media; 26 return { 27 index: i + 1, 28 user: m?.user?.username || '', 29 caption: (m?.caption?.text || '').replace(/\\n/g, ' ').substring(0, 100), 30 likes: m?.like_count ?? 0, 31 comments: m?.comment_count ?? 0, 32 type: m?.media_type === 1 ? 'photo' : m?.media_type === 2 ? 'video' : 'carousel', 33 }; 34 }); 35 })() 36 ` }, 37 ], 38 });