Merge pull request #4804 from nonamethanks/fix-lofter-second-theme

Lofter: fix strategy for additional type of html theme
This commit is contained in:
evazion
2021-05-23 11:07:31 -05:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

View File

@@ -10,6 +10,7 @@
# Page URLs
#
# * https://gengar563.lofter.com/post/1e82da8c_1c98dae1b
# * https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d (different theme/css selectors)
#
# Profile URLs
#
@@ -45,7 +46,7 @@ module Sources
end
def image_urls
images = page&.search(".pic img")
images = page&.search(".pic img, .content img")
images.to_a.map { |img| get_full_version(img["src"]) }
end
@@ -73,7 +74,7 @@ module Sources
end
def tags
tags = page&.search(".info .tag")
tags = page&.search(".info .tag, .main .tag a")
tags.to_a.map do |tag|
[tag.text, tag.attr("href")]
@@ -81,7 +82,7 @@ module Sources
end
def artist_commentary_desc
page&.search(".ct .text")&.to_html
page&.search(".ct .text, .content .text").to_a.compact.first&.to_html
end
def normalize_for_source

View File

@@ -44,6 +44,14 @@ module Sources
end
end
context "A different CSS schema" do
should "still find all the data" do
source = Sources::Strategies.find("https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d")
assert_equal(["https://imglf5.lf127.net/img/Mm55d3lNK2tJUWpNTjVLN0MvaTRDc1UvQUFLMGszOHRvSjV6S3VSa1lwa3BDWUtVOWpBTHBnPT0.jpg"], source.image_urls)
assert_not_empty(source.tags)
end
end
context "A bad link" do
should "correctly get the full size" do
source = Sources::Strategies.find("https://imglf4.lf127.net/img/S1d2QlVsWkJhSW1qcnpIS0ZSa3ZJUFczb2RKSVlpMHJkNy9kc3BSQVQvQm5DNzB4eVhxay9nPT0.png?imageView&thumbnail=1680x0&quality=96&stripmeta=0")