cn.hutool.json.JSONArray Java Examples

The following examples show how to use cn.hutool.json.JSONArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OcrUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 7 votes vote down vote up
private static String extractSogouResult(String html) {
    if (StrUtil.isBlank(html)) {
        return "";
    }
    JSONObject jsonObject = JSONUtil.parseObj(html);
    if (jsonObject.getInt("success", 0) != 1) {
        return "";
    }
    JSONArray jsonArray = jsonObject.getJSONArray("result");
    List<TextBlock> textBlocks = new ArrayList<>();
    boolean isEng;
    for (int i = 0; i < jsonArray.size(); i++) {
        JSONObject jObj = jsonArray.getJSONObject(i);
        TextBlock textBlock = new TextBlock();
        textBlock.setText(jObj.getStr("content").trim());
        //noinspection SuspiciousToArrayCall
        String[] frames = jObj.getJSONArray("frame").toArray(new String[0]);
        textBlock.setTopLeft(CommUtils.frameToPoint(frames[0]));
        textBlock.setTopRight(CommUtils.frameToPoint(frames[1]));
        textBlock.setBottomRight(CommUtils.frameToPoint(frames[2]));
        textBlock.setBottomLeft(CommUtils.frameToPoint(frames[3]));
        textBlocks.add(textBlock);
    }
    isEng = jsonObject.getStr("lang", "zh-Chs").equals("zh-Chs");
    return CommUtils.combineTextBlocks(textBlocks, isEng);
}
 
Example #2
Source File: HutoolController.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
@ApiOperation("JSONUtil使用:JSON解析工具类")
@GetMapping("/jsonUtil")
public CommonResult jsonUtil() {
    PmsBrand brand = new PmsBrand();
    brand.setId(1L);
    brand.setName("小米");
    brand.setShowStatus(1);
    //对象转化为JSON字符串
    String jsonStr = JSONUtil.parse(brand).toString();
    LOGGER.info("jsonUtil parse:{}", jsonStr);
    //JSON字符串转化为对象
    PmsBrand brandBean = JSONUtil.toBean(jsonStr, PmsBrand.class);
    LOGGER.info("jsonUtil toBean:{}", brandBean);
    List<PmsBrand> brandList = new ArrayList<>();
    brandList.add(brand);
    String jsonListStr = JSONUtil.parse(brandList).toString();
    //JSON字符串转化为列表
    brandList = JSONUtil.toList(new JSONArray(jsonListStr), PmsBrand.class);
    LOGGER.info("jsonUtil toList:{}", brandList);
    return CommonResult.success(null, "操作成功");
}
 
Example #3
Source File: RegexUtil.java    From SubTitleSearcher with Apache License 2.0 6 votes vote down vote up
/**
 * 获取匹配列表--2维数组
 * @param str
 * @param regex
 * @return
 */
public static JSONArray getMatchList(String str, String regex) {
	JSONArray list = new JSONArray();
	if (str == null) {
		return list;
	}
	Pattern pattern = Pattern.compile(regex);
	Matcher m = pattern.matcher(str);
	while (m.find()) {
		JSONArray row = new JSONArray();
		for(int i = 1; i <= m.groupCount(); i++){
			row.add(m.group(i));
		}
		list.add(row);
	}
	return list;
}
 
Example #4
Source File: RegexUtil.java    From SubTitleSearcher with Apache License 2.0 6 votes vote down vote up
public static JSONArray getMatchList(String str, String regex, int flags) {
	JSONArray list = new JSONArray();
	if (str == null) {
		return list;
	}
	Pattern pattern = Pattern.compile(regex, flags);
	Matcher m = pattern.matcher(str);
	while (m.find()) {
		JSONArray row = new JSONArray();
		for(int i = 1; i <= m.groupCount(); i++){
			row.add(m.group(i));
		}
		list.add(row);
	}
	return list;
}
 
Example #5
Source File: RegexUtil.java    From SubTitleSearcher with Apache License 2.0 6 votes vote down vote up
public static JSONArray getMatchList(String str, String regex, int flags) {
	JSONArray list = new JSONArray();
	if (str == null) {
		return list;
	}
	Pattern pattern = Pattern.compile(regex, flags);
	Matcher m = pattern.matcher(str);
	while (m.find()) {
		JSONArray row = new JSONArray();
		for(int i = 1; i <= m.groupCount(); i++){
			row.add(m.group(i));
		}
		list.add(row);
	}
	return list;
}
 
Example #6
Source File: RegexUtil.java    From SubTitleSearcher with Apache License 2.0 6 votes vote down vote up
/**
 * 获取匹配列表--2维数组
 * @param str
 * @param regex
 * @return
 */
public static JSONArray getMatchList(String str, String regex) {
	JSONArray list = new JSONArray();
	if (str == null) {
		return list;
	}
	Pattern pattern = Pattern.compile(regex);
	Matcher m = pattern.matcher(str);
	while (m.find()) {
		JSONArray row = new JSONArray();
		for(int i = 1; i <= m.groupCount(); i++){
			row.add(m.group(i));
		}
		list.add(row);
	}
	return list;
}
 
Example #7
Source File: ShooterCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	String fileName = "E:/_tmp/mov/downsizing.2017.720p.bluray.x264-geckos.mkv";
	//fileName = "H:/_tmp/MOV/超人特工队.720p.国英台粤.mkv";

	JSONArray list = DownList(fileName);
	System.out.println(list.toJSONString(8));
	
	String url = list.getJSONObject(0).getJSONArray("Files").getJSONObject(0).getStr("Link");
	//HtHttpUtil.http.debug = true;
	MyFileUtil.fileWrite("E:/_tmp/mov/a.ass", HtHttpUtil.http.get(url, null,null, "https://www.shooter.cn/api/subapi.php"), "UTF-8", "");
	
}
 
Example #8
Source File: TranslatorUtil.java    From eladmin with Apache License 2.0 5 votes vote down vote up
private static String parseResult(String inputJson){
    JSONArray jsonArray2 = (JSONArray) new JSONArray(inputJson).get(0);
    StringBuilder result = new StringBuilder();
    for (Object o : jsonArray2) {
        result.append(((JSONArray) o).get(0).toString());
    }
    return result.toString();
}
 
Example #9
Source File: TaskController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
@ApiOperation("查询全部")
@RequestMapping(value = "/all", method = RequestMethod.GET)
public Result<JSONArray> all() {
    List<Task> list = ts.getAllTask();
    Result<JSONArray> result = new Result<JSONArray>();
    JSONArray jsonArray = new JSONArray(list);
    result.setResult(jsonArray);
    return result;
}
 
Example #10
Source File: TranslatorUtil.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
private static String parseResult(String inputJson){
    JSONArray jsonArray2 = (JSONArray) new JSONArray(inputJson).get(0);
    StringBuilder result = new StringBuilder();
    for (Object o : jsonArray2) {
        result.append(((JSONArray) o).get(0).toString());
    }
    return result.toString();
}
 
Example #11
Source File: ApiController.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载字幕
 */
public void zimu_down() {
	HttpRequest request = getRequest();
	HttpResponse response = getResponse();
	String data = request.getParaToStr("data");
	if(data == null) {
		outJsonpMessage(request,response, 1, "请求数据错误");
		return;
	}
	
	JSONObject dataJson = JSONUtil.parseObj(data);
	JSONArray items = dataJson.getJSONArray("items");
	if(items == null || items.size()==0) {
		outJsonpMessage(request,response, 1, "请选择字幕文件");
		return;
	}
	//System.out.println(data);
	
	DownParm downParm;
	JSONObject row;
	int item_id;
	for(int i = 0; i < items.size(); i++) {
		row = items.getJSONObject(i);
		item_id = row.getInt("id");
		downParm = new DownParm();
		downParm.charset = row.getStr("charset", "");
		downParm.simplified = row.getBool("simplified", false);
		downParm.filenameType = row.getInt("filenameType", 1);

		try {
			DownZIMu.down(item_id, downParm);
		}catch(Exception e) {
			logger.error(e);
		}
		
	}
	outJsonpMessage(request,response, 0, "OK");
}
 
Example #12
Source File: ExtractApiController.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 获取初始化数据
 */
public void get_init_data() {
	JSONObject resp = new JSONObject();
	JSONArray list = new JSONArray();
	for (int i = 0; i < ExtractDialog.extractDialog.archiveFiles.size(); i++) {
		File file = ExtractDialog.extractDialog.archiveFiles.get(i);
		String title = file.getName();
		
		if(!ArrayUtil.contains(AppConfig.subExtNames, StringUtil.extName(file).toLowerCase())){
			continue;
		}
		
		String key = title;
		JSONObject row = new JSONObject();
		row.put("key", key);
		row.put("title", title);
		row.put("size", file.length());
		row.put("sizeF", StringUtil.getPrintSize(file.length()));
		
		list.add(row);
	}
	resp.put("list", list);
	resp.put("title", ExtractDialog.extractDialog.title);
	resp.put("archiveExt", ExtractDialog.extractDialog.archiveExt);
	resp.put("archiveSize", ExtractDialog.extractDialog.archiveData.length);
	resp.put("archiveSizeF", StringUtil.getPrintSize(ExtractDialog.extractDialog.archiveData.length));
	
	outJsonpMessage(request,response, 0, "OK", resp);
}
 
Example #13
Source File: ExtractApiController.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载压缩文件中的字幕
 * @param data
 * @return
 */
public void down_archive_file() {
	HttpRequest request = getRequest();
	HttpResponse response = getResponse();
	String data = request.getParaToStr("data");
	if(data == null) {
		outJsonpMessage(request,response, 1, "请求数据错误");
		return;
	}
	logger.info("data="+data);
	if(data == null || data.length() < 10) {
		logger.error("data=null");
		outJsonpMessage(request,response, 1, "参数错误");
		return;
	}
	JSONObject dataJson = JSONUtil.parseObj(data);
	JSONArray items = dataJson.getJSONArray("items");
	if(items == null || items.size() == 0) {
		logger.error("items=null");
		outJsonpMessage(request,response, 1, "参数错误");
		return;
	}
	
	JSONObject resp = new JSONObject();
	resp.put("saveSelected", ExtractDialog.extractDialog.saveSelected(items));
	outJsonpMessage(request,response, 0, "OK", resp);
}
 
Example #14
Source File: TranslatorUtil.java    From sk-admin with Apache License 2.0 5 votes vote down vote up
private static String parseResult(String inputJson){
    JSONArray jsonArray2 = (JSONArray) new JSONArray(inputJson).get(0);
    StringBuilder result = new StringBuilder();
    for (Object o : jsonArray2) {
        result.append(((JSONArray) o).get(0).toString());
    }
    return result.toString();
}
 
Example #15
Source File: ExtractDialog.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
public boolean saveSelected(JSONArray items) {
	for (int i = 0; i < items.size(); i++) {
		JSONObject item = items.getJSONObject(i);
		DownParm downParm = new DownParm();
		downParm.charset = item.getStr("charset", "");
		downParm.simplified = item.getBool("simplified", false);
		downParm.filenameType = item.getInt("filenameType", 1);
		saveFile(item.getStr("title"), downParm);
	}
	return true;
}
 
Example #16
Source File: ZIMuKuCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 获取下载网址列表
 * @return
 */
public static JSONArray getDetailList(String url) {
	String result = httpGet(baseUrl+url);
	//System.out.println(result);
	Document doc = Jsoup.parse(result);
	Elements matchList = doc.select("#subtb tbody tr");
	if(matchList.size() == 0)return new JSONArray();
	//System.out.println(matchList.html());
	JSONArray resList = new JSONArray();
	for(int i  = 0 ; i < matchList.size(); i++) {
		Element row = matchList.get(i);
		JSONObject resRow = new JSONObject();
		resRow.put("url", row.selectFirst("a").attr("href"));
		resRow.put("title", row.selectFirst("a").attr("title"));
		resRow.put("ext", row.selectFirst(".label-info").text());
		Elements authorInfos = row.select(".gray");
		StringBuffer authorInfo = new StringBuffer();
		authorInfos.forEach(element ->{
			authorInfo.append(element.text() + ",");
		});
		if(authorInfo.length() > 0) {
			resRow.put("authorInfo", authorInfo.toString().substring(0, authorInfo.length()-1));
		}else {
			resRow.put("authorInfo", "");
		}
		
		resRow.put("lang", row.selectFirst("img").attr("alt"));
		resRow.put("rate", row.selectFirst(".rating-star").attr("title").replace("字幕质量:", ""));
		resRow.put("downCount", row.select("td").get(3).text());
		resList.add(resRow);
	}
	return resList;
}
 
Example #17
Source File: ShooterCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
public static JSONArray DownList(String fileName) throws Exception {
	HashMap<String, Object> paramMap = new HashMap<String, Object>();
	paramMap.put("filehash", getHash(fileName));
	paramMap.put("pathinfo", StringUtil.basename(fileName));
	paramMap.put("format", "json");
	paramMap.put("lang", "Chn");
	byte[] result = HtHttpUtil.http.postBytes("https://www.shooter.cn/api/subapi.php", paramMap);
	if(result == null || result.length==0 || result[0] == -1) {
		logger.error("未查询到结果");
		return null;
	}
	return JSONUtil.parseArray(new String(result));
}
 
Example #18
Source File: XunLeiCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
public static JSONArray DownList(String fileName) throws Exception {
	String cid = getCid(fileName);
	String result = HtHttpUtil.http.get(String.format("http://sub.xmp.sandai.net:8000/subxl/%s.json", cid));
	if(result == null) {
		logger.error("未查询到结果");
		return null;
	}
	//System.out.println(result);
	JSONObject json = JSONUtil.parseObj(result);
	return json.getJSONArray("sublist");
}
 
Example #19
Source File: SubHDCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载字幕列表
 * @param fileName
 * @return
 * @throws Exception
 */
public static JSONArray DownList(String fileName) throws Exception {
	JSONArray mainList = getFuzzyPageList(fileName);
	//System.out.println(mainList);
	
	JSONArray resp = new JSONArray();
	for(int i = 0; i < mainList.size(); i++) {
		JSONArray row = mainList.getJSONArray(i);
		//System.out.println("row="+row);
		JSONArray detailList = getDetailList(row.getStr(0));
		resp.addAll(detailList);
	}
	return resp;
}
 
Example #20
Source File: SubHDCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 获取页面列表
 * @param title
 * @return
 */
public static JSONArray getPageList(String title) {
	String result = HtHttpUtil.http.get(baseUrl+"/search0/"+URLUtil.encodeAll(title, CharsetUtil.CHARSET_UTF_8), HtHttpUtil.http.default_charset,HtHttpUtil.http._ua, baseUrl);
	//System.out.println(result);
	JSONArray resList = RegexUtil.getMatchList(result, "<a href=\"(/do[\\w]+/[\\w]+)\"><img", Pattern.DOTALL);
	//System.out.println(resList);
	if(resList == null) {
		return new JSONArray();
	}
	
	return resList;
}
 
Example #21
Source File: ZIMuKuCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载字幕列表
 * @param fileName
 * @return
 * @throws Exception
 */
public static JSONArray DownList(String fileName) throws Exception {
	JSONArray mainList = getFuzzyPageList(fileName);
	//System.out.println(mainList);
	
	JSONArray resp = new JSONArray();
	for(int i = 0; i < mainList.size(); i++) {
		JSONArray row = mainList.getJSONArray(i);
		//System.out.println("row="+row);
		JSONArray detailList = getDetailList(row.getStr(0));
		if(detailList ==  null)continue;
		resp.addAll(detailList);
	}
	return resp;
}
 
Example #22
Source File: ZIMuKuCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载字幕
 * @param url
 * @return
 */
public static JSONObject downContent(String url) {
	String result = httpGet(baseUrl+url);
	String downUrl = RegexUtil.getMatchStr(result, 
			"<a\\s+id=\"down1\"\\s+href=\"([^\"]*/dld/[\\w]+\\.html)\""
			, Pattern.DOTALL);
	if(downUrl == null)return null;
	if(!downUrl.startsWith("http")) {
		downUrl = baseUrl + downUrl;
	}
	
	result = httpGet(downUrl);
	if(result == null)return null;
	//System.out.println(result);
	JSONArray resList = RegexUtil.getMatchList(result, 
			"<li><a\\s+rel=\"nofollow\"\\s+href=\"([^\"]*/download/[^\"]+)\"", Pattern.DOTALL);
	if(resList == null || resList.size() == 0 || resList.getJSONArray(0).size() == 0)return null;
	//HtHttpUtil.http.debug=true;
	HttpResponse httpResp = HtHttpUtil.http.getResponse(addBaseUrl(resList.getJSONArray(0).getStr(0)), null, downUrl);
	int i = 0;
	while(httpResp == null && resList.size() > ++i) {
		httpResp = HtHttpUtil.http.getResponse(addBaseUrl(resList.getJSONArray(1).getStr(0)), null, downUrl);
	}
	//System.out.println(httpResp);
	if(httpResp == null)return null;
	String filename = HtHttpUtil.getFileName(httpResp);
	byte[] data = httpResp.bodyBytes();
	//System.out.println(filename);
	JSONObject resp = new JSONObject();
	resp.put("filename", filename);
	resp.put("ext", StringUtil.extName(filename).toLowerCase());
	resp.put("data", Base64.encode(data));
	
	return resp;
}
 
Example #23
Source File: ZIMuKuCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 获取页面列表
 * @param title
 * @return
 */
public static JSONArray getPageList(String title) {
	String result = httpGet(baseUrl+"/search?q="+URLUtil.encodeAll(title, CharsetUtil.CHARSET_UTF_8));
	//System.out.println(result);
	JSONArray resList = RegexUtil.getMatchList(result, "<p\\s+class=\"tt\\s+clearfix\"><a\\s+href=\"(/subs/[\\w]+\\.html)\"\\s+"
			+ "target=\"_blank\"><b>(.*?)</b></a></p>", Pattern.DOTALL);
	//System.out.println(resList);
	if(resList == null) {
		return new JSONArray();
	}
	
	return resList;
}
 
Example #24
Source File: SubHDCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载字幕列表
 * @param fileName
 * @return
 * @throws Exception
 */
public static JSONArray DownList(String fileName) throws Exception {
	JSONArray mainList = getFuzzyPageList(fileName);
	//System.out.println(mainList);
	
	JSONArray resp = new JSONArray();
	for(int i = 0; i < mainList.size(); i++) {
		JSONArray row = mainList.getJSONArray(i);
		//System.out.println("row="+row);
		JSONArray detailList = getDetailList(row.getStr(0));
		resp.addAll(detailList);
	}
	return resp;
}
 
Example #25
Source File: OcrUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static String extractBdResult(String html) {
    if (StrUtil.isBlank(html)) {
        return "";
    }
    JSONObject jsonObject = JSONUtil.parseObj(html);
    if (jsonObject.getInt("errno", 0) != 0) {
        return "";
    }
    JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("words_result");
    List<TextBlock> textBlocks = new ArrayList<>();
    boolean isEng = false;
    for (int i = 0; i < jsonArray.size(); i++) {
        JSONObject jObj = jsonArray.getJSONObject(i);
        TextBlock textBlock = new TextBlock();
        textBlock.setText(jObj.getStr("words").trim());
        //noinspection SuspiciousToArrayCall
        JSONObject location = jObj.getJSONObject("location");
        int top = location.getInt("top");
        int left = location.getInt("left");
        int width = location.getInt("width");
        int height = location.getInt("height");
        textBlock.setTopLeft(new Point(top, left));
        textBlock.setTopRight(new Point(top, left + width));
        textBlock.setBottomLeft(new Point(top + height, left));
        textBlock.setBottomRight(new Point(top + height, left + width));
        textBlocks.add(textBlock);
    }
    return CommUtils.combineTextBlocks(textBlocks, isEng);
}
 
Example #26
Source File: ApiController.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载字幕
 */
public void zimu_down() {
	HttpRequest request = getRequest();
	HttpResponse response = getResponse();
	String data = request.getParaToStr("data");
	if(data == null) {
		outJsonpMessage(request,response, 1, "请求数据错误");
		return;
	}
	
	JSONObject dataJson = JSONUtil.parseObj(data);
	JSONArray items = dataJson.getJSONArray("items");
	if(items == null || items.size()==0) {
		outJsonpMessage(request,response, 1, "请选择字幕文件");
		return;
	}
	//System.out.println(data);
	
	DownParm downParm;
	JSONObject row;
	int item_id;
	for(int i = 0; i < items.size(); i++) {
		row = items.getJSONObject(i);
		item_id = row.getInt("id");
		downParm = new DownParm();
		downParm.charset = row.getStr("charset", "");
		downParm.simplified = row.getBool("simplified", false);
		downParm.filenameType = row.getInt("filenameType", 1);

		try {
			DownZIMu.down(item_id, downParm);
		}catch(Exception e) {
			logger.error(e);
		}
		
	}
	outJsonpMessage(request,response, 0, "OK");
}
 
Example #27
Source File: ExtractApiController.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 获取初始化数据
 */
public void get_init_data() {
	JSONObject resp = new JSONObject();
	JSONArray list = new JSONArray();
	for (int i = 0; i < ExtractDialog.extractDialog.archiveFiles.size(); i++) {
		File file = ExtractDialog.extractDialog.archiveFiles.get(i);
		String title = file.getName();
		
		if(!ArrayUtil.contains(AppConfig.subExtNames, StringUtil.extName(file).toLowerCase())){
			continue;
		}
		
		String key = title;
		JSONObject row = new JSONObject();
		row.put("key", key);
		row.put("title", title);
		row.put("size", file.length());
		row.put("sizeF", StringUtil.getPrintSize(file.length()));
		
		list.add(row);
	}
	resp.put("list", list);
	resp.put("title", ExtractDialog.extractDialog.title);
	resp.put("archiveExt", ExtractDialog.extractDialog.archiveExt);
	resp.put("archiveSize", ExtractDialog.extractDialog.archiveData.length);
	resp.put("archiveSizeF", StringUtil.getPrintSize(ExtractDialog.extractDialog.archiveData.length));
	
	outJsonpMessage(request,response, 0, "OK", resp);
}
 
Example #28
Source File: ExtractApiController.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
/**
 * 下载压缩文件中的字幕
 * @param data
 * @return
 */
public void down_archive_file() {
	HttpRequest request = getRequest();
	HttpResponse response = getResponse();
	String data = request.getParaToStr("data");
	if(data == null) {
		outJsonpMessage(request,response, 1, "请求数据错误");
		return;
	}
	logger.info("data="+data);
	if(data == null || data.length() < 10) {
		logger.error("data=null");
		outJsonpMessage(request,response, 1, "参数错误");
		return;
	}
	JSONObject dataJson = JSONUtil.parseObj(data);
	JSONArray items = dataJson.getJSONArray("items");
	if(items == null || items.size() == 0) {
		logger.error("items=null");
		outJsonpMessage(request,response, 1, "参数错误");
		return;
	}
	
	JSONObject resp = new JSONObject();
	resp.put("saveSelected", ExtractDialog.extractDialog.saveSelected(items));
	outJsonpMessage(request,response, 0, "OK", resp);
}
 
Example #29
Source File: ShooterCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	String fileName = "E:/_tmp/mov/downsizing.2017.720p.bluray.x264-geckos.mkv";
	//fileName = "H:/_tmp/MOV/超人特工队.720p.国英台粤.mkv";

	JSONArray list = DownList(fileName);
	System.out.println(list.toJSONString(8));
	
	String url = list.getJSONObject(0).getJSONArray("Files").getJSONObject(0).getStr("Link");
	//HtHttpUtil.http.debug = true;
	MyFileUtil.fileWrite("E:/_tmp/mov/a.ass", HtHttpUtil.http.get(url, null,null, "https://www.shooter.cn/api/subapi.php"), "UTF-8", "");
	
}
 
Example #30
Source File: ShooterCommon.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
public static JSONArray DownList(String fileName) throws Exception {
	HashMap<String, Object> paramMap = new HashMap<String, Object>();
	paramMap.put("filehash", getHash(fileName));
	paramMap.put("pathinfo", StringUtil.basename(fileName));
	paramMap.put("format", "json");
	paramMap.put("lang", "Chn");
	byte[] result = HtHttpUtil.http.postBytes("https://www.shooter.cn/api/subapi.php", paramMap);
	if(result == null || result.length==0 || result[0] == -1) {
		logger.error("未查询到结果");
		return null;
	}
	return JSONUtil.parseArray(new String(result));
}