misskey-dev / summaly

🔍 Get a summary of any web page
MIT License
22 stars 10 forks source link

oembedのjsonにhtmlが含まれてないとエラーになる #20

Open anatawa12 opened 11 months ago

anatawa12 commented 11 months ago

https://oembed.com/ 曰くhtmlは必須なので、ない方が悪いですがエラーになって取得できませんになってしまいます。

real world example: https://adventar.org/calendars/9018


TypeError: Cannot read properties of undefined (reading 'startsWith')
    at getOEmbedPlayer (file:///Users/anatawa12/IdeaProjects/summaly/built/general.js:43:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 1)
    at async default (file:///Users/anatawa12/IdeaProjects/summaly/built/general.js:194:28)
    at async summaly (file:///Users/anatawa12/IdeaProjects/summaly/built/index.js:37:21)
    at async Object.<anonymous> (file:///Users/anatawa12/IdeaProjects/summaly/built/index.js:54:29)
yulog commented 8 months ago

今見るとhtmlは含まれるようですが、終端が</iframe>\nとなっています。

{
  "version": "1.0",
  "width": "100%",
  "height": 437,
  "type": "rich",
  "provider_name": "Adventar",
  "provider_url": "https://adventar.org",
  "url": "https://adventar.org/calendars/9018/embed",
  "html": "<iframe src=\"https://adventar.org/calendars/9018/embed\" width=\"100%\" height=\"437\"></iframe>\n"
}

現在のコードだと終端が\nだとoEmbedの対象外になってそうです。

https://github.com/misskey-dev/summaly/blob/71fe234d3e4541a60ce279ba794a3c370553ed88/src/general.ts#L47-L50