|
1 | 1 | import * as fs from "fs-extra";
|
2 | 2 | import FileType, { FileTypeResult } from "file-type";
|
3 |
| -import axios from "axios"; |
4 | 3 | import { makeImagePersistencePlan } from "./MakeImagePersistencePlan";
|
5 | 4 | import { warning, logDebug, verbose, info } from "./log";
|
6 | 5 | import { ListBlockChildrenResponseResult } from "notion-to-md/build/types";
|
@@ -150,10 +149,15 @@ async function processImageBlock(
|
150 | 149 | async function readPrimaryImage(imageSet: ImageSet) {
|
151 | 150 | // In Mar 2024, we started having a problem getting a particular gif from imgur using
|
152 | 151 | // node-fetch. Switching to axios resolved it. I don't know why.
|
153 |
| - const response = await axios.get(imageSet.primaryUrl, { |
154 |
| - responseType: "arraybuffer", |
155 |
| - }); |
156 |
| - imageSet.primaryBuffer = Buffer.from(response.data, "utf-8"); |
| 152 | + // Then, in Apr 2025, we started getting 429 responses from imgur through axios, |
| 153 | + // so we switched to node's built-in fetch (different than the node-fetch package). |
| 154 | + // Just a guess, but probably imgur keeps locking down what it suspects as code running |
| 155 | + // to scrape images. |
| 156 | + // Apparently, imgur is getting to be more and more of a liability, |
| 157 | + // so we should probably stop using it. |
| 158 | + const response = await fetch(imageSet.primaryUrl); |
| 159 | + const arrayBuffer = await response.arrayBuffer(); |
| 160 | + imageSet.primaryBuffer = Buffer.from(arrayBuffer); |
157 | 161 | imageSet.fileType = await FileType.fromBuffer(imageSet.primaryBuffer);
|
158 | 162 | }
|
159 | 163 |
|
|
0 commit comments