From c0749f3edb4af420691be9cd909c6cbf4d55b91e Mon Sep 17 00:00:00 2001 From: Chihchy Date: Thu, 2 Nov 2023 21:44:41 +0800 Subject: [PATCH] Fix previews parsing --- .github/workflows/deploy.yml | 2 +- EhPanda/App/Tools/Parser.swift | 61 +++++++++++++------ .../Parser/Gallery/GalleryDetail.html | 32 +++++----- .../Gallery/GalleryDetailParserTests.swift | 34 +++++------ 4 files changed, 76 insertions(+), 53 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3a2960f0..1d5f8b25 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,7 +6,7 @@ on: types: [closed] env: DEVELOPER_DIR: /Applications/Xcode_15.0.1.app - APP_VERSION: '2.7.3' + APP_VERSION: '2.7.4' SCHEME_NAME: 'EhPanda' ALTSTORE_JSON_PATH: './AltStore.json' BUILDS_PATH: '/tmp/action-builds' diff --git a/EhPanda/App/Tools/Parser.swift b/EhPanda/App/Tools/Parser.swift index cc25953c..1134d5b7 100644 --- a/EhPanda/App/Tools/Parser.swift +++ b/EhPanda/App/Tools/Parser.swift @@ -312,23 +312,47 @@ struct Parser { static func parseGalleryDetail(doc: HTMLDocument, gid: String) throws -> (GalleryDetail, GalleryState) { func parsePreviewConfig(doc: HTMLDocument) throws -> PreviewConfig { guard let previewMode = try? parsePreviewMode(doc: doc), - let gdoNode = doc.at_xpath("//div [@id='gdo']"), - let rows = gdoNode.at_xpath("//div [@id='gdo2']")?.xpath("//div") + let gpcText = doc.at_xpath("//p [@class='gpc']")?.text, + let rangeA = gpcText.range(of: "Showing 1 - "), + let rangeB = gpcText.range(of: " of "), + let singlePageCount = Int(gpcText[rangeA.upperBound.. URL { @@ -741,14 +765,13 @@ struct Parser { } static func parsePreviewMode(doc: HTMLDocument) throws -> String { - guard let gdoNode = doc.at_xpath("//div [@id='gdo']"), - let gdo4Node = gdoNode.at_xpath("//div [@id='gdo4']") - else { return "gdtm" } - - for link in gdo4Node.xpath("//div") where link.text == "Large" { - return link["class"] == "ths nosel" ? "gdtl" : "gdtm" + if doc.at_xpath("//div [@class='gdtm']") != nil { + return "gdtm" + } else if doc.at_xpath("//div [@class='gdtl']") != nil { + return "gdtl" + } else { + throw AppError.parseFailed } - return "gdtm" } static func parseMPVKeys(doc: HTMLDocument) throws -> (String, [Int: String]) { diff --git a/EhPandaTests/Resources/Parser/Gallery/GalleryDetail.html b/EhPandaTests/Resources/Parser/Gallery/GalleryDetail.html index 05ee1c01..ca4bc0f5 100644 --- a/EhPandaTests/Resources/Parser/Gallery/GalleryDetail.html +++ b/EhPandaTests/Resources/Parser/Gallery/GalleryDetail.html @@ -1,9 +1,9 @@ - - + + -◆FANBOX◆ AI Fetish [87052610&ai-fetish] [AI Generated] - E-Hentai Galleries - - +●PIXIV● HYYT [67227995] - E-Hentai Galleries + + @@ -13,11 +13,11 @@ - + - -

◆FANBOX◆ AI Fetish [87052610&ai-fetish] [AI Generated]

Misc
Posted:2023-09-07 23:51
Parent:None
Visible:Yes
Language:Japanese  
File Size:684.9 MiB
Length:194 pages
Favorited:6 times
Rating:
6
Average: 0.50

Showing 1 - 20 of 194 images

<1234567...10>
4 rows
10 rows
20 rows
40 rows
Normal
Large
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
Posted on 07 September 2023, 23:51 by:   KEYLUN    PM
Uploader Comment
https://ai-fetish.fanbox.cc/

=================================================
每天大量更新/Massive update every day

https://e-hentai.org/uploader/KEYLUN
=========================================================
Q群被炸,轉戰TELEGRAM
(中文限:做種&補種&交流) :https://t.me/+-Pwn49-d7uQxN2M1

如不喜歡ai生成的人請使用以下方法/If you don't like AI generated, please use the following method:
my home>my tag>空格輸入/Space input [ai generated]>勾選/tick hidden>save
+ +

Showing 1 - 40 of 612 images

<1234567...16>
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
Posted on 02 November 2023, 12:27 by:   KEYLUN    PM
Uploader Comment
https://www.pixiv.net/users/67227995

=================================================
每天大量更新/Massive update every day

https://e-hentai.org/uploader/KEYLUN
=========================================================
Q群被炸,轉戰TELEGRAM
(中文限:做種&補種&交流) :https://t.me/+-Pwn49-d7uQxN2M1
Posted on 17 September 2021, 17:52 by:   onlyregistere    PM
[Vote+]   [Vote-]
Score +82
Pretty funny combination of decent art and terrible low res fetish tattoo photo bashing, what a waste. At least most of them come with the base image.
This stuff should come with a tag so it can be filtered.
Posted on 07 October 2021, 15:47 by:   Nikolaios    PM
[Vote+]   [Vote-]
Score +18
bro translate the chinese name i cannot find the author
Posted on 07 October 2021, 16:42 by:   yooooooooooooiooo    PM
[Vote+]   [Vote-]
Score +52
我超,晚晚 不要啊
Posted on 08 October 2021, 03:17 by:   zdb493637495    PM
[Vote+]   [Vote-]
Score +49
我超,乐
Posted on 13 November 2021, 06:24 by:   Severusli    PM
[Vote+]   [Vote-]
Score +161
粉色矮子因为未成年人过不了审核逃过一劫
Posted on 25 November 2021, 23:47 by:   0ld0neEye    PM
[Vote+]   [Vote-]
Score +21
Ahegao, womb tattoo... good to see we've already set the low bar for Shenhe art in the first couple of days.
Posted on 26 November 2021, 15:50 by:   chung~    PM
[Vote+]   [Vote-]
Score +48
黑人花式體操
Posted on 26 November 2021, 16:25 by:   唱跳rap篮球    PM
[Vote+]   [Vote-]
Score +10
尼哥尼哥He
Posted on 05 December 2021, 05:39 by:   Farry01    PM
[Vote+]   [Vote-]
Score +125
楼上的ylg密麻麻石蜡,提出现的人物也算ky是吧,你是不是觉得你会个ky的词就是网络弄潮儿了啊
Posted on 07 December 2021, 02:40 by:   WorkSpend street    PM
[Vote+]   [Vote-]
Score +53
倪哥能不能死啊😅
Posted on 07 December 2021, 18:43 by:   samuelmoon    PM
[Vote+]   [Vote-]
Score +95
黑人就该被灭绝
Posted on 16 December 2021, 13:03 by:   hhhhf123    PM
[Vote+]   [Vote-]
Score +28
qq人:乌鸦座飞机!
Posted on 01 January 2022, 11:29 by:   二苇渡江    PM
[Vote+]   [Vote-]
Score +39
申鹤就应该被黑人隔着裤袜草死
Posted on 08 January 2022, 15:48 by:   雪芬12256    PM
[Vote+]   [Vote-]
Score +51
画技忽高忽低,透视也七上八下....不会是半路出家吧?
Posted on 08 January 2022, 18:23 by:   kevinstu7    PM
[Vote+]   [Vote-]
Score +14
xp巨好,如果画的更好就完美了
Posted on 11 January 2022, 05:18 by:   魔女的丝袜    PM
[Vote+]   [Vote-]
Score +14
感觉更像是哥布林但比哥布林还背德
Posted on 12 January 2022, 08:12 by:   ss407935963    PM
[Vote+]   [Vote-]
Score +5
呃呃呃呃好吧
Last edited on 26 April 2022, 22:11.
Posted on 17 February 2022, 09:05 by:   acgs    PM
[Vote+]   [Vote-]
Score +16
倪哥能不能爬啊😋
Posted on 06 March 2022, 09:06 by:   jmc_akatsuki    PM
[Vote+]   [Vote-]
Score +16
p站找不到这个画师了,是删号了还是炸号了?
Posted on 06 March 2022, 14:36 by:   ShaodowNinja    PM
[Vote+]   [Vote-]
Score +19
删作品加换名,问了下说是没事,我暂且蒙古
Posted on 08 March 2022, 14:50 by:   Stella0119    PM
[Vote+]   [Vote-]
Score +12
我超,以前的画都删了,没那些小作文都没那么色了
Posted on 20 March 2022, 00:04 by:   qingjiangxiangbei    PM
[Vote+]   [Vote-]
Score +13
一只喜爱,作者名字
Posted on 07 April 2022, 06:35 by:   CNx1    PM
[Vote+]   [Vote-]
Score +10
没有爱老师的旁白,图的色度大大下降了。
Posted on 07 April 2022, 19:22 by:   YZZ200219    PM
[Vote+]   [Vote-]
Score +12
这位画师的精髓可是小作文啊,这单图不太行啊
Posted on 18 April 2022, 12:59 by:   fengqing123    PM
[Vote+]   [Vote-]
Score +8
可惜没简介了
Posted on 02 May 2022, 04:59 by:   空明幻想    PM
[Vote+]   [Vote-]
Score +12
这个画师的作品在eh上的排序都是反的 怎么回事
Posted on 11 May 2022, 02:59 by:   Yinjiuzui    PM
[Vote+]   [Vote-]
Score +9
可有人存过珍惜小作文资源?(
Posted on 17 June 2022, 15:53 by:   Edwi17    PM
[Vote+]   [Vote-]
Score +57
尼哥不就是现实题材下的哥布林和兽人吗。。。有什么接受不了的,尼哥这一个设定就有流浪汉的脏乱差有黑帮的毒品有体育老师的体格,再加上大吉吧的刻板印象,拿来当黄毛设定不要太方便(别人的评论)
Posted on 18 June 2022, 09:20 by:   ss407935963    PM
[Vote+]   [Vote-]
Score +91
现实里没有强奸和轮奸吗?为什么你们还要看呢?看个本子因为屁大点事骂到画师删作品加改名。我看有尼哥的本子是媚黑,那如果你看了有违法行为的本子敢不敢去自首??更别提r18g的本子了。有些小鬼是真的恶心,纯低能。
Posted on 06 July 2022, 22:43 by:   gftrym    PM
[Vote+]   [Vote-]
Score +43
这评论区太脑瘫了。
Posted on 19 July 2022, 10:48 by:   hentaisang52    PM
[Vote+]   [Vote-]
Score +12
没文字感觉没味道,每次简介的小作文可是精华啊
Posted on 09 September 2022, 14:39 by:   huifeidehaitun    PM
[Vote+]   [Vote-]
Score +6
原来还有小作文,看了这么多次,都不知道QAQ
Posted on 12 September 2022, 07:29 by:   fanboshi    PM
[Vote+]   [Vote-]
Score +43
整个星球的黑人加起来都不够你们二次元的♠去榨的
Posted on 17 September 2022, 06:29 by:   seedt    PM
[Vote+]   [Vote-]
Score +10
所以说什么时候把留学牲宿舍拆了 把negro,学渣棒那些遣返捏
Posted on 05 May 2023, 14:25 by:   Bakster123    PM
[Vote+]   [Vote-]
Score +15
This artist shows some creativity in camera angles and poses, not too far from the generic ones but enough to catch the eye.

I feel that if they invest more in this, they will gain a foothold at a new level.
Posted on 05 May 2023, 15:19 by:   gunpowderfans    PM
[Vote+]   [Vote-]
Score +6
什么时候画马的
Posted on 05 May 2023, 17:57 by:   shuyuuuuu    PM
[Vote+]   [Vote-]
Score +24
tmd截肢标签放第一个,结果翻了快三百页才看到截肢图😡
Posted on 06 May 2023, 05:02 by:   Nicolasbot    PM
[Vote+]   [Vote-]
Score +7
看个黄图都有种族主义是吧,没出生在德三上前线是不是浑身刺挠?
Posted on 24 May 2023, 07:33 by:   Fuck you?    PM
[Vote+]   [Vote-]
Score +6
雷电将军太戳我啦😍😍
Posted on 31 May 2023, 00:31 by:   白兔糖~    PM
[Vote+]   [Vote-]
Score +6
这个作者现在怎么没有赞助了
Posted on 04 June 2023, 16:12 by:   mooyee    PM
[Vote+]   [Vote-]
Score +13
这个作者画米家烧鸡一直很顶的,尤其是崩三图,别家出高质量崩三r18或者r18g图都很少,就这个作者一直出很顶的图
Posted on 04 June 2023, 16:29 by:   茜色的火焰    PM
[Vote+]   [Vote-]
Score +16
我也歧视黑人 但是这种色图里的黑人我没什么感觉
Posted on 05 June 2023, 04:14 by:   黑色騎士    PM
[Vote+]   [Vote-]
Score +6
我宁肯看尼也不想看散呀,这东西在我这和慎二一个量级的(在色图里看见觉得晦气)
Posted on 05 June 2023, 14:48 by:   eric11825    PM
[Vote+]   [Vote-]
Score +6
強烈建議去P站看作者的小作文
Posted on 25 July 2023, 03:09 by:   yxlm9527    PM
[Vote+]   [Vote-]
Score +19
评论区真是卧龙凤雏,我每次看到这种类型的本子就先点开评论区瞅瞅看有没有人才😆
Posted on 25 July 2023, 09:03 by:   yazawayuan    PM
[Vote+]   [Vote-]
Score +3
这位老师的小作文才是精髓啊
Posted on 02 August 2023, 04:50 by:   ussr_without_⑨    PM
[Vote+]   [Vote-]
Score +11
空哥跟重云这个对比笑死我了
Posted on 02 November 2023, 12:32 by:   cpwt4567    PM
[Vote+]   [Vote-]
Score +4
看到我老婆夜兰像母狗一样被人操就觉得好幸福

There are 19 more comments below the viewing threshold - click to show all.

[Post New Comment]

-
- Front Page -   Terms of Service   Advertise - +
+ Front +   LoFi   Forums   HentaiVerse   Wiki   Twitter   ToS   Advertise +
diff --git a/EhPandaTests/Tests/Parser/Gallery/GalleryDetailParserTests.swift b/EhPandaTests/Tests/Parser/Gallery/GalleryDetailParserTests.swift index 60f81ffa..527eddd7 100644 --- a/EhPandaTests/Tests/Parser/Gallery/GalleryDetailParserTests.swift +++ b/EhPandaTests/Tests/Parser/Gallery/GalleryDetailParserTests.swift @@ -12,29 +12,29 @@ import XCTest class GalleryDetailParserTests: XCTestCase, TestHelper { func testExample() throws { let document = try htmlDocument(filename: .galleryDetail) - let (detail, state) = try Parser.parseGalleryDetail(doc: document, gid: "2668586") - XCTAssertEqual(detail.gid, "2668586") - XCTAssertEqual(detail.title, "◆FANBOX◆ AI Fetish [87052610&ai-fetish] [AI Generated]") + let (detail, state) = try Parser.parseGalleryDetail(doc: document, gid: "2725078") + XCTAssertEqual(detail.gid, "2725078") + XCTAssertEqual(detail.title, "●PIXIV● HYYT [67227995]") XCTAssertEqual(detail.jpnTitle, nil) XCTAssertFalse(detail.isFavorited) XCTAssertEqual(detail.visibility, .yes) - XCTAssertEqual(detail.rating, 0.5) + XCTAssertEqual(detail.rating, 4.5) XCTAssertEqual(detail.userRating, 0) - XCTAssertEqual(detail.ratingCount, 6) - XCTAssertEqual(detail.category, .misc) + XCTAssertEqual(detail.ratingCount, 569) + XCTAssertEqual(detail.category, .imageSet) XCTAssertEqual(detail.language, .japanese) XCTAssertEqual(detail.uploader, "KEYLUN") - XCTAssertEqual(detail.coverURL?.absoluteString, "https://ehgt.org/9d/71/9d71dd93bbf5cae13e9b5f9a1086b41600c9ce7e-6430614-2048-3072-png_250.jpg") - XCTAssertEqual(detail.archiveURL?.absoluteString, "https://e-hentai.org/archiver.php?gid=0000000&token=0000000000&or=470592--63bbddc729b849100ec24ab920ffdb84b6542b23") - XCTAssertNil(detail.parentURL) - XCTAssertEqual(detail.favoritedCount, 6) - XCTAssertEqual(detail.pageCount, 194) - XCTAssertEqual(detail.sizeCount, 684.9) + XCTAssertEqual(detail.coverURL?.absoluteString, "https://ehgt.org/5e/b5/5eb550886fe58da8c780d9ab9182717ae9bcda91-604248-2235-3016-jpg_250.jpg") + XCTAssertEqual(detail.archiveURL?.absoluteString, "https://e-hentai.org/archiver.php?gid=0000000&token=0000000000&or=471924--76094077f7be1ee86673ef75c45e0d382961dc9c") + XCTAssertEqual(detail.parentURL?.absoluteString, "https://e-hentai.org/g/2624293/78cf5e78a5/") + XCTAssertEqual(detail.favoritedCount, 9218) + XCTAssertEqual(detail.pageCount, 612) + XCTAssertEqual(detail.sizeCount, 657.6) XCTAssertEqual(detail.sizeType, "MiB") - XCTAssertEqual(detail.torrentCount, 1) - XCTAssertEqual(state.tags.count, 1) - XCTAssertEqual(state.previewURLs.count, 20) - XCTAssertEqual(state.previewConfig, .large(rows: 4)) - XCTAssertEqual(state.comments.count, 1) + XCTAssertEqual(detail.torrentCount, 5) + XCTAssertEqual(state.tags.count, 4) + XCTAssertEqual(state.previewURLs.count, 40) + XCTAssertEqual(state.previewConfig, .normal(rows: 4)) + XCTAssertEqual(state.comments.count, 49) } }