[xasiat] fix 'IndexError' for albums without category (#8569)
This commit is contained in:
@@ -38,7 +38,7 @@ class XasiatExtractor(Extractor):
|
||||
"block_id": "list_albums_common_albums_list",
|
||||
"sort_by": "post_date",
|
||||
"from": pnum,
|
||||
"_": int(time.time() * 1000)
|
||||
"_": int(time.time() * 1000),
|
||||
}
|
||||
|
||||
page = self.request(url, params=params).text
|
||||
@@ -66,15 +66,14 @@ class XasiatAlbumExtractor(XasiatExtractor):
|
||||
images = extr('class="images"', "</div>")
|
||||
|
||||
urls = list(text.extract_iter(images, 'href="', '"'))
|
||||
|
||||
categories = text.re(r'categories/[^"]+\">\s*(.+)\s*</a').findall(info)
|
||||
data = {
|
||||
"title": text.unescape(title),
|
||||
"model": text.re(
|
||||
r'top_models1"></i>\s*(.+)\s*</span').findall(info),
|
||||
"tags": text.re(
|
||||
r'tags/[^"]+\">\s*(.+)\s*</a').findall(info),
|
||||
"album_category": text.re(
|
||||
r'categories/[^"]+\">\s*(.+)\s*</a').findall(info)[0],
|
||||
"album_category": categories[0] if categories else "",
|
||||
"album_url": response.url,
|
||||
"album_id": text.parse_int(album_id),
|
||||
"count": len(urls),
|
||||
|
||||
@@ -58,6 +58,26 @@ __tests__ = (
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.xasiat.com/albums/30478/gekkan-young-magazine-2025-no-11/",
|
||||
"#comment" : "no 'album_category' (#8569)",
|
||||
"#class" : xasiat.XasiatAlbumExtractor,
|
||||
"#pattern" : r"https://www\.xasiat\.com/get_image/\d+/\w+",
|
||||
"#count" : 13,
|
||||
|
||||
"album_category": "",
|
||||
"album_id" : 30478,
|
||||
"album_url" : "https://www.xasiat.com/albums/30478/gekkan-young-magazine-2025-no-11/",
|
||||
"count" : 13,
|
||||
"extension" : "jpg",
|
||||
"model" : [],
|
||||
"title" : "[Gekkan Young Magazine] 2025 No.11",
|
||||
"tags" : [
|
||||
"Young Magazine",
|
||||
"Teen",
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.xasiat.com/albums/categories/gravure-idols/",
|
||||
"#class" : xasiat.XasiatCategoryExtractor,
|
||||
|
||||
Reference in New Issue
Block a user