From e95731d58f0cbdac1541beeac176080ff475c8fd Mon Sep 17 00:00:00 2001 From: nonamethanks Date: Tue, 4 May 2021 21:18:12 +0200 Subject: [PATCH] Skeb: fix broken strategy --- app/logical/sources/strategies/skeb.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/logical/sources/strategies/skeb.rb b/app/logical/sources/strategies/skeb.rb index 90fdc9859..7feeeef2b 100644 --- a/app/logical/sources/strategies/skeb.rb +++ b/app/logical/sources/strategies/skeb.rb @@ -44,7 +44,10 @@ module Sources if url =~ IMAGE_URL [url] elsif page.present? - [page.text[/window\.__NUXT__=.*,preview_url:"(.*?)",/, 1].gsub("\\u002F", "/")] + # Heavy heuristic to extract the uncropped image among the nighmare that is the skeb minified json + candidates = page&.css("script")&.map { |script| script.text&.scan(/(https:\\u002F\\u002Fskeb\.imgix\.net.*?)(?:"|,|\s)/) } + candidates = candidates.to_a.flatten.compact.uniq.reject { |match| match.include? "crop=" } + [candidates.first.gsub("\\u002F", "/")] else [] end