Add stub for SB story metadata extraction
This commit is contained in:
parent
7458599ac2
commit
886a387740
1 changed files with 33 additions and 2 deletions
|
|
@ -123,9 +123,40 @@ module FicTracker::Backends::Spacebattles
|
||||||
private
|
private
|
||||||
|
|
||||||
def extract_story(page)
|
def extract_story(page)
|
||||||
|
header = page.at_css('.p-body-header')
|
||||||
|
threadmark_header = page.at_css('.threadmarkListingHeader-content')
|
||||||
|
|
||||||
|
authors = header.at_css('.p-description').css('username').map do |user|
|
||||||
|
{
|
||||||
|
slug: user[:'data-user-id'],
|
||||||
|
name: user.test.strip,
|
||||||
|
url: File.join(client.BASE_URL, user[:href]),
|
||||||
|
}.compact
|
||||||
|
end
|
||||||
|
tags = header.css('.p-description dl.tagList a.tagItem').map do |tag|
|
||||||
|
{
|
||||||
|
name: tag.text,
|
||||||
|
category: tag.at_css('i')[:title].downcase.to_sym,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
header_blocks = threadmark_header.css('dl').to_hash do |block|
|
||||||
|
[block.at_css('dt').text.strip.downcase.to_sym, block.at_css('dd')]
|
||||||
|
end
|
||||||
|
edited = threadmark_header.at_css('dl.message-lastEdit')
|
||||||
|
updated_at = Time.parse(edited.at_css('time')[:datetime]) if edited
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
name: header.at_css('.p-title').text.strip,
|
||||||
|
authors:,
|
||||||
|
synopsis: threadmark_header.at_css('.threadmarkListingHeader-extraInfo > article > div').children.to_xml.strip,
|
||||||
|
url:,
|
||||||
|
chapter_count: header_blocks[:threadmarks].text.to_i,
|
||||||
|
completed: header_blocks[:status].text != 'Ongoing',
|
||||||
|
published_at: Time.parse(header_blocks[:created].at_css('time')[:datetime]),
|
||||||
|
updated_at:,
|
||||||
|
tags: FicTracker::Models::Light::Tag.load(tags),
|
||||||
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_chapter(post)
|
def extract_chapter(post)
|
||||||
|
|
@ -140,7 +171,7 @@ module FicTracker::Backends::Spacebattles
|
||||||
|
|
||||||
name: threadmark.text,
|
name: threadmark.text,
|
||||||
url: post[:itemid],
|
url: post[:itemid],
|
||||||
published_at: Time.at(latest['data-time'].to_i),
|
published_at: Time.at(latest[:'data-time'].to_i),
|
||||||
last_refresh: Time.now,
|
last_refresh: Time.now,
|
||||||
|
|
||||||
content: html,
|
content: html,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue