Skip to content

Commit

Permalink
[furaffinity] Add 'thumbnail' (mikf#1284) and 'folders' properties
Browse files Browse the repository at this point in the history
Retrieve 'thumbnail' and 'folders' properties for each post.
Thumbnail (mikf#1284):
 - Preview image used for search results, writing posts, music, etc.
 - Filename format: <post_id>@600-<directory_containing_full_image>.jpg
Folders (related to mikf#1817):
 - A list of all gallery folders containing this post.
 - Folder name format: [<folder_category> - ]<folder_name>
 - Only works on new layout; old layout does not show folders, so list will be empty

A test is included for each property
  • Loading branch information
theorangesauce committed Jul 4, 2024
1 parent e03b99b commit 3e1142e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gallery_dl/extractor/furaffinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def _parse_post(self, post_id):
data["gender"] = rh(extr('>Gender</strong>', '</div>'))
data["width"] = pi(extr("<span>", "x"))
data["height"] = pi(extr("", "p"))
data["folders"] = [rh(folder) for folder in extr(
'<h3>Listed in Folders</h3>',
'</section>').split('</a>') if rh(folder) != '']
else:
# old site layout
data["title"] = text.unescape(extr("<h2>", "</h2>"))
Expand All @@ -132,11 +135,16 @@ def _parse_post(self, post_id):
data["_description"] = extr(
'<td valign="top" align="left" width="70%" class="alt1" '
'style="padding:8px">', ' </td>')
data["folders"] = [] # folders not present in old layout

data["artist_url"] = data["artist"].replace("_", "").lower()
data["user"] = self.user or data["artist_url"]
data["date"] = text.parse_timestamp(data["filename"].partition(".")[0])
data["description"] = self._process_description(data["_description"])
data["thumbnail"] = (
'https://t.furaffinity.net/' +
str(data['id']) + '@600-' +
data['url'].split('/')[-2].split('.')[0] + '.jpg')

return data

Expand Down
44 changes: 44 additions & 0 deletions test/results/furaffinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,50 @@
"width" : 1280,
},

{
"#url" : "https://www.furaffinity.net/view/22964019/",
"#comment" : "get thumbnails for posts (#1284)",
"#category": ("", "furaffinity", "post"),
"#class" : furaffinity.FuraffinityPostExtractor,

"artist" : "Dwale",
"artist_url" : "dwale",
"date" : "dt:2017-03-21 14:21:29",
"fa_category" : "Poetry",
"filename" : "1490106089.dwale_poem_for_children",
"folders" : [],
"height" : 50,
"id" : 22964019,
"rating" : "General",
"title" : "Poem for Children Wishing to Summon Evil Spirits",
"thumbnail" : "https://t.furaffinity.net/22964019@600-1490106089.jpg",
"width" : 50,
},

{
"#url" : "https://www.furaffinity.net/view/34260156/",
"#comment" : "list gallery folders for image",
"#category": ("", "furaffinity", "post"),
"#class" : furaffinity.FuraffinityPostExtractor,

"artist" : "dbd",
"artist_url" : "dbd",
"date" : "dt:2019-12-17 22:52:01",
"fa_category" : "All",
"filename" : "1576623121.dbd_patreoncustom-wdg13-web",
"folders" : ["By Year - 2019",
"Custom Character Folder - All Custom Characters",
"Custom Character Folder - Other Ungulates",
"Custom Character Folder - Female",
"Custom Character Folder - Patreon Supported Custom Characters"],
"height" : 900,
"id" : 34260156,
"rating" : "General",
"title" : "Patreon Custom Deer",
"thumbnail" : "https://t.furaffinity.net/34260156@600-1576623121.jpg",
"width" : 488,
},

{
"#url" : "https://furaffinity.net/view/21835115/",
"#category": ("", "furaffinity", "post"),
Expand Down

0 comments on commit 3e1142e

Please sign in to comment.