[furaffinity] improve new/old layout detection (fixes #2277)

pull/2281/head
Mike Fährmann 3 years ago
parent 0f1e7ff319
commit 4efe56f419
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2020-2021 Mike Fährmann
# Copyright 2020-2022 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@ -28,6 +28,7 @@ class FuraffinityExtractor(Extractor):
Extractor.__init__(self, match)
self.user = match.group(1)
self.offset = 0
self._new_layout = None
if self.config("descriptions") == "html":
self._process_description = str.strip
@ -64,8 +65,11 @@ class FuraffinityExtractor(Extractor):
def _parse_post(self, post_id):
url = "{}/view/{}/".format(self.root, post_id)
extr = text.extract_from(self.request(url).text)
path = extr('href="//d', '"')
if self._new_layout is None:
self._new_layout = ("http-equiv=" not in extr("<meta ", ">"))
path = extr('href="//d', '"')
if not path:
self.log.warning(
"Unable to download post %s (\"%s\")",
@ -84,10 +88,9 @@ class FuraffinityExtractor(Extractor):
"url": "https://d" + path,
})
tags = extr('class="tags-row">', '</section>')
if tags:
# new site layout
data["tags"] = text.split_html(tags)
if self._new_layout:
data["tags"] = text.split_html(extr(
'class="tags-row">', '</section>'))
data["title"] = text.unescape(extr("<h2><p>", "</p></h2>"))
data["artist"] = extr("<strong>", "<")
data["_description"] = extr('class="section-body">', '</div>')
@ -306,6 +309,25 @@ class FuraffinityPostExtractor(FuraffinityExtractor):
r"|http://www\.postybirb\.com",
"count": 2,
}),
# no tags (#2277)
("https://www.furaffinity.net/view/45331225/", {
"keyword": {
"artist": "Kota_Remminders",
"artist_url": "kotaremminders",
"date": "dt:2022-01-03 17:49:33",
"fa_category": "Adoptables",
"filename": "1641232173.kotaremminders_chidopts1",
"gender": "Any",
"height": 905,
"id": 45331225,
"rating": "General",
"species": "Unspecified / Any",
"tags": [],
"theme": "All",
"title": "REMINDER",
"width": 1280,
},
}),
("https://furaffinity.net/view/21835115/"),
("https://sfw.furaffinity.net/view/21835115/"),
("https://www.furaffinity.net/full/21835115/"),

Loading…
Cancel
Save