merge #7409: [pictoa] add support (#6683)

This commit is contained in:
Mike Fährmann
2025-04-24 18:02:34 +02:00
4 changed files with 157 additions and 0 deletions

View File

@@ -691,6 +691,12 @@ Consider all listed sites to potentially be NSFW.
<td>Galleries</td>
<td></td>
</tr>
<tr>
<td>Pictoa</td>
<td>https://pictoa.com/</td>
<td>Albums, individual Images</td>
<td></td>
</tr>
<tr>
<td>Piczel</td>
<td>https://piczel.tv/</td>

View File

@@ -130,6 +130,7 @@ modules = [
"philomena",
"photovogue",
"picarto",
"pictoa",
"piczel",
"pillowfort",
"pinterest",

View File

@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
# 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
# published by the Free Software Foundation.
"""Extractors for https://pictoa.com/"""
from .common import Extractor, Message
from .. import text
BASE_PATTERN = r"(?:https?://)?(?:[\w]+\.)?pictoa\.com(?:\.de)?"
class PictoaExtractor(Extractor):
"""Base class for pictoa extractors"""
category = "pictoa"
root = "https://pictoa.com"
directory_fmt = ("{category}", "{album_id} {album_title}")
filename_fmt = "{id}.{extension}"
archive_fmt = "{id}"
class PictoaImageExtractor(PictoaExtractor):
"""Extractor for single images from pictoa.com"""
subcategory = "image"
pattern = BASE_PATTERN + r"/albums/(?:[\w-]+-)?(\d+)/(\d+)"
example = "https://www.pictoa.com/albums/NAME-12345/12345.html"
def items(self):
album_id, image_id = self.groups
url = "{}/albums/{}/{}.html".format(self.root, album_id, image_id)
page = self.request(url).text
album_title = text.extr(page, 'property="og:title" content="', '"')
image_url = text.extr(page, 'property="og:image" content="', '"')
data = {
"album_id" : album_id,
"album_title": album_title.rpartition(" #")[0],
"id" : image_id,
"url" : image_url,
}
text.nameext_from_url(image_url, data)
yield Message.Directory, data
yield Message.Url, image_url, data
class PictoaAlbumExtractor(PictoaExtractor):
"""Extractor for image albums from pictoa.com"""
subcategory = "album"
pattern = BASE_PATTERN + r"/albums/(?:[\w-]+-)?(\d+).html"
example = "https://www.pictoa.com/albums/NAME-12345.html"
def items(self):
album_id = self.groups[0]
url = "{}/albums/{}.html".format(self.root, album_id)
page = self.request(url).text
album_data = {
"album_id" : album_id,
"album_title": text.extr(page, "<h1>", "<"),
"tags" : text.split_html(text.extr(
page, '<ol class="related-categories', '</ol>'))[1:],
"_extractor" : PictoaImageExtractor,
}
while True:
container = text.extr(page, '<main>', '<span id="flag" >')
for url in text.extract_iter(
container, '<a rel="nofollow" href="', '"'):
yield Message.Queue, url, album_data
url = text.extr(page, '<link rel="next" href="', '"')
if not url:
break
page = self.request(url).text

72
test/results/pictoa.py Normal file
View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
# 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
# published by the Free Software Foundation.
from gallery_dl.extractor import pictoa
__tests__ = (
{
"#url" : "https://www.pictoa.com/albums/anna-kendrick-busty-in-a-strapless-red-dress-out-in-nyc-3229225.html",
"#class" : pictoa.PictoaAlbumExtractor,
"#pattern": pictoa.PictoaImageExtractor.pattern,
"#count" : 16,
"album_id" : "3229225",
"album_title": "Anna Kendrick busty in a strapless red dress out in NYC",
"tags" : ["Anna Kendrick", "Celebrity"],
},
{
"#url" : "https://www.pictoa.com.de/albums/oscars-2020-red-carpet-4010403.html",
"#comment": "verify pagination works",
"#class" : pictoa.PictoaAlbumExtractor,
"#pattern": pictoa.PictoaImageExtractor.pattern,
"#count" : 182,
"album_id" : "4010403",
"album_title": "Oscars 2020 Red Carpet",
"tags" : ['Celebrity', 'Red'],
},
{
"#url" : "https://it.pictoa.com/albums/carl-virkus-149024.html",
"#comment": "null tags",
"#class" : pictoa.PictoaAlbumExtractor,
"#urls" : "https://www.pictoa.com/albums/carl-virkus-149024/2221031.html",
"album_id" : "149024",
"album_title": "Carl Virkus",
"tags" : [],
},
{
"#url" : "https://www.pictoa.com/albums/anna-kendrick-showing-cleavage-at-the-56th-annual-grammy-awards-3233172/75206264.html",
"#class": pictoa.PictoaImageExtractor,
"#urls" : "https://s1.pictoa.com/media/galleries/168/930/168930594a8750dfd3e/3233172594a8759dcc3a.jpg",
"album_id" : "3233172",
"album_title": "Anna Kendrick showing cleavage at the 56th Annual GRAMMY Awards",
"extension" : "jpg",
"filename" : "3233172594a8759dcc3a",
"id" : "75206264",
"url" : "https://s1.pictoa.com/media/galleries/168/930/168930594a8750dfd3e/3233172594a8759dcc3a.jpg"
},
{
"#url" : "https://nl.pictoa.com/albums/kandi-barbour-3840809/94038192.html",
"#class": pictoa.PictoaImageExtractor,
"#urls" : "https://s2.pictoa.com/media/galleries/294/452/29445260009fa5b68e4/384080960009fb51e389.jpg",
"#sha1_content": "152595069016da89565eb3d8e73df835afd22e2c",
"album_id" : "3840809",
"album_title": "Kandi Barbour",
"extension" : "jpg",
"filename" : "384080960009fb51e389",
"id" : "94038192",
"url" : "https://s2.pictoa.com/media/galleries/294/452/29445260009fa5b68e4/384080960009fb51e389.jpg",
},
)