From 4d009568fd44401fb883588f112713b26f0ed3e8 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 26 Aug 2022 01:12:23 -0500 Subject: [PATCH] Fix #5165: add support for weibo share urls --- app/logical/source/url/weibo.rb | 5 +++++ test/unit/sources/weibo_test.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/logical/source/url/weibo.rb b/app/logical/source/url/weibo.rb index 88e81ded8..eda999966 100644 --- a/app/logical/source/url/weibo.rb +++ b/app/logical/source/url/weibo.rb @@ -50,6 +50,11 @@ class Source::URL::Weibo < Source::URL in _, "detail", /^\d+$/ => illust_long_id @illust_long_id = illust_long_id + # https://share.api.weibo.cn/share/304950356,4767694689143828.html + # https://share.api.weibo.cn/share/304950356,4767694689143828 + in "share.api.weibo.cn", "share", /^(\d+),(\d+)/ + @illust_long_id = $2 + # https://m.weibo.cn/status/J33G4tH1B in "m.weibo.cn", "status", /^\w+$/ => illust_base62_id @illust_base62_id = illust_base62_id diff --git a/test/unit/sources/weibo_test.rb b/test/unit/sources/weibo_test.rb index d033bd820..7f108a6f1 100644 --- a/test/unit/sources/weibo_test.rb +++ b/test/unit/sources/weibo_test.rb @@ -112,6 +112,18 @@ module Sources end end + context "A share.api.weibo.cn/share/:id URL" do + strategy_should_work( + "https://share.api.weibo.cn/share/304950356,4767694689143828.html", + image_urls: ["https://wx3.sinaimg.cn/large/007bspzxly1h23na4y0hhj32982pinpd.jpg"], + download_size: 1_781_330, + artist_name: "号布谷鸟", + artist_commentary_desc: "#快递组# 摸了 ", + profile_url: "https://www.weibo.com/u/6582241007", + tags: ["快递组"] + ) + end + should "Parse Weibo URLs correctly" do assert_equal("https://www.weibo.com/3150932560/H4cFbeKKA", Source::URL.page_url("https://www.weibo.com/3150932560/H4cFbeKKA?from=page_1005053150932560_profile&wvr=6&mod=weibotime")) assert_equal("https://m.weibo.cn/detail/4242129997905387", Source::URL.page_url("https://photo.weibo.com/2125874520/wbphotos/large/mid/4242129997905387/pid/7eb64558ly1friyzhj44lj20dw2qxe81"))