Lofter: add support for another theme

This commit is contained in:
nonamethanks
2021-07-12 19:07:52 +02:00
committed by evazion
parent 716b9a5b88
commit bb4bdefc23
2 changed files with 11 additions and 6 deletions

View File

@@ -11,6 +11,7 @@
#
# * https://gengar563.lofter.com/post/1e82da8c_1c98dae1b
# * https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d (different theme/css selectors)
# * https://ssucrose.lofter.com/post/1d30f3e4_1cc58e9f0 (another different theme)
#
# Profile URLs
#
@@ -46,7 +47,7 @@ module Sources
end
def image_urls
images = page&.search(".pic img, .content img")
images = page&.search(".imgclasstag img")
images.to_a.map { |img| get_full_version(img["src"]) }
end
@@ -74,7 +75,7 @@ module Sources
end
def tags
tags = page&.search(".info .tag, .main .tag a")
tags = page&.search(".info .tag, .main .tag a, .tagarea")
tags.to_a.map do |tag|
[tag.text, tag.attr("href")]

View File

@@ -1,4 +1,4 @@
require 'test_helper'
require "test_helper"
module Sources
class LofterTest < ActiveSupport::TestCase
@@ -46,9 +46,13 @@ module Sources
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)
source1 = Sources::Strategies.find("https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d")
source2 = Sources::Strategies.find("https://ssucrose.lofter.com/post/1d30f3e4_1cc58e9f0")
assert_equal(["https://imglf5.lf127.net/img/Mm55d3lNK2tJUWpNTjVLN0MvaTRDc1UvQUFLMGszOHRvSjV6S3VSa1lwa3BDWUtVOWpBTHBnPT0.jpg"], source1.image_urls)
assert_not_empty(source1.tags)
assert_equal(["https://imglf5.lf127.net/img/d052Q09DWkVNMVJwZm9rNURwNHdPcjlzRFlQc1BmTXArSG9TdXdJZnlCbUpEYnZJTHUwTGRRPT0.jpg"], source2.image_urls)
end
end