webshot_test.js 5.1 KB

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const path = require("path");
  4. const webshot_1 = require("./webshot");
  5. const config = require(path.resolve('./config.json'));
  6. const cookies = [];
  7. try {
  8. cookies.push(...require(path.resolve('./webshot_cookies.json')));
  9. }
  10. catch (_a) {
  11. console.warn('no webshot_cookies.json, proceeding to capture without cookies');
  12. }
  13. const twitter = [
  14. { taken_at: 1621924987, pk: '2581216338441119423', id: '2581216338441119423_44417763068', device_timestamp: '1621924644902829', media_type: 8, code: 'CPSUpV9N6a_', client_cache_key: 'MjU4MTIxNjMzODQ0MTExOTQyMw==.2', filter_type: 0, carousel_media_count: 2, carousel_media: [{ id: '2581216334238381632_44417763068', media_type: 1, image_versions2: { candidates: [{ width: 1080, height: 1080, url: 'https://scontent-frt3-2.cdninstagram.com/v/t51.2885-15/e35/s1080x1080/190746834_305880047711439_1238677858420966077_n.jpg?tp=1&_nc_ht=scontent-frt3-2.cdninstagram.com&_nc_cat=103&_nc_ohc=5rrKbdowQiwAX_huVNN&edm=ALQROFkBAAAA&ccb=7-4&oh=3f11e17ab93ac27e0f519d4c93c0b03f&oe=60B3581A&_nc_sid=30a2ef&ig_cache_key=MjU4MTIxNjMzNDIzODM4MTYzMg%3D%3D.2-ccb7-4', scans_profile: 'e35', estimated_scans_sizes: [16392, 32784, 49176, 65568, 81960, 91713, 116708, 132645, 147528] }, { width: 360, height: 360, url: 'https://scontent-frt3-2.cdninstagram.com/v/t51.2885-15/e35/s360x360/190746834_305880047711439_1238677858420966077_n.jpg?tp=1&_nc_ht=scontent-frt3-2.cdninstagram.com&_nc_cat=103&_nc_ohc=5rrKbdowQiwAX_huVNN&edm=ALQROFkBAAAA&ccb=7-4&oh=3b2261065eeb42b4a66f86c08ef33f00&oe=60B31936&_nc_sid=30a2ef&ig_cache_key=MjU4MTIxNjMzNDIzODM4MTYzMg%3D%3D.2-ccb7-4', scans_profile: 'e35', estimated_scans_sizes: [2869, 5739, 8609, 11478, 14348, 17274, 498509, 25827, 25827] }] }, original_width: 1440, original_height: 1440, pk: '2581216334238381632', carousel_parent_id: '2581216338441119423_44417763068', can_see_insights_as_brand: false, sharing_friction_info: { should_have_sharing_friction: false, bloks_app_url: null } }, { id: '2581216334221669977_44417763068', media_type: 1, image_versions2: { candidates: [{ width: 1080, height: 1080, url: 'https://scontent-frt3-2.cdninstagram.com/v/t51.2885-15/e35/s1080x1080/191567565_117731327146678_5748332914724407042_n.jpg?tp=1&_nc_ht=scontent-frt3-2.cdninstagram.com&_nc_cat=110&_nc_ohc=44Txge0DTWQAX90l1wu&edm=ALQROFkBAAAA&ccb=7-4&oh=a5c55f601722495acb92228c9fae0c8b&oe=60B41433&_nc_sid=30a2ef&ig_cache_key=MjU4MTIxNjMzNDIyMTY2OTk3Nw%3D%3D.2-ccb7-4', scans_profile: 'e35', estimated_scans_sizes: [14958, 29916, 44874, 59832, 74791, 83691, 106500, 121042, 134624] }, { width: 360, height: 360, url: 'https://scontent-frt3-2.cdninstagram.com/v/t51.2885-15/e35/s360x360/191567565_117731327146678_5748332914724407042_n.jpg?tp=1&_nc_ht=scontent-frt3-2.cdninstagram.com&_nc_cat=110&_nc_ohc=44Txge0DTWQAX90l1wu&edm=ALQROFkBAAAA&ccb=7-4&oh=03b21be9a79a0b8c49fc45f7abdd794b&oe=60B4B69F&_nc_sid=30a2ef&ig_cache_key=MjU4MTIxNjMzNDIyMTY2OTk3Nw%3D%3D.2-ccb7-4', scans_profile: 'e35', estimated_scans_sizes: [2762, 5524, 8286, 11048, 13810, 16627, 479838, 24859, 24859] }] }, original_width: 1440, original_height: 1440, pk: '2581216334221669977', carousel_parent_id: '2581216338441119423_44417763068', can_see_insights_as_brand: false, sharing_friction_info: { should_have_sharing_friction: false, bloks_app_url: null } }], user: { pk: 44417763068, username: 'yoshioka_mayuc', full_name: '吉岡茉祐', is_private: false, profile_pic_url: 'https://scontent-frx5-1.cdninstagram.com/v/t51.2885-19/s150x150/123601327_2808566602748728_8801779503881262018_n.jpg?tp=1&_nc_ht=scontent-frx5-1.cdninstagram.com&_nc_ohc=3WIXXH0VqRIAX_LqZRc&edm=ALQROFkBAAAA&ccb=7-4&oh=ef381592bf5162e5396d2da6dd45bef3&oe=60B498A6&_nc_sid=30a2ef', profile_pic_id: '2436311751362218490_44417763068' }, caption: { pk: '17869742171406631', user_id: 44417763068, text: '撮影時のオフショット。\n\n#ヨシオカとホンイズミ の撮影した日のオフショット集です。\n多分まだある。\n\n屋上のあるスタジオをお借りして撮影しました。\n半日だけど衣装もかなり並べて(半分ほんちゃんの私物)着せ替え人形になりました。\nありがてえ。\n 私のセンスじゃここまでオシャレにならんのよ。\n\n何でもない日にオフショ集あげる予定なので、よかったら見てってくださいな。\nついでに、YouTubeチャンネルの方も、よろしくお願いします☺️\n最近は動画内で鍋食べて ます。\n\n#撮影 \n#屋上 \n#オフショット \n#おしゃれに撮りたい', type: 1, created_at: 1621924988, created_at_utc: 1621924988, content_type: 'comment', status: 'Active' }, product_type: 'carousel_container' },
  15. ];
  16. (new webshot_1.default(config.playwright_ws_spec_endpoint, 0, () => cookies))(twitter.map(item => ({ pk: item.pk, item: () => Promise.resolve(item) })), messageChain => {
  17. const media = messageChain.match(/(?<=\[CQ:(?:image|video).*file:\/\/)[^,\]]*/g);
  18. if (media) {
  19. media.forEach((path, index) => {
  20. console.log(`saved media file #${index} at ${path}`);
  21. });
  22. }
  23. }, 15000);