diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ffb0cdb7..4c9f7011 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,7 +6,7 @@ on: types: [closed] env: DEVELOPER_DIR: /Applications/Xcode_14.1.app - APP_VERSION: '2.4.4' + APP_VERSION: '2.4.5' 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 878926ea..a42dcf71 100644 --- a/EhPanda/App/Tools/Parser.swift +++ b/EhPanda/App/Tools/Parser.swift @@ -13,11 +13,17 @@ struct Parser { // MARK: List static func parseGalleries(doc: HTMLDocument) throws -> [Gallery] { func parseDisplayMode(doc: HTMLDocument) throws -> String { - guard let dmsNode = doc.at_xpath("//div [@id='dms']"), - let select = dmsNode.at_xpath("//select") + guard let containerNode = doc.at_xpath("//div [@id='dms']") ?? doc.at_xpath("//div [@class='searchnav']") else { throw AppError.parseFailed } - for option in select.xpath("//option") where option["selected"] == "selected" { + var dmsNode: XMLElement? + for select in containerNode.xpath("//select") where select["onchange"]?.contains("inline_set=dm_") == true { + dmsNode = select + break + } + guard let dmsNode else { throw AppError.parseFailed } + + for option in dmsNode.xpath("//option") where option["selected"] == "selected" { if let displayMode = option.text { return displayMode } @@ -1103,146 +1109,152 @@ extension Parser { let form = tmpForm else { throw AppError.parseFailed } // swiftlint:disable line_length - var tmpEhProfiles = [EhProfile](); var tmpCapableLoadThroughHathSetting: EhSetting.LoadThroughHathSetting?; var tmpCapableImageResolution: EhSetting.ImageResolution?; var tmpCapableSearchResultCount: EhSetting.SearchResultCount?; var tmpCapableThumbnailConfigSize: EhSetting.ThumbnailSize?; var tmpCapableThumbnailConfigRowCount: EhSetting.ThumbnailRowCount?; var tmpLoadThroughHathSetting: EhSetting.LoadThroughHathSetting?; var tmpBrowsingCountry: EhSetting.BrowsingCountry?; var tmpImageResolution: EhSetting.ImageResolution?; var tmpImageSizeWidth: Float?; var tmpImageSizeHeight: Float?; var tmpGalleryName: EhSetting.GalleryName?; var tmpLiteralBrowsingCountry: String?; var tmpArchiverBehavior: EhSetting.ArchiverBehavior?; var tmpDisplayMode: EhSetting.DisplayMode?; var tmpDisabledCategories = [Bool](); var tmpFavoriteCategories = [String](); var tmpFavoritesSortOrder: EhSetting.FavoritesSortOrder?; var tmpRatingsColor: String?; var tmpExcludedNamespaces = [Bool](); var tmpTagFilteringThreshold: Float?; var tmpTagWatchingThreshold: Float?; var tmpExcludedLanguages = [Bool](); var tmpExcludedUploaders: String?; var tmpSearchResultCount: EhSetting.SearchResultCount?; var tmpThumbnailLoadTiming: EhSetting.ThumbnailLoadTiming?; var tmpThumbnailConfigSize: EhSetting.ThumbnailSize?; var tmpThumbnailConfigRows: EhSetting.ThumbnailRowCount?; var tmpThumbnailScaleFactor: Float?; var tmpViewportVirtualWidth: Float?; var tmpCommentsSortOrder: EhSetting.CommentsSortOrder?; var tmpCommentVotesShowTiming: EhSetting.CommentVotesShowTiming?; var tmpTagsSortOrder: EhSetting.TagsSortOrder?; var tmpGalleryShowPageNumbers: Bool?; /* var tmpHathLocalNetworkHost: String?; */ var tmpUseOriginalImages: Bool?; var tmpUseMultiplePageViewer: Bool?; var tmpMultiplePageViewerStyle: EhSetting.MultiplePageViewerStyle?; var tmpMultiplePageViewerShowThumbnailPane: Bool? + var ehProfiles = [EhProfile](); var isCapableOfCreatingNewProfile: Bool?; var capableLoadThroughHathSetting: EhSetting.LoadThroughHathSetting?; var capableImageResolution: EhSetting.ImageResolution?; var capableSearchResultCount: EhSetting.SearchResultCount?; var capableThumbnailConfigSize: EhSetting.ThumbnailSize?; var capableThumbnailConfigRowCount: EhSetting.ThumbnailRowCount?; var loadThroughHathSetting: EhSetting.LoadThroughHathSetting?; var browsingCountry: EhSetting.BrowsingCountry?; var imageResolution: EhSetting.ImageResolution?; var imageSizeWidth: Float?; var imageSizeHeight: Float?; var galleryName: EhSetting.GalleryName?; var literalBrowsingCountry: String?; var archiverBehavior: EhSetting.ArchiverBehavior?; var displayMode: EhSetting.DisplayMode?; var disabledCategories = [Bool](); var favoriteCategories = [String](); var favoritesSortOrder: EhSetting.FavoritesSortOrder?; var ratingsColor: String?; var excludedNamespaces = [Bool](); var tagFilteringThreshold: Float?; var tagWatchingThreshold: Float?; var excludedLanguages = [Bool](); var excludedUploaders: String?; var searchResultCount: EhSetting.SearchResultCount?; var thumbnailLoadTiming: EhSetting.ThumbnailLoadTiming?; var thumbnailConfigSize: EhSetting.ThumbnailSize?; var thumbnailConfigRows: EhSetting.ThumbnailRowCount?; var thumbnailScaleFactor: Float?; var viewportVirtualWidth: Float?; var commentsSortOrder: EhSetting.CommentsSortOrder?; var commentVotesShowTiming: EhSetting.CommentVotesShowTiming?; var tagsSortOrder: EhSetting.TagsSortOrder?; var galleryShowPageNumbers: Bool?; var useOriginalImages: Bool?; var useMultiplePageViewer: Bool?; var multiplePageViewerStyle: EhSetting.MultiplePageViewerStyle?; var multiplePageViewerShowThumbnailPane: Bool? // swiftlint:enable line_length - tmpEhProfiles = parseSelections(node: profileOuter, name: "profile_set") + ehProfiles = parseSelections(node: profileOuter, name: "profile_set") .compactMap { (name, value, isSelected) in guard let value = Int(value) else { return nil } return EhProfile(value: value, name: name, isSelected: isSelected) } + for button in profileOuter.xpath("//input [@type='button']") { + if button["value"] == "Create New" { + isCapableOfCreatingNewProfile = true + break + } else { + isCapableOfCreatingNewProfile = false + } + } + for optouter in form.xpath("//div [@class='optouter']") { if optouter.at_xpath("//input [@name='uh']") != nil { - tmpLoadThroughHathSetting = parseEnum(node: optouter, name: "uh") - tmpCapableLoadThroughHathSetting = parseCapability(node: optouter, name: "uh") + loadThroughHathSetting = parseEnum(node: optouter, name: "uh") + capableLoadThroughHathSetting = parseCapability(node: optouter, name: "uh") } if optouter.at_xpath("//select [@name='co']") != nil { var value = parseSelections(node: optouter, name: "co").filter(\.2).first?.1 if value == "" { value = "-" } - tmpBrowsingCountry = EhSetting.BrowsingCountry(rawValue: value ?? "") + browsingCountry = EhSetting.BrowsingCountry(rawValue: value ?? "") if let pText = optouter.at_xpath("//p")?.text, let rangeA = pText.range(of: "You appear to be browsing the site from "), let rangeB = pText.range(of: " or use a VPN or proxy in this country") { - tmpLiteralBrowsingCountry = String(pText[rangeA.upperBound..) { - _ehSetting = ehSetting - } - - var body: some View { - Section( - header: Text(R.string.localizable.ehSettingViewSectionTitleHathLocalNetworkHost()).newlineBold() - + Text(R.string.localizable.ehSettingViewDescriptionIpAddressPort()) - ) { - HStack { - Text(R.string.localizable.ehSettingViewTitleIpAddressPort()) - Spacer() - SettingTextField(text: $ehSetting.hathLocalNetworkHost, width: 150).focused($isFocused) - } - } - .textCase(nil) - } -} - */ - // MARK: OriginalImagesSection private struct OriginalImagesSection: View { @Binding private var ehSetting: EhSetting