/* * Copyright (C) 2015 Hippo Seven * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hippo.ehviewer.client; import com.hippo.ehviewer.data.Comment; import com.hippo.ehviewer.data.TagGroup; import com.hippo.ehviewer.util.EhUtils; import com.hippo.util.AssertUtils; import com.hippo.util.Utils; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; public class GalleryDetailParser { private static final DateFormat WEB_COMMENT_DATA_FORMAT = new SimpleDateFormat("dd MMMMM yyyy, HH:mm z", Locale.US); private static final DateFormat OUT_COMMENT_DATA_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US); static { WEB_COMMENT_DATA_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); OUT_COMMENT_DATA_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); } private static final String OFFENSIVE_STRING = "
(And if you choose to ignore this warning, you lose all rights to complain about it in the future.)
"; private static final String PINING_STRING = "This gallery is pining for the fjords.
"; public static final int REQUEST_DETAIL = 0x1; public static final int REQUEST_TAG = 0x2; public static final int REQUEST_PREVIEW_INFO = 0x4; public static final int REQUEST_COMMENT = 0x10; private static final CommentSort COMMENT_SORTER = new CommentSort(); public int gid; public String token; public String thumb; public String title; public String titleJpn; public int category; public String uploader; public int torrentCount; public String torrentUrl; public String posted; public String parent; public String visible; public String language; public String size; public String resize; public int pageCount; public int favoredTimes; public boolean isFavored; public float rating; public int ratedTimes; public List([^<]+)
"); m = p.matcher(body); if (m.find()) { throw new EhException(m.group(1)); } if ((request & REQUEST_DETAIL) != 0) { p = Pattern.compile("var gid = (\\d+)" // 1 gid + ".+?" + "var token = \"([a-z0-9A]+)\"" // 2 token + ".+?" + "