├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── 1_package.bat ├── 2_export_jre-10.bat ├── 3_publish.bat ├── 4_publish-new.bat ├── LICENSE ├── README.md ├── __upgrade_files └── SubTitleSearcher.exe ├── _release ├── _debug.bat ├── bin │ ├── 7z.dll │ └── 7z.exe ├── copy_files.exe ├── unzip.exe └── zip.exe ├── _upgrade ├── info.txt ├── last ├── last_exe └── last_zip ├── assembly.xml ├── docs ├── Java11 & JavaFX 初体验 - Java 代码生成 Markdown 的小工具 - 个人文章 - SegmentFault 思否.url ├── SubTitleSearcher.png ├── WebEngine (JavaFX 8).url ├── ej-technologies - Java APM, Java Profiler, Java Installer Builder.url ├── screenshot │ ├── p1.png │ └── p2.png ├── upgrade_cmd │ ├── upgrade_exe.cmd │ ├── upgrade_zip - 副本.cmd │ └── upgrade_zip.cmd ├── 下一版功能.txt ├── 字幕库 │ └── 下载流程.vsdx └── 射手网 │ ├── SPlayer视频文件hash算法 - Google 文档.mht │ ├── SPlayer视频文件hash算法 - Google 文档.url │ ├── 射手影音智能字幕查询API(JSON) - Google 文档.mht │ └── 射手影音智能字幕查询API(JSON) - Google 文档.url ├── lib └── simplewebserver-0.2.40.jar ├── pom.xml └── src └── main ├── java ├── com │ └── hibegin │ │ └── common │ │ └── util │ │ └── MyLogger.java └── zimu │ ├── AppConfig.java │ ├── AppMain.java │ ├── common │ ├── UpgradeCommon.java │ ├── ZiMuCommon.java │ └── sites │ │ ├── ShooterCommon.java │ │ ├── SubHDCommon.java │ │ ├── SubHDCommon.java.jodd │ │ ├── XunLeiCommon.java │ │ └── ZIMuKuCommon.java │ ├── down │ └── DownZIMu.java │ ├── gui │ ├── AboutDialog.java │ ├── ExtractDialog.java │ ├── GuiConfig.java │ ├── MainWin.java │ ├── MainWinJsApp.java │ └── parms │ │ ├── DownParm.java │ │ ├── MovFileInfo.java │ │ └── SearchParm.java │ ├── server │ ├── MyHttpJsonMessageConverter.java │ ├── ServerMain.java │ └── controllers │ │ ├── ApiController.java │ │ ├── Base.java │ │ ├── ExtractApiController.java │ │ └── IndexController.java │ ├── tests │ ├── Test1.java │ └── Test2.java │ └── util │ ├── ExeJsUtil.java │ ├── HtHttpUtil.java │ ├── MyFileUtil.java │ ├── StringUtil.java │ ├── WinRarUtil.java │ └── regex │ ├── AbstractReplaceCallBack.java │ ├── RegexUtil.java │ ├── ReplaceCallBack.java │ └── Test.java └── resources ├── html ├── extract_dialog.html ├── images │ ├── btn_about.png │ ├── css │ │ └── style.css │ └── js │ │ ├── common.js │ │ ├── extract_dialog.js │ │ ├── jquery.min.js │ │ ├── layer │ │ ├── layer.js │ │ └── theme │ │ │ └── default │ │ │ ├── icon-ext.png │ │ │ ├── icon.png │ │ │ ├── layer.css │ │ │ ├── loading-0.gif │ │ │ ├── loading-1.gif │ │ │ └── loading-2.gif │ │ ├── main.js │ │ ├── mainwin.js │ │ └── plugins │ │ ├── ContextMenu │ │ ├── contextMenu.css │ │ └── contextMenu.js │ │ └── newforms │ │ ├── jquery.newforms.js │ │ └── skins │ │ └── default │ │ ├── checkbox.png │ │ ├── date-trigger.png │ │ ├── radio.png │ │ ├── spinner.png │ │ ├── style.css │ │ └── trigger.png └── mainwin.html └── res ├── icon ├── app.ico └── app.png └── img ├── about.png └── loading.gif /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /_publish 2 | /target 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SubTitleSearcher 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled 3 | org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore 4 | org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull 5 | org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= 6 | org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault 7 | org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= 8 | org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable 9 | org.eclipse.jdt.core.compiler.annotation.nullable.secondary= 10 | org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled 11 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 12 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 13 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 14 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 15 | org.eclipse.jdt.core.compiler.compliance=1.8 16 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 17 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 18 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 19 | org.eclipse.jdt.core.compiler.problem.APILeak=warning 20 | org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning 21 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 22 | org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 23 | org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning 24 | org.eclipse.jdt.core.compiler.problem.deadCode=warning 25 | org.eclipse.jdt.core.compiler.problem.deprecation=warning 26 | org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 27 | org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 28 | org.eclipse.jdt.core.compiler.problem.discouragedReference=warning 29 | org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore 30 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 31 | org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore 32 | org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore 33 | org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled 34 | org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore 35 | org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning 36 | org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning 37 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 38 | org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning 39 | org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled 40 | org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning 41 | org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning 42 | org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore 43 | org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore 44 | org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning 45 | org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore 46 | org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore 47 | org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled 48 | org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 49 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 50 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled 51 | org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning 52 | org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 53 | org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning 54 | org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning 55 | org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore 56 | org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning 57 | org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning 58 | org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error 59 | org.eclipse.jdt.core.compiler.problem.nullReference=warning 60 | org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error 61 | org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning 62 | org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning 63 | org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore 64 | org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning 65 | org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore 66 | org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore 67 | org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore 68 | org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning 69 | org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning 70 | org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore 71 | org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore 72 | org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore 73 | org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore 74 | org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore 75 | org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled 76 | org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning 77 | org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled 78 | org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled 79 | org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled 80 | org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore 81 | org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning 82 | org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning 83 | org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled 84 | org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning 85 | org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning 86 | org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore 87 | org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning 88 | org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning 89 | org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled 90 | org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info 91 | org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore 92 | org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore 93 | org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore 94 | org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning 95 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore 96 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled 97 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled 98 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled 99 | org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore 100 | org.eclipse.jdt.core.compiler.problem.unusedImport=warning 101 | org.eclipse.jdt.core.compiler.problem.unusedLabel=warning 102 | org.eclipse.jdt.core.compiler.problem.unusedLocal=warning 103 | org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore 104 | org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore 105 | org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled 106 | org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled 107 | org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled 108 | org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning 109 | org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore 110 | org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning 111 | org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 112 | org.eclipse.jdt.core.compiler.release=disabled 113 | org.eclipse.jdt.core.compiler.source=1.8 114 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /1_package.bat: -------------------------------------------------------------------------------- 1 | rd /s /q target\classes 2 | mvn package 3 | -------------------------------------------------------------------------------- /2_export_jre-10.bat: -------------------------------------------------------------------------------- 1 | set JAVA_HOME=D:\Java\jdk-10\ 2 | set CLASSPATH=%JAVA_HOME%\jre\lib\rt.jar;%JAVA_HOME%\lib\tools.jar 3 | set PATH=%JAVA_HOME%\bin 4 | set PUBLISH_PATH=_publish 5 | set PUBLISH_JRE_PATH=%PUBLISH_PATH%\jre 6 | rd /s /q %PUBLISH_JRE_PATH%\ 7 | jlink -p %JAVA_HOME%/jmods --add-modules jdk.crypto.ec,java.sql,javafx.base,javafx.swing,javafx.web --output %PUBLISH_JRE_PATH% 8 | rd /s /q %PUBLISH_JRE_PATH%\legal 9 | rd /s /q %PUBLISH_JRE_PATH%\include 10 | 11 | rd /s /q %PUBLISH_JRE_PATH%\lib\server 12 | del /q %PUBLISH_JRE_PATH%\bin\api-ms-win* 13 | del /q %PUBLISH_JRE_PATH%\bin\appletviewer.exe 14 | del /q %PUBLISH_JRE_PATH%\bin\keytool.exe 15 | del /q %PUBLISH_JRE_PATH%\bin\ucrtbase.dll 16 | del /q %PUBLISH_JRE_PATH%\bin\gstreamer-lite.dll 17 | del /q %PUBLISH_JRE_PATH%\bin\concrt140.dll 18 | del /q %PUBLISH_JRE_PATH%\release 19 | 20 | -------------------------------------------------------------------------------- /3_publish.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/3_publish.bat -------------------------------------------------------------------------------- /4_publish-new.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/4_publish-new.bat -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SubTitleSearcher 2 | 字幕搜索查询(Java版),支持4k 2160p,1080p,720p视频字幕搜索,集合了字幕库、迅雷、射手、SubHD查询接口。 3 | 4 | **Go语言版本:** 5 | https://gitee.com/andyfoo/GoSubTitleSearcher 6 | https://github.com/Andyfoo/GoSubTitleSearcher 7 | 8 | **Java版本在此,不打算更新了:** 9 | https://gitee.com/andyfoo/SubTitleSearcher 10 | https://github.com/Andyfoo/SubTitleSearcher 11 | 12 | 13 | 可以拖动视频或选择视频开始搜索字幕 14 | ![可以拖动视频或选择视频开始搜索字幕](https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/master/docs/screenshot/p1.png) 15 | 16 | 可以单独或批量下载字幕,可复制标题文字 17 | ![可以单独或批量下载字幕,可复制标题文字](https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/master/docs/screenshot/p2.png) 18 | -------------------------------------------------------------------------------- /__upgrade_files/SubTitleSearcher.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/__upgrade_files/SubTitleSearcher.exe -------------------------------------------------------------------------------- /_release/_debug.bat: -------------------------------------------------------------------------------- 1 | SubTitleSearcher\jre\bin\java -Dfile.encoding=utf-8 -jar SubTitleSearcher\SubTitleSearcher.exe 2 | pause 3 | -------------------------------------------------------------------------------- /_release/bin/7z.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_release/bin/7z.dll -------------------------------------------------------------------------------- /_release/bin/7z.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_release/bin/7z.exe -------------------------------------------------------------------------------- /_release/copy_files.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_release/copy_files.exe -------------------------------------------------------------------------------- /_release/unzip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_release/unzip.exe -------------------------------------------------------------------------------- /_release/zip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_release/zip.exe -------------------------------------------------------------------------------- /_upgrade/info.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_upgrade/info.txt -------------------------------------------------------------------------------- /_upgrade/last: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/_upgrade/last -------------------------------------------------------------------------------- /_upgrade/last_exe: -------------------------------------------------------------------------------- 1 | { 2 | "version" : "2.3.2", 3 | "type" : "exe", 4 | "sign" : "F291284E72910317597C58FE4E9597A6", 5 | "desc" : "增加SubHd源,更新界面风格", 6 | "url" : "http://localhost:8080/update/SubTitleSearcher.exe", 7 | } -------------------------------------------------------------------------------- /_upgrade/last_zip: -------------------------------------------------------------------------------- 1 | { 2 | "version" : "2.3.2", 3 | "type" : "zip", 4 | "sign" : "68C710BCCF274487C55226C4B591770D", 5 | "desc" : "增加SubHd源,更新界面风格", 6 | "url" : "http://localhost:8080/update/SubTitleSearcher字幕下载.zip", 7 | } -------------------------------------------------------------------------------- /assembly.xml: -------------------------------------------------------------------------------- 1 | 5 | jar-with-dependencies 6 | 7 | jar 8 | 9 | false 10 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | 21 | true 22 | system 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/Java11 & JavaFX 初体验 - Java 代码生成 Markdown 的小工具 - 个人文章 - SegmentFault 思否.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://segmentfault.com/a/1190000018084677?utm_source=tag-newest 3 | -------------------------------------------------------------------------------- /docs/SubTitleSearcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/docs/SubTitleSearcher.png -------------------------------------------------------------------------------- /docs/WebEngine (JavaFX 8).url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://docs.oracle.com/javase/8/javafx/api/javafx/scene/web/WebEngine.html 3 | -------------------------------------------------------------------------------- /docs/ej-technologies - Java APM, Java Profiler, Java Installer Builder.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://www.ej-technologies.com/download/exe4j/files 3 | -------------------------------------------------------------------------------- /docs/screenshot/p1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/docs/screenshot/p1.png -------------------------------------------------------------------------------- /docs/screenshot/p2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/docs/screenshot/p2.png -------------------------------------------------------------------------------- /docs/upgrade_cmd/upgrade_exe.cmd: -------------------------------------------------------------------------------- 1 | cd %~dp0 2 | copy /Y new_ver.exe ..\SubTitleSearcher.exe 3 | start ..\SubTitleSearcher.exe 4 | cd .. 5 | ping -n 3 127.0.0.1>nul 6 | rd /S /Q upgrade 7 | -------------------------------------------------------------------------------- /docs/upgrade_cmd/upgrade_zip - 副本.cmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/docs/upgrade_cmd/upgrade_zip - 副本.cmd -------------------------------------------------------------------------------- /docs/upgrade_cmd/upgrade_zip.cmd: -------------------------------------------------------------------------------- 1 | cd %~dp0 2 | ..\bin\7z.exe x -y -aos new_ver.zip 3 | xcopy /Q /E /Y SubTitleSearcher\* ..\ 4 | start ..\SubTitleSearcher.exe 5 | cd .. 6 | ping -n 3 127.0.0.1>nul 7 | rd /S /Q upgrade 8 | -------------------------------------------------------------------------------- /docs/下一版功能.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/docs/下一版功能.txt -------------------------------------------------------------------------------- /docs/字幕库/下载流程.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/docs/字幕库/下载流程.vsdx -------------------------------------------------------------------------------- /docs/射手网/SPlayer视频文件hash算法 - Google 文档.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://docs.google.com/document/d/1w5MCBO61rKQ6hI5m9laJLWse__yTYdRugpVyz4RzrmM/preview 3 | -------------------------------------------------------------------------------- /docs/射手网/射手影音智能字幕查询API(JSON) - Google 文档.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://docs.google.com/document/d/1ufdzy6jbornkXxsD-OGl3kgWa4P9WO5NZb6_QYZiGI0/preview 3 | -------------------------------------------------------------------------------- /lib/simplewebserver-0.2.40.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/lib/simplewebserver-0.2.40.jar -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | SubTitleSearcher 7 | SubTitleSearcher 8 | 2.0.6.0 9 | 10 | UTF-8 11 | Copyright 2019 pslib.com 12 | 13 | 14 | 15 | cn.hutool 16 | hutool-core 17 | 4.5.16 18 | 19 | 20 | cn.hutool 21 | hutool-log 22 | 4.5.16 23 | 24 | 25 | cn.hutool 26 | hutool-json 27 | 4.5.16 28 | 29 | 30 | cn.hutool 31 | hutool-http 32 | 4.5.16 33 | 34 | 35 | cn.hutool 36 | hutool-crypto 37 | 4.5.16 38 | 39 | 40 | commons-cli 41 | commons-cli 42 | 1.2 43 | 44 | 45 | com.github.stuxuhai 46 | jpinyin 47 | 1.1.8 48 | 49 | 50 | org.jsoup 51 | jsoup 52 | 1.14.2 53 | 54 | 55 | 56 | com.hibegin 57 | simplewebserver 58 | 0.2.40 59 | system 60 | ${project.basedir}/lib/simplewebserver-0.2.40.jar 61 | 62 | 69 | 71 | 86 | 87 | 88 | 89 | 90 | org.apache.maven.plugins 91 | maven-compiler-plugin 92 | 93 | 1.8 94 | 1.8 95 | 96 | 97 | 98 | maven-assembly-plugin 99 | 100 | false 101 | SubTitleSearcher 102 | 103 | assembly.xml 104 | 105 | 106 | 107 | zimu.AppMain 108 | true 109 | 110 | 111 | 112 | 113 | 114 | package 115 | 116 | single 117 | 118 | 119 | 120 | 121 | 122 | com.akathist.maven.plugins.launch4j 123 | launch4j-maven-plugin 124 | 1.7.25 125 | 126 | 127 | l4j-gui 128 | package 129 | 130 | launch4j 131 | 132 | 133 | gui 134 | target/${project.artifactId}.exe 135 | target/${project.artifactId}.jar 136 | App Err 137 | 138 | zimu.AppMain 139 | false 140 | 141 | src/main/resources/res/icon/app.ico 142 | 143 | 1.7.0 144 | 1.8.0 145 | 32 146 | 256 147 | 148 | jre 149 | 150 | -Dfile.encoding=utf-8 151 | 152 | 153 | 154 | ${project.version} 155 | ${project.version} 156 | ${project.artifactId} 157 | ${copyright} 158 | ${project.version} 159 | ${project.version} 160 | ${project.artifactId} 161 | ${project.artifactId} 162 | ${project.artifactId}-${project.version}.exe 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /src/main/java/com/hibegin/common/util/MyLogger.java: -------------------------------------------------------------------------------- 1 | package com.hibegin.common.util; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | import java.util.logging.Level; 6 | 7 | import cn.hutool.log.Log; 8 | import cn.hutool.log.LogFactory; 9 | 10 | public class MyLogger { 11 | private Log logger; 12 | public MyLogger(Class clazz) { 13 | logger = LogFactory.get(clazz); 14 | } 15 | public static MyLogger getLogger(Class clazz) { 16 | return new MyLogger(clazz); 17 | } 18 | public void info(String msg) { 19 | logger.info(msg); 20 | } 21 | public void warning(String msg) { 22 | logger.warn(msg); 23 | } 24 | public void debug(String msg) { 25 | logger.info(msg); 26 | } 27 | public void error(String msg, Throwable thrown) { 28 | logger.error(thrown, msg); 29 | } 30 | public void log(Level level, String msg, Throwable thrown) { 31 | logger.info(thrown, msg); 32 | } 33 | public void log(Level level, String msg) { 34 | logger.info(msg); 35 | } 36 | 37 | /** 38 | * 记录完善的异常日志信息(包括堆栈信息) 39 | * 40 | * @param e 41 | * Exception 42 | */ 43 | public static String recordStackTraceMsg(Exception e) { 44 | StringWriter stringWriter = new StringWriter(); 45 | PrintWriter writer = new PrintWriter(stringWriter); 46 | e.printStackTrace(writer); 47 | StringBuffer buffer = stringWriter.getBuffer(); 48 | return buffer.toString(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/zimu/AppConfig.java: -------------------------------------------------------------------------------- 1 | package zimu; 2 | 3 | import cn.hutool.core.util.URLUtil; 4 | import zimu.util.StringUtil; 5 | 6 | public class AppConfig { 7 | public static String appName = "SubTitleSearcher"; 8 | public static String appTitle = "字幕下载"; 9 | //public static String appTitle = "SubTitleSearcher"; 10 | public static String appVer = "2.0.8"; 11 | 12 | public static String appPath; 13 | public static boolean isExe; 14 | 15 | public static int serverPort = 11122; 16 | 17 | public static String[] subExtNames = new String[] {"sup", "srt", "ass", "ssa"}; 18 | static { 19 | String path = AppMain.class.getProtectionDomain().getCodeSource().getLocation().getFile(); 20 | if(path.contains(":") && (path.startsWith("\\") || path.startsWith("/"))) { 21 | path = path.substring(1); 22 | } 23 | path = URLUtil.decode(path); 24 | String pathLcase = path.toLowerCase(); 25 | if(pathLcase.endsWith(".exe") || pathLcase.endsWith(".jar")) { 26 | path = StringUtil.dirname(path); 27 | isExe = true; 28 | }else { 29 | isExe = false; 30 | } 31 | appPath = path; 32 | System.out.println("appPath="+appPath); 33 | } 34 | 35 | //public static String upgradeUrl = "https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/master/_upgrade/last"; 36 | public static String upgradeUrl = "http://upgrade.res.pslib.com/my-apps/java/tools/SubTitleSearcher/last"; 37 | //public static String upgradeUrl = "http://localhost:8080/update/last"; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/zimu/AppMain.java: -------------------------------------------------------------------------------- 1 | package zimu; 2 | 3 | import java.io.File; 4 | 5 | import cn.hutool.log.Log; 6 | import cn.hutool.log.LogFactory; 7 | import zimu.common.UpgradeCommon; 8 | import zimu.gui.MainWin; 9 | import zimu.gui.parms.MovFileInfo; 10 | 11 | public class AppMain { 12 | static final Log logger = LogFactory.get(); 13 | public static void main(String[] args) { 14 | System.setProperty("crypto.policy", "unlimited"); 15 | //System.setProperty("https.protocols", "TLSv1.2,TLSv1.1,SSLv3"); 16 | try { 17 | //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 18 | //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); 19 | //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 20 | //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); 21 | //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); 22 | 23 | //UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel");//需要在相关的操作系统上方可实现 24 | //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");//需要在相关的操作系统上方可实现 25 | } catch (Exception e) { 26 | logger.error(e); 27 | } 28 | MainWin.get().init(); 29 | UpgradeCommon.autocheck(); 30 | if(args.length > 0) { 31 | //final File fileFromCommandLine = getFileFromCommandLine(args); 32 | //MainWin.setFile(fileFromCommandLine.getAbsolutePath()); 33 | if(args.length > 0) { 34 | String filepath = args[0]; 35 | File file = new File(filepath); 36 | if(file.exists()) { 37 | MovFileInfo.setFile(file.getAbsolutePath()); 38 | //MainWin.startSearch(); 39 | }else { 40 | filepath = System.getProperty("user.dir") + File.separator + filepath; 41 | file = new File(filepath); 42 | if(file.exists()) { 43 | MovFileInfo.setFile(file.getAbsolutePath()); 44 | //MainWin.startSearch(); 45 | } 46 | } 47 | } 48 | //JOptionPane.showMessageDialog(MainWin.frame, System.getProperty("user.dir")); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/zimu/common/UpgradeCommon.java: -------------------------------------------------------------------------------- 1 | package zimu.common; 2 | 3 | import java.awt.Desktop; 4 | import java.io.ByteArrayInputStream; 5 | import java.io.File; 6 | 7 | import cn.hutool.core.codec.Base64; 8 | import cn.hutool.core.util.StrUtil; 9 | import cn.hutool.crypto.SecureUtil; 10 | import cn.hutool.json.JSONObject; 11 | import cn.hutool.json.JSONUtil; 12 | import cn.hutool.log.Log; 13 | import cn.hutool.log.LogFactory; 14 | import zimu.AppConfig; 15 | import zimu.gui.MainWin; 16 | import zimu.util.HtHttpUtil; 17 | import zimu.util.MyFileUtil; 18 | 19 | public class UpgradeCommon { 20 | static final Log logger = LogFactory.get(); 21 | static JSONObject data = null; 22 | static String upgradeCmdExe = "Y2QgJX5kcDANCmNvcHkgL1kgbmV3X3Zlci5leGUgLi5cU3ViVGl0bGVTZWFyY2hlci5leGUNCnN0YXJ0IC4uXFN1YlRpdGxlU2VhcmNoZXIuZXhlDQpjZCAuLg0KcGluZyAtbiAzIDEyNy4wLjAuMT5udWwNCnJkIC9TIC9RIHVwZ3JhZGUNCg=="; 23 | static String upgradeCmdZip = "Y2QgJX5kcDANCi4uXGJpblw3ei5leGUgeCAteSAtYW9zIG5ld192ZXIuemlwDQp4Y29weSAvUSAvRSAvWSBTdWJUaXRsZVNlYXJjaGVyXCogLi5cDQpzdGFydCAuLlxTdWJUaXRsZVNlYXJjaGVyLmV4ZQ0KY2QgLi4NCnBpbmcgLW4gMyAxMjcuMC4wLjE+bnVsDQpyZCAvUyAvUSB1cGdyYWRlDQo="; 24 | 25 | /** 26 | * 下载更新 27 | * @return 28 | */ 29 | public static String download() { 30 | if(data == null || StrUtil.isEmpty(data.getStr("url"))) { 31 | logger.error("下载链接为空"); 32 | return null; 33 | } 34 | String url = data.getStr("url"); 35 | String sign = data.getStr("sign"); 36 | String type = data.getStr("type"); 37 | 38 | byte[] updateData = HtHttpUtil.http.getBytes(url); 39 | logger.info("下载完毕"); 40 | if(updateData==null) { 41 | logger.error("下载数据为空"); 42 | MainWin.frame.alert("下载错误,请稍后重试"); 43 | return null; 44 | } 45 | 46 | String sign2 = SecureUtil.md5(new ByteArrayInputStream(updateData));//145316371511956DB5540F2EA608800C; 47 | //System.out.println(sign2); 48 | if(!sign2.equalsIgnoreCase(sign)) { 49 | logger.error("下载数据签名错误"); 50 | MainWin.frame.alert("下载数据签名错误"); 51 | return null; 52 | } 53 | String filepath = AppConfig.appPath + "upgrade/"; 54 | MyFileUtil.dirCreate(filepath); 55 | String batFilename = filepath+"upgrade.cmd"; 56 | String batStr = ""; 57 | 58 | //生成更新bat文件 59 | if(type.equals("exe")){ 60 | String filename = filepath+"new_ver.exe"; 61 | MyFileUtil.fileWriteBin(filename, updateData); 62 | 63 | batStr = upgradeCmdExe; 64 | }else if(type.equals("zip")){ 65 | String filename = filepath+"new_ver.zip"; 66 | MyFileUtil.fileWriteBin(filename, updateData); 67 | 68 | batStr = upgradeCmdZip; 69 | }else { 70 | return null; 71 | } 72 | MyFileUtil.fileWriteBin(batFilename, Base64.decode(batStr)); 73 | 74 | 75 | //System.out.println(updateData.length); 76 | return batFilename; 77 | } 78 | 79 | /** 80 | * 判断是否有新版 81 | * @return 82 | */ 83 | public static boolean checkNewVersion() { 84 | String url = AppConfig.upgradeUrl; 85 | String str = HtHttpUtil.http.get(url); 86 | logger.info(str); 87 | data = JSONUtil.parseObj(str); 88 | if(data==null) { 89 | logger.error("未发现新版"); 90 | return false; 91 | } 92 | //System.out.println(data); 93 | return compareVersion(data.getStr("version"), AppConfig.appVer) > 0; 94 | } 95 | /** 96 | * 比较版本号的大小,前者大则返回一个正数,后者大返回一个负数,相等则返回0 97 | * 98 | * @param version1 99 | * @param version2 100 | * @return 101 | */ 102 | public static int compareVersion(String version1, String version2) { 103 | if (version1 == null || version2 == null) { 104 | return -999; 105 | } 106 | if (version1.equals(version2)) { 107 | return 0; 108 | } 109 | String[] versionArray1 = version1.split("\\.");// 注意此处为正则匹配,不能用"."; 110 | String[] versionArray2 = version2.split("\\."); 111 | int idx = 0; 112 | int minLength = Math.min(versionArray1.length, versionArray2.length);// 取最小长度值 113 | int diff = 0; 114 | while (idx < minLength && (diff = versionArray1[idx].length() - versionArray2[idx].length()) == 0// 先比较长度 115 | && (diff = versionArray1[idx].compareTo(versionArray2[idx])) == 0) {// 再比较字符 116 | ++idx; 117 | } 118 | // 如果已经分出大小,则直接返回,如果未分出大小,则再比较位数,有子版本的为大; 119 | diff = (diff != 0) ? diff : versionArray1.length - versionArray2.length; 120 | return diff; 121 | } 122 | 123 | /** 124 | * 开始更新 125 | */ 126 | public static void upgrade() { 127 | //Runtime rt = Runtime.getRuntime(); 128 | //StringBuffer result = new StringBuffer(); 129 | try { 130 | String upgradeCmd = download(); 131 | if(upgradeCmd == null) { 132 | logger.error("更新失败"); 133 | return; 134 | } 135 | logger.info("更新命令: "+upgradeCmd); 136 | Desktop.getDesktop().open(new File(upgradeCmd)); 137 | System.exit(0); 138 | //Process p = rt.exec(upgradeCmd); 139 | //p.waitFor(); 140 | 141 | // InputStream fis = p.getInputStream(); 142 | // InputStreamReader isr = new InputStreamReader(fis,"GBK"); 143 | // BufferedReader br = new BufferedReader(isr); 144 | // String line = null; 145 | // while ((line = br.readLine()) != null) { 146 | // result.append(line); 147 | // result.append("\r\n"); 148 | // } 149 | // logger.info(result.toString()); 150 | 151 | }catch(Exception e) { 152 | e.printStackTrace(); 153 | } 154 | } 155 | /** 156 | * 检测更新 157 | */ 158 | public static void autocheck() { 159 | new Thread() { 160 | public void run() { 161 | if(checkNewVersion()) { 162 | String desc = data.getStr("desc", ""); 163 | String version = data.getStr("version"); 164 | desc = desc.replace("
", "\n").replace("
", "\n"); 165 | MainWin.frame.confirm("检测到新版本:"+version+",是否更新?", "更新说明 :\n"+desc, new Runnable() { 166 | @Override 167 | public void run() { 168 | upgrade(); 169 | } 170 | }, null); 171 | } 172 | } 173 | }.start(); 174 | } 175 | public static void main(String[] args) { 176 | checkNewVersion(); 177 | System.out.println(System.getProperty("java.version")); 178 | //autocheck(); 179 | // System.out.println(checkNewVersion()); 180 | // System.out.println(download()); 181 | upgrade(); 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /src/main/java/zimu/common/ZiMuCommon.java: -------------------------------------------------------------------------------- 1 | package zimu.common; 2 | 3 | import java.awt.Toolkit; 4 | import java.awt.datatransfer.Clipboard; 5 | import java.awt.datatransfer.StringSelection; 6 | import java.awt.datatransfer.Transferable; 7 | import java.util.regex.Matcher; 8 | import java.util.regex.Pattern; 9 | 10 | public class ZiMuCommon { 11 | /** 12 | * 将字符串复制到剪切板。 13 | */ 14 | public static void copyClipboard(String writeMe) { 15 | Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); 16 | Transferable tText = new StringSelection(writeMe); 17 | clip.setContents(tText, null); 18 | } 19 | 20 | /** 21 | * 获取字符中的汉字部分 22 | * @param title 23 | * @return 24 | */ 25 | public static String getTitleCnStr(String title) { 26 | if(title == null)return ""; 27 | title = title.replace(":", ":"); 28 | //title = title.replace("_", "—"); 29 | //title = title.replace("-", "ˉ"); 30 | title = title.replace("[", "【"); 31 | title = title.replace("]", "】"); 32 | title = title.replace("修正版", ""); 33 | String[] arr = title.split("\\."); 34 | if(arr.length > 2) { 35 | title = title.substring(0, title.lastIndexOf(".")); 36 | } 37 | if(arr.length > 3) { 38 | title = title.substring(0, title.lastIndexOf(".")); 39 | } 40 | 41 | String title2 = title.replaceAll("【.*】", ""); 42 | 43 | //中文+标点组合 44 | Pattern pattern = Pattern.compile("[\u4E00-\u9FA5" 45 | + "\u3002\uff1f\uff01\uff0c\u3001\uff1b\uff1a\u201c" 46 | + "\u201d\u2018\u2019\uff08\uff09\u300a\u300b\u3008" 47 | + "\u3009\u3010\u3011\u300e\u300f\u300c\u300d\ufe43" 48 | + "\ufe44\u3014\u3015\u2026\u2014\uff5e\ufe4f\uffe5" 49 | + "\u02c9]+"); 50 | Matcher matcher = pattern.matcher(title2); 51 | String resStr = ""; 52 | if(matcher.find()) { 53 | resStr = matcher.group(0); 54 | }else { 55 | matcher = pattern.matcher(title); 56 | if(matcher.find()) { 57 | resStr = matcher.group(0); 58 | resStr = resStr.replaceAll("[【】]+", ""); 59 | } 60 | } 61 | //中文+英文+标点组合 62 | pattern = Pattern.compile("[\\w\u4E00-\u9FA5" 63 | + "\u3002\uff1f\uff01\uff0c\u3001\uff1b\uff1a\u201c" 64 | + "\u201d\u2018\u2019\uff08\uff09\u300a\u300b\u3008" 65 | + "\u3009\u3010\u3011\u300e\u300f\u300c\u300d\ufe43" 66 | + "\ufe44\u3014\u3015\u2026\u2014\uff5e\ufe4f\uffe5" 67 | + "\u02c9]+"); 68 | if((resStr == null || resStr.length() == 0) && Pattern.compile("[\u4E00-\u9FA5]+").matcher(title).find()) { 69 | matcher = pattern.matcher(title); 70 | if(matcher.find()) { 71 | resStr = matcher.group(0); 72 | resStr = resStr.replaceAll("[【】]+", ""); 73 | } 74 | } 75 | 76 | 77 | return resStr; 78 | } 79 | 80 | public static void main(String[] args) { 81 | // System.out.println("[缩小人生]Downsizing.2017.1080p.Bluray.MKV.x264.AC3修正版.ass [ASS/SSA][双语][下载次数:1709]". 82 | // replaceAll("\\[[^]]*]\\[[^]]*]\\[下载次数.+]", ""));; 83 | 84 | //System.out.println(getTitleCnStr("【X战警:逆转未来 导演剪辑版】X-Men.Days.of.Future.Past.THE.ROGUE.CUT.1080p.BluRay.x264-SADPANDA")); 85 | //System.exit(0); 86 | String[] titles = new String[] { 87 | "test.a.b.c", 88 | "我是中文.a.b.c", 89 | "我是中文 a.b.c", 90 | "我是中文a.b.c", 91 | "我是-中文a.b.c", 92 | "我是_中文a.b.c", 93 | "[我是中文]a.b.c", 94 | "【获取】我是中文a.b.c", 95 | "[获wee取]我是中文a.b.c", 96 | "[超人特工队(国粤台英)].The.Incredibles.2004.BluRay.720p.x264.AC3.4Audios-CMCT.完美匹配国语chsc", 97 | "[缩小人生]Downsizing.2017.1080p.Bluray.MKV.x264.AC3修正版", 98 | "X战警:第一战.X-Men.First.Class.2011.2160p.BluRay", 99 | "战X警:第一战.X-Men.First.Class.2011.2160p.BluRay", 100 | "【X战警:逆转未来 导演剪辑版】X-Men.Days.of.Future.Past.THE.ROGUE.CUT.1080p.BluRay.x264-SADPANDA" 101 | }; 102 | //System.out.println(getTitleCnStr("[获wee取]我是中文a.b.c")); 103 | for(int i = 0; i < titles.length; i++) { 104 | System.out.println(getTitleCnStr(titles[i])); 105 | } 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/zimu/common/sites/ShooterCommon.java: -------------------------------------------------------------------------------- 1 | package zimu.common.sites; 2 | 3 | import java.io.RandomAccessFile; 4 | import java.security.MessageDigest; 5 | import java.util.Arrays; 6 | import java.util.HashMap; 7 | 8 | import cn.hutool.json.JSONArray; 9 | import cn.hutool.json.JSONUtil; 10 | import cn.hutool.log.Log; 11 | import cn.hutool.log.LogFactory; 12 | import zimu.util.HtHttpUtil; 13 | import zimu.util.MyFileUtil; 14 | import zimu.util.StringUtil; 15 | 16 | public class ShooterCommon { 17 | static final Log logger = LogFactory.get(); 18 | private final static int BUFFER_SIZE = 4096; 19 | 20 | public static void main(String[] args) throws Exception { 21 | String fileName = "E:/_tmp/mov/downsizing.2017.720p.bluray.x264-geckos.mkv"; 22 | //fileName = "H:/_tmp/MOV/超人特工队.720p.国英台粤.mkv"; 23 | 24 | JSONArray list = DownList(fileName); 25 | System.out.println(list.toJSONString(8)); 26 | 27 | String url = list.getJSONObject(0).getJSONArray("Files").getJSONObject(0).getStr("Link"); 28 | //HtHttpUtil.http.debug = true; 29 | MyFileUtil.fileWrite("E:/_tmp/mov/a.ass", HtHttpUtil.http.get(url, null,null, "https://www.shooter.cn/api/subapi.php"), "UTF-8", ""); 30 | 31 | } 32 | public static JSONArray DownList(String fileName) throws Exception { 33 | HashMap paramMap = new HashMap(); 34 | paramMap.put("filehash", getHash(fileName)); 35 | paramMap.put("pathinfo", StringUtil.basename(fileName)); 36 | paramMap.put("format", "json"); 37 | paramMap.put("lang", "Chn"); 38 | byte[] result = HtHttpUtil.http.postBytes("https://www.shooter.cn/api/subapi.php", paramMap); 39 | if(result == null || result.length==0 || result[0] == -1) { 40 | logger.error("未查询到结果"); 41 | return null; 42 | } 43 | return JSONUtil.parseArray(new String(result)); 44 | } 45 | 46 | public static String getHash(String filePath) throws Exception{ 47 | 48 | RandomAccessFile file = new RandomAccessFile(filePath, "r"); 49 | long fileLength = file.length(); 50 | 51 | 52 | long[] positions = new long[]{4096, fileLength / 3 * 2, fileLength / 3, fileLength - 8192}; 53 | StringBuilder stringBuilder = new StringBuilder(); 54 | for (long position : positions) { 55 | byte[] buffer = new byte[BUFFER_SIZE]; 56 | if(fileLength < position) { 57 | file.close(); 58 | return stringBuilder.toString(); 59 | } 60 | file.seek(position); 61 | int realBufferSize = file.read(buffer); 62 | buffer = Arrays.copyOfRange(buffer, 0, realBufferSize); 63 | stringBuilder.append(bytesToMD5(buffer)); 64 | stringBuilder.append(";"); 65 | } 66 | file.close(); 67 | stringBuilder.deleteCharAt(stringBuilder.length() - 1); 68 | return stringBuilder.toString(); 69 | } 70 | 71 | private static String bytesToString(byte[] bytes){ 72 | StringBuilder stringBuilder = new StringBuilder(); 73 | for (byte b : bytes) { 74 | int bias = (b & 0xf0) >>> 4; 75 | stringBuilder.append(Integer.toHexString(bias)); 76 | bias = b & 0xf; 77 | stringBuilder.append(Integer.toHexString(bias)); 78 | } 79 | return stringBuilder.toString(); 80 | } 81 | 82 | 83 | private static String bytesToMD5(byte[] bytes) throws Exception{ 84 | MessageDigest messageDigest = MessageDigest.getInstance("MD5"); 85 | byte[] buffer = messageDigest.digest(bytes); 86 | return bytesToString(buffer); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/zimu/common/sites/SubHDCommon.java: -------------------------------------------------------------------------------- 1 | package zimu.common.sites; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.regex.Pattern; 6 | 7 | import org.jsoup.Jsoup; 8 | import org.jsoup.nodes.Document; 9 | import org.jsoup.nodes.Element; 10 | import org.jsoup.select.Elements; 11 | 12 | import cn.hutool.core.codec.Base64; 13 | import cn.hutool.core.util.CharsetUtil; 14 | import cn.hutool.core.util.URLUtil; 15 | import cn.hutool.json.JSONArray; 16 | import cn.hutool.json.JSONObject; 17 | import cn.hutool.json.JSONUtil; 18 | import cn.hutool.log.Log; 19 | import cn.hutool.log.LogFactory; 20 | import zimu.AppConfig; 21 | import zimu.util.HtHttpUtil; 22 | import zimu.util.StringUtil; 23 | import zimu.util.regex.RegexUtil; 24 | 25 | public class SubHDCommon { 26 | static final Log logger = LogFactory.get(); 27 | static String baseUrl = "https://subhd.tv"; 28 | 29 | public static void main(String[] args) throws Exception { 30 | //System.out.println(DownList("憨豆特工.mkv")); 31 | System.out.println(DownList("downsizing.2017.720p.bluray.x264-geckos.mkv")); 32 | //System.out.println(getDetailList("/a/378333")); 33 | 34 | 35 | //System.out.println(downContent("/ar0/378333"));; 36 | } 37 | /** 38 | * 下载字幕列表 39 | * @param fileName 40 | * @return 41 | * @throws Exception 42 | */ 43 | public static JSONArray DownList(String fileName) throws Exception { 44 | JSONArray mainList = getFuzzyPageList(fileName); 45 | //System.out.println(mainList); 46 | 47 | JSONArray resp = new JSONArray(); 48 | for(int i = 0; i < mainList.size(); i++) { 49 | JSONArray row = mainList.getJSONArray(i); 50 | //System.out.println("row="+row); 51 | JSONArray detailList = getDetailList(row.getStr(0)); 52 | resp.addAll(detailList); 53 | } 54 | return resp; 55 | } 56 | 57 | /** 58 | * 下载字幕 59 | * @param url 60 | * @return 61 | */ 62 | public static JSONObject downContent(String url) { 63 | String result = HtHttpUtil.http.get(baseUrl+url, HtHttpUtil.http.default_charset, HtHttpUtil.http._ua, baseUrl+url); 64 | Document doc = Jsoup.parse(result); 65 | Elements matchList = doc.select("#down"); 66 | if(matchList.size() == 0)return null; 67 | Element down = matchList.get(0); 68 | Map postData = new HashMap(); 69 | postData.put("sub_id", matchList.attr("sid")); 70 | postData.put("dtoken", down.attr("dtoken")); 71 | result = HtHttpUtil.http.post(baseUrl+"/ajax/down_ajax", postData); 72 | if(result == null || !result.contains("}"))return null; 73 | JSONObject resultJson = JSONUtil.parseObj(result); 74 | if(resultJson == null || !resultJson.getBool("success"))return null; 75 | String downUrl = resultJson.getStr("url"); 76 | String filename = StringUtil.basename(downUrl); 77 | //HtHttpUtil.http.debug=true; 78 | byte[] data = HtHttpUtil.http.getBytes(downUrl, HtHttpUtil.http._ua, baseUrl+url); 79 | 80 | JSONObject resp = new JSONObject(); 81 | resp.put("filename", filename); 82 | resp.put("ext", StringUtil.extName(filename).toLowerCase()); 83 | resp.put("data", Base64.encode(data)); 84 | 85 | 86 | return resp; 87 | } 88 | 89 | /** 90 | * 获取下载网址列表 91 | * @return 92 | */ 93 | public static JSONArray getDetailList(String url) { 94 | String result = HtHttpUtil.http.get(baseUrl+url, HtHttpUtil.http.default_charset, HtHttpUtil.http._ua, baseUrl+url); 95 | //System.out.println(result); 96 | Document doc = Jsoup.parse(result); 97 | Elements matchList = doc.select(".table-sm tr"); 98 | //System.out.println(matchList.html()); 99 | JSONArray detailList = new JSONArray(); 100 | for (Element matchRow : matchList) { 101 | if(matchRow.select("a.text-dark").size() == 0)continue; 102 | String html = matchRow.html(); 103 | String htmlLower = html.toLowerCase(); 104 | String downUrl = matchRow.select("a.text-dark").get(0).attr("href"); 105 | //System.out.println(downUrl); 106 | String title = matchRow.select("a.text-dark").get(0).text().trim(); 107 | int downCount = Integer.valueOf(RegexUtil.getMatchStr(matchRow.select("td.p-3").get(1).text(), "([\\d]+)")); 108 | String ext = ""; 109 | for(String extName : AppConfig.subExtNames) { 110 | //if(StrUtil.isNotEmpty(RegexUtil.getMatchStr(html, "(>"+extName+"<)", Pattern.CASE_INSENSITIVE))) { 111 | if(htmlLower.contains(">"+extName+"<")) { 112 | ext += extName; 113 | ext += ","; 114 | } 115 | } 116 | if(ext.endsWith(",")) { 117 | ext=ext.substring(0, ext.length()-1); 118 | }else { 119 | ext="其它"; 120 | } 121 | 122 | String lang = ""; 123 | String[] langList = new String[] {"双语", "简体", "繁体", "英文"}; 124 | for(String langName : langList) { 125 | if(htmlLower.contains(">"+langName+"<")) { 126 | lang += langName; 127 | lang += ","; 128 | } 129 | } 130 | if(lang.endsWith(",")) { 131 | lang=lang.substring(0, lang.length()-1); 132 | }else { 133 | lang="其它"; 134 | } 135 | 136 | Elements labels = matchRow.select(".text-secondary span"); 137 | StringBuffer labelInfo = new StringBuffer(); 138 | labels.forEach(element ->{ 139 | labelInfo.append(element.text() + ","); 140 | }); 141 | if(labelInfo.length() > 0) { 142 | labelInfo.delete(labelInfo.length()-1, labelInfo.length()); 143 | } 144 | String zimuzu = ""; 145 | if((matchRow.select("a").get(0).attr("href")+"").contains("/zu/")) { 146 | zimuzu = matchRow.select("a").get(0).text(); 147 | } 148 | 149 | JSONObject dataRow = new JSONObject(); 150 | dataRow.put("url", downUrl); 151 | dataRow.put("baseUrl", baseUrl); 152 | dataRow.put("title", title); 153 | dataRow.put("ext", ext); 154 | dataRow.put("lang",lang); 155 | dataRow.put("rate", "-"); 156 | dataRow.put("downCount", downCount); 157 | dataRow.put("labelInfo", labelInfo); 158 | dataRow.put("zimuzu", zimuzu); 159 | detailList.add(dataRow); 160 | } 161 | return detailList; 162 | } 163 | 164 | /** 165 | * 模糊查询页面列表 166 | * @param title 167 | * @return 168 | */ 169 | public static JSONArray getFuzzyPageList(String title) { 170 | int pos = title.lastIndexOf("."); 171 | title = title.toLowerCase(); 172 | title = pos > 0 ? title.substring(0, pos) : title; 173 | JSONArray list = getPageList(title); 174 | if(list.size() == 0 && (pos = title.lastIndexOf("bluray")) > 0) { 175 | title = title.substring(0, pos+6); 176 | list = getPageList(title); 177 | } 178 | if(list.size() == 0 && (pos = title.lastIndexOf(".2160p")) > 0) { 179 | title = title.substring(0, pos+6); 180 | list = getPageList(title); 181 | if(list.size() == 0) { 182 | title = title.substring(0, pos); 183 | list = getPageList(title); 184 | } 185 | } 186 | if(list.size() == 0 && (pos = title.lastIndexOf(".1080p")) > 0) { 187 | title = title.substring(0, pos+6); 188 | list = getPageList(title); 189 | if(list.size() == 0) { 190 | title = title.substring(0, pos); 191 | list = getPageList(title); 192 | } 193 | } 194 | if(list.size() == 0 && (pos = title.lastIndexOf(".720p")) > 0) { 195 | title = title.substring(0, pos+5); 196 | list = getPageList(title); 197 | if(list.size() == 0) { 198 | title = title.substring(0, pos); 199 | list = getPageList(title); 200 | } 201 | } 202 | if(list.size() == 0 && (pos = title.lastIndexOf(".480p")) > 0) { 203 | title = title.substring(0, pos+5); 204 | list = getPageList(title); 205 | if(list.size() == 0) { 206 | title = title.substring(0, pos); 207 | list = getPageList(title); 208 | } 209 | } 210 | if(list.size() == 0 && (pos = title.lastIndexOf(".internal")) > 0) { 211 | title = title.substring(0, pos+9); 212 | list = getPageList(title); 213 | if(list.size() == 0) { 214 | title = title.substring(0, pos); 215 | list = getPageList(title); 216 | } 217 | } 218 | //System.out.println(list); 219 | return list; 220 | } 221 | /** 222 | * 获取页面列表 223 | * @param title 224 | * @return 225 | */ 226 | public static JSONArray getPageList(String title) { 227 | String result = HtHttpUtil.http.get(baseUrl+"/search0/"+URLUtil.encodeAll(title, CharsetUtil.CHARSET_UTF_8), HtHttpUtil.http.default_charset,HtHttpUtil.http._ua, baseUrl); 228 | //System.out.println(result); 229 | JSONArray resList = RegexUtil.getMatchList(result, " postData = new HashMap(); 65 | postData.put("sub_id", down.attr("sid")); 66 | postData.put("dtoken", down.attr("dtoken")); 67 | result = HtHttpUtil.http.post(baseUrl+"/ajax/down_ajax", postData); 68 | if(result == null || !result.contains("}"))return null; 69 | JSONObject resultJson = JSONUtil.parseObj(result); 70 | if(resultJson == null || !resultJson.getBool("success"))return null; 71 | String downUrl = resultJson.getStr("url"); 72 | String filename = StringUtil.basename(downUrl); 73 | //HtHttpUtil.http.debug=true; 74 | byte[] data = HtHttpUtil.http.getBytes(downUrl, HtHttpUtil.http._ua, baseUrl+url); 75 | 76 | JSONObject resp = new JSONObject(); 77 | resp.put("filename", filename); 78 | resp.put("ext", StringUtil.extName(filename).toLowerCase()); 79 | resp.put("data", Base64.encode(data)); 80 | 81 | 82 | return resp; 83 | } 84 | 85 | /** 86 | * 获取下载网址列表 87 | * @return 88 | */ 89 | public static JSONArray getDetailList(String url) { 90 | String result = HtHttpUtil.http.get(baseUrl+url, HtHttpUtil.http.default_charset, HtHttpUtil.http._ua, baseUrl+url); 91 | Jerry matchsJerry = Jerry.jerry(result); 92 | //System.out.println(matchsJerry.$(".d_table").html()); 93 | JSONArray detailList = new JSONArray(); 94 | 95 | matchsJerry.$(".d_table tr").each(new JerryFunction() { 96 | public Boolean onNode(Jerry $this, int index) { 97 | if($this.$(".dt_edition").length() == 0)return true; 98 | String html = $this.html(); 99 | String htmlLower = html.toLowerCase(); 100 | String downUrl = $this.$(".dt_down a").attr("href"); 101 | String title = $this.$(".dt_edition a").text().trim(); 102 | int downCount = Integer.valueOf(RegexUtil.getMatchStr($this.$(".dt_count").text(), "([\\d]+)")); 103 | String ext = ""; 104 | for(String extName : AppConfig.subExtNames) { 105 | //if(StrUtil.isNotEmpty(RegexUtil.getMatchStr(html, "(>"+extName+"<)", Pattern.CASE_INSENSITIVE))) { 106 | if(htmlLower.contains(">"+extName+"<")) { 107 | ext += extName; 108 | ext += ","; 109 | } 110 | } 111 | if(ext.endsWith(",")) { 112 | ext=ext.substring(0, ext.length()-1); 113 | }else { 114 | ext="其它"; 115 | } 116 | 117 | String lang = ""; 118 | String[] langList = new String[] {"双语", "简体", "繁体", "英文"}; 119 | for(String langName : langList) { 120 | if(htmlLower.contains(">"+langName+"<")) { 121 | lang += langName; 122 | lang += ","; 123 | } 124 | } 125 | if(lang.endsWith(",")) { 126 | lang=lang.substring(0, lang.length()-1); 127 | }else { 128 | lang="其它"; 129 | } 130 | 131 | JSONObject dataRow = new JSONObject(); 132 | dataRow.put("url", downUrl); 133 | dataRow.put("title", title); 134 | dataRow.put("ext", ext); 135 | dataRow.put("lang",lang); 136 | dataRow.put("rate", "-"); 137 | dataRow.put("downCount", downCount); 138 | detailList.add(dataRow); 139 | return true; 140 | } 141 | }); 142 | 143 | return detailList; 144 | } 145 | 146 | /** 147 | * 模糊查询页面列表 148 | * @param title 149 | * @return 150 | */ 151 | public static JSONArray getFuzzyPageList(String title) { 152 | int pos = title.lastIndexOf("."); 153 | title = title.toLowerCase(); 154 | title = pos > 0 ? title.substring(0, pos) : title; 155 | JSONArray list = getPageList(title); 156 | if(list.size() == 0 && (pos = title.lastIndexOf("bluray")) > 0) { 157 | title = title.substring(0, pos+6); 158 | list = getPageList(title); 159 | } 160 | if(list.size() == 0 && (pos = title.lastIndexOf(".2160p")) > 0) { 161 | title = title.substring(0, pos+6); 162 | list = getPageList(title); 163 | if(list.size() == 0) { 164 | title = title.substring(0, pos); 165 | list = getPageList(title); 166 | } 167 | } 168 | if(list.size() == 0 && (pos = title.lastIndexOf(".1080p")) > 0) { 169 | title = title.substring(0, pos+6); 170 | list = getPageList(title); 171 | if(list.size() == 0) { 172 | title = title.substring(0, pos); 173 | list = getPageList(title); 174 | } 175 | } 176 | if(list.size() == 0 && (pos = title.lastIndexOf(".720p")) > 0) { 177 | title = title.substring(0, pos+5); 178 | list = getPageList(title); 179 | if(list.size() == 0) { 180 | title = title.substring(0, pos); 181 | list = getPageList(title); 182 | } 183 | } 184 | if(list.size() == 0 && (pos = title.lastIndexOf(".480p")) > 0) { 185 | title = title.substring(0, pos+5); 186 | list = getPageList(title); 187 | if(list.size() == 0) { 188 | title = title.substring(0, pos); 189 | list = getPageList(title); 190 | } 191 | } 192 | //System.out.println(list); 193 | return list; 194 | } 195 | /** 196 | * 获取页面列表 197 | * @param title 198 | * @return 199 | */ 200 | public static JSONArray getPageList(String title) { 201 | String result = HtHttpUtil.http.get(baseUrl+"/search0/"+HttpUtil.encodeUtf8(title), HtHttpUtil.http.default_charset,HtHttpUtil.http._ua, baseUrl); 202 | //System.out.println(result); 203 | JSONArray resList = RegexUtil.getMatchList(result, ">> 4; 68 | stringBuilder.append(Integer.toHexString(bias)); 69 | bias = b & 0xf; 70 | stringBuilder.append(Integer.toHexString(bias)); 71 | } 72 | return stringBuilder.toString(); 73 | } 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/zimu/common/sites/ZIMuKuCommon.java: -------------------------------------------------------------------------------- 1 | package zimu.common.sites; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | import org.jsoup.Jsoup; 6 | import org.jsoup.nodes.Document; 7 | import org.jsoup.nodes.Element; 8 | import org.jsoup.select.Elements; 9 | 10 | import cn.hutool.core.codec.Base64; 11 | import cn.hutool.core.util.CharsetUtil; 12 | import cn.hutool.core.util.StrUtil; 13 | import cn.hutool.core.util.URLUtil; 14 | import cn.hutool.http.HttpResponse; 15 | import cn.hutool.json.JSONArray; 16 | import cn.hutool.json.JSONObject; 17 | import cn.hutool.log.Log; 18 | import cn.hutool.log.LogFactory; 19 | import zimu.util.ExeJsUtil; 20 | import zimu.util.HtHttpUtil; 21 | import zimu.util.StringUtil; 22 | import zimu.util.regex.RegexUtil; 23 | 24 | public class ZIMuKuCommon { 25 | static final Log logger = LogFactory.get(); 26 | /** 27 | * 字幕库启用新域名:www.zimuku.la (强烈推荐收藏永久备用米:zmk.tw) 28 | 29 | */ 30 | //static String baseUrl = "https://www.zimuku.cn"; 31 | static String baseUrl = "http://www.zimuku.la"; 32 | 33 | 34 | 35 | 36 | public static void main(String[] args) throws Exception { 37 | //System.out.println(DownList("憨豆特工.mkv")); 38 | //System.out.println(DownList("downsizing.2017.720p.bluray.x264-geckos.mkv")); 39 | //System.out.println(DownList("From.Beijing.with.Love.1994.720p.BluRay.x264-WiKi.mkv")); 40 | //System.out.println(getPageList("From.Beijing.with.Love")); 41 | 42 | System.out.println(downContent("/detail/101779.html"));; 43 | //detail/100250.html 44 | } 45 | /** 46 | * 下载字幕列表 47 | * @param fileName 48 | * @return 49 | * @throws Exception 50 | */ 51 | public static JSONArray DownList(String fileName) throws Exception { 52 | JSONArray mainList = getFuzzyPageList(fileName); 53 | //System.out.println(mainList); 54 | 55 | JSONArray resp = new JSONArray(); 56 | for(int i = 0; i < mainList.size(); i++) { 57 | JSONArray row = mainList.getJSONArray(i); 58 | //System.out.println("row="+row); 59 | JSONArray detailList = getDetailList(row.getStr(0)); 60 | if(detailList == null)continue; 61 | resp.addAll(detailList); 62 | } 63 | return resp; 64 | } 65 | 66 | /** 67 | * 下载字幕 68 | * @param url 69 | * @return 70 | */ 71 | public static JSONObject downContent(String url) { 72 | String result = httpGet(baseUrl+url); 73 | String downUrl = RegexUtil.getMatchStr(result, 74 | " ++i) { 91 | httpResp = HtHttpUtil.http.getResponse(addBaseUrl(resList.getJSONArray(1).getStr(0)), null, downUrl); 92 | } 93 | //System.out.println(httpResp); 94 | if(httpResp == null)return null; 95 | String filename = HtHttpUtil.getFileName(httpResp); 96 | byte[] data = httpResp.bodyBytes(); 97 | //System.out.println(filename); 98 | JSONObject resp = new JSONObject(); 99 | resp.put("filename", filename); 100 | resp.put("ext", StringUtil.extName(filename).toLowerCase()); 101 | resp.put("data", Base64.encode(data)); 102 | 103 | return resp; 104 | } 105 | 106 | public static String addBaseUrl(String url) { 107 | if(url == null || url.startsWith("http://") || url.startsWith("https://")) { 108 | return url; 109 | } 110 | return baseUrl+url; 111 | } 112 | 113 | /** 114 | * 获取下载网址列表 115 | * @return 116 | */ 117 | public static JSONArray getDetailList(String url) { 118 | String result = httpGet(baseUrl+url); 119 | //System.out.println(result); 120 | Document doc = Jsoup.parse(result); 121 | Elements matchList = doc.select("#subtb tbody tr"); 122 | if(matchList.size() == 0)return new JSONArray(); 123 | //System.out.println(matchList.html()); 124 | JSONArray resList = new JSONArray(); 125 | for(int i = 0 ; i < matchList.size(); i++) { 126 | Element row = matchList.get(i); 127 | JSONObject resRow = new JSONObject(); 128 | resRow.put("url", row.selectFirst("a").attr("href")); 129 | resRow.put("title", row.selectFirst("a").attr("title")); 130 | resRow.put("ext", row.selectFirst(".label-info").text()); 131 | Elements authorInfos = row.select(".gray"); 132 | StringBuffer authorInfo = new StringBuffer(); 133 | authorInfos.forEach(element ->{ 134 | authorInfo.append(element.text() + ","); 135 | }); 136 | if(authorInfo.length() > 0) { 137 | resRow.put("authorInfo", authorInfo.toString().substring(0, authorInfo.length()-1)); 138 | }else { 139 | resRow.put("authorInfo", ""); 140 | } 141 | 142 | resRow.put("lang", row.selectFirst("img").attr("alt")); 143 | resRow.put("rate", row.selectFirst(".rating-star").attr("title").replace("字幕质量:", "")); 144 | resRow.put("downCount", row.select("td").get(3).text()); 145 | resList.add(resRow); 146 | } 147 | return resList; 148 | } 149 | 150 | /** 151 | * 模糊查询页面列表 152 | * @param title 153 | * @return 154 | */ 155 | public static JSONArray getFuzzyPageList(String title) { 156 | int pos = title.lastIndexOf("."); 157 | title = title.toLowerCase(); 158 | title = pos > 0 ? title.substring(0, pos) : title; 159 | JSONArray list = getPageList(title); 160 | if(list.size() == 0 && (pos = title.lastIndexOf("bluray")) > 0) { 161 | title = title.substring(0, pos+6); 162 | list = getPageList(title); 163 | } 164 | if(list.size() == 0 && (pos = title.lastIndexOf(".2160p")) > 0) { 165 | title = title.substring(0, pos+6); 166 | list = getPageList(title); 167 | if(list.size() == 0) { 168 | title = title.substring(0, pos); 169 | list = getPageList(title); 170 | } 171 | } 172 | if(list.size() == 0 && (pos = title.lastIndexOf(".1080p")) > 0) { 173 | title = title.substring(0, pos+6); 174 | list = getPageList(title); 175 | if(list.size() == 0) { 176 | title = title.substring(0, pos); 177 | list = getPageList(title); 178 | } 179 | } 180 | if(list.size() == 0 && (pos = title.lastIndexOf(".720p")) > 0) { 181 | title = title.substring(0, pos+5); 182 | list = getPageList(title); 183 | if(list.size() == 0) { 184 | title = title.substring(0, pos); 185 | list = getPageList(title); 186 | } 187 | } 188 | if(list.size() == 0 && (pos = title.lastIndexOf(".480p")) > 0) { 189 | title = title.substring(0, pos+5); 190 | list = getPageList(title); 191 | if(list.size() == 0) { 192 | title = title.substring(0, pos); 193 | list = getPageList(title); 194 | } 195 | } 196 | if(list.size() == 0 && (pos = title.lastIndexOf(".internal")) > 0) { 197 | title = title.substring(0, pos+9); 198 | list = getPageList(title); 199 | if(list.size() == 0) { 200 | title = title.substring(0, pos); 201 | list = getPageList(title); 202 | } 203 | } 204 | //System.out.println(list); 205 | return list; 206 | } 207 | /** 208 | * 获取页面列表 209 | * @param title 210 | * @return 211 | */ 212 | public static JSONArray getPageList(String title) { 213 | String result = httpGet(baseUrl+"/search?q="+URLUtil.encodeAll(title, CharsetUtil.CHARSET_UTF_8)); 214 | //System.out.println(result); 215 | JSONArray resList = RegexUtil.getMatchList(result, "(.*?)

", Pattern.DOTALL); 217 | //System.out.println(resList); 218 | if(resList == null) { 219 | return new JSONArray(); 220 | } 221 | 222 | return resList; 223 | } 224 | 225 | public static String httpGet(String url) { 226 | String result = HtHttpUtil.http.get(url); 227 | if(result!=null && StrUtil.count(result, "url")>10 && result.contains("]*>(.*?)"); 229 | jsStr = jsStr.replaceAll("window.location[\\s]*=[\\s]*url", ""); 230 | jsStr = jsStr.replaceAll("location[\\s]*=[\\s]*url", ""); 231 | if(jsStr==null) { 232 | jsStr = ""; 233 | } 234 | String jsVal = null; 235 | try { 236 | jsVal = ExeJsUtil.getJsVal("function getUrl(){"+jsStr+";return url;} getUrl()"); 237 | }catch(Exception e) { 238 | logger.error(e); 239 | } 240 | if(jsVal!=null&&jsVal.length()>0) { 241 | return httpGet(jsVal.contains("://") ? jsVal : baseUrl+jsVal); 242 | } 243 | } 244 | return result; 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/AboutDialog.java: -------------------------------------------------------------------------------- 1 | package zimu.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.Desktop; 6 | import java.awt.Frame; 7 | import java.awt.Image; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.awt.event.KeyEvent; 11 | import java.net.URL; 12 | 13 | import javax.swing.BorderFactory; 14 | import javax.swing.ImageIcon; 15 | import javax.swing.JButton; 16 | import javax.swing.JComponent; 17 | import javax.swing.JDialog; 18 | import javax.swing.JFrame; 19 | import javax.swing.JLabel; 20 | import javax.swing.JOptionPane; 21 | import javax.swing.JPanel; 22 | import javax.swing.JRootPane; 23 | import javax.swing.JScrollPane; 24 | import javax.swing.JTextPane; 25 | import javax.swing.KeyStroke; 26 | import javax.swing.event.HyperlinkEvent; 27 | import javax.swing.event.HyperlinkListener; 28 | 29 | import zimu.AppConfig; 30 | 31 | public class AboutDialog extends JDialog { 32 | private static final long serialVersionUID = 1L; 33 | 34 | public AboutDialog(Frame parent) { 35 | super(parent, true); 36 | initComponents(); 37 | } 38 | 39 | @Override 40 | protected JRootPane createRootPane() { 41 | KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); 42 | JRootPane rootPane = new JRootPane(); 43 | rootPane.registerKeyboardAction(new ActionListener() { 44 | @Override 45 | public void actionPerformed(ActionEvent e) { 46 | escapeKeyProc(); 47 | } 48 | }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); 49 | 50 | return rootPane; 51 | } 52 | 53 | protected void escapeKeyProc() { 54 | setVisible(false); 55 | } 56 | private void initComponents() { 57 | 58 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 59 | setIconImage(MainWin.icon); 60 | setSize(500, 300); 61 | setResizable(false); 62 | 63 | setLocationRelativeTo(this.getParent()); 64 | setTitle("About " + AppConfig.appTitle); 65 | 66 | JPanel mainPanel = new JPanel(new BorderLayout()); 67 | add(mainPanel); 68 | 69 | JPanel leftPanel = new JPanel(); 70 | mainPanel.add(leftPanel, BorderLayout.WEST); 71 | 72 | ImageIcon iconImg = new ImageIcon(MainWin.icon); 73 | iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH)); 74 | JLabel iconLabel = new JLabel(iconImg); 75 | iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10)); 76 | leftPanel.add(iconLabel); 77 | 78 | HyperlinkListener hlLsnr = new HyperlinkListener() { 79 | @Override 80 | public void hyperlinkUpdate(HyperlinkEvent e) { 81 | if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) 82 | return; 83 | // 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。 84 | // JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription()); 85 | URL linkUrl = e.getURL(); 86 | if (linkUrl != null) { 87 | try { 88 | Desktop.getDesktop().browse(linkUrl.toURI()); 89 | } catch (Exception e1) { 90 | e1.printStackTrace(); 91 | JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE); 92 | } 93 | } else { 94 | JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE); 95 | } 96 | } 97 | }; 98 | 99 | JTextPane infoArea = new JTextPane(); 100 | //设置css单位(px/pt)和chrome一致 101 | infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true); 102 | infoArea.addHyperlinkListener(hlLsnr); 103 | infoArea.setContentType("text/html"); 104 | infoArea.setText(getInfo()); 105 | infoArea.setEditable(false); 106 | infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10)); 107 | infoArea.setFocusable(false); 108 | 109 | JScrollPane infoAreaScrollPane = new JScrollPane(infoArea); 110 | infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 111 | infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 112 | infoAreaScrollPane.getViewport().setBackground(Color.WHITE); 113 | mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER); 114 | 115 | } 116 | 117 | 118 | String getInfo() { 119 | String fontfamily = GuiConfig.defaultFont.getFamily(); 120 | String htmlFont = "font-size:12px;font-family:"+fontfamily+";"; 121 | StringBuffer sb = new StringBuffer(); 122 | sb.append("
");
123 | 		sb.append("软件名称:" + AppConfig.appName + "\n");
124 | 		sb.append("软件版本:" + AppConfig.appVer + "\n");
125 | 		sb.append("软件网址:github.com/Andyfoo/SubTitleSearcher");
126 | 		sb.append("
"); 127 | 128 | sb.append("
"); 129 | sb.append("免责声明:"); 130 | sb.append("
    \n"); 131 | sb.append("
  1. 本软件仅供个人学习和研究之用,不得用于商业或者非法用途。
  2. \n"); 132 | sb.append("
  3. 下载后会覆盖原字幕,请谨慎操作。
  4. \n"); 133 | sb.append("
  5. 所有字幕均来源于互联网,请使用者自行承担风险。
  6. \n"); 134 | sb.append("
  7. 作者仅提供学习和研究工具,不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任。
  8. \n"); 135 | sb.append("
      \n"); 136 | sb.append("
"); 137 | return sb.toString(); 138 | // return "asdfas"; 139 | } 140 | 141 | public static void main(String args[]) { 142 | final JFrame frame = new JFrame("test"); 143 | frame.setSize(800, 500); 144 | // frame.setBackground(Color.LIGHT_GRAY); 145 | frame.setVisible(true); 146 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 147 | JButton btn = new JButton("test"); 148 | btn.addActionListener(new ActionListener() { 149 | @Override 150 | public void actionPerformed(ActionEvent e) { 151 | new AboutDialog(frame).setVisible(true); 152 | } 153 | 154 | }); 155 | frame.add(btn); 156 | new AboutDialog(frame).setVisible(true); 157 | 158 | } 159 | 160 | } -------------------------------------------------------------------------------- /src/main/java/zimu/gui/ExtractDialog.java: -------------------------------------------------------------------------------- 1 | package zimu.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Frame; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | import java.awt.event.KeyEvent; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.WindowEvent; 10 | import java.io.File; 11 | import java.util.List; 12 | 13 | import javax.swing.JComponent; 14 | import javax.swing.JDialog; 15 | import javax.swing.JFrame; 16 | import javax.swing.JOptionPane; 17 | import javax.swing.JRootPane; 18 | import javax.swing.KeyStroke; 19 | 20 | import com.github.stuxuhai.jpinyin.ChineseHelper; 21 | 22 | import cn.hutool.core.date.DateTime; 23 | import cn.hutool.json.JSONArray; 24 | import cn.hutool.json.JSONObject; 25 | import cn.hutool.log.Log; 26 | import cn.hutool.log.LogFactory; 27 | import javafx.application.Platform; 28 | import javafx.embed.swing.JFXPanel; 29 | import javafx.scene.Scene; 30 | import javafx.scene.web.WebEngine; 31 | import javafx.scene.web.WebView; 32 | import zimu.AppConfig; 33 | import zimu.gui.parms.DownParm; 34 | import zimu.server.ServerMain; 35 | import zimu.util.MyFileUtil; 36 | import zimu.util.StringUtil; 37 | import zimu.util.WinRarUtil; 38 | 39 | public class ExtractDialog extends JDialog { 40 | private static final long serialVersionUID = 1L; 41 | 42 | static final Log logger = LogFactory.get(); 43 | 44 | public static ExtractDialog extractDialog = null; 45 | 46 | public String title; 47 | 48 | private JFXPanel bsPanel = new JFXPanel(); 49 | WebView webview; 50 | Scene webviewScene; 51 | 52 | public byte[] archiveData; 53 | public String archiveExt; 54 | public String subFilename; 55 | 56 | String archivePath; 57 | public List archiveFiles; 58 | 59 | DownParm downParm; 60 | int zimuIndex; 61 | 62 | public ExtractDialog(Frame parent, int index, DownParm downParm, String title, String ext, String filename, byte[] data) { 63 | super(parent, true); 64 | 65 | this.downParm = downParm; 66 | this.zimuIndex = index; 67 | this.title = title; 68 | if (data == null) { 69 | data = new byte[0]; 70 | } 71 | this.archiveData = data; 72 | this.archiveExt = ext; 73 | this.subFilename = filename; 74 | 75 | 76 | initComponents(); 77 | extractDialog = this; 78 | } 79 | 80 | @Override 81 | protected JRootPane createRootPane() { 82 | KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); 83 | JRootPane rootPane = new JRootPane(); 84 | rootPane.registerKeyboardAction(new ActionListener() { 85 | @Override 86 | public void actionPerformed(ActionEvent e) { 87 | escapeKeyProc(); 88 | } 89 | }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); 90 | 91 | return rootPane; 92 | } 93 | 94 | protected void escapeKeyProc() { 95 | clear(); 96 | setVisible(false); 97 | } 98 | private void jsAlert(String message) { 99 | JOptionPane.showMessageDialog(this, message); 100 | } 101 | 102 | private boolean jsConfirm(String message) { 103 | int r = JOptionPane.showConfirmDialog(this, message, "提示信息", JOptionPane.YES_NO_OPTION); 104 | if (r == JOptionPane.YES_OPTION) { 105 | return true; 106 | } else if (r == JOptionPane.NO_OPTION) { 107 | return false; 108 | } 109 | return false; 110 | } 111 | public void alert(String str) { 112 | JOptionPane.showMessageDialog(this, str); 113 | } 114 | 115 | private void initData() { 116 | archivePath = AppConfig.appPath + "tmpData/" + DateTime.now().toString("yyyyMMddHHmmss"); 117 | archiveFiles = WinRarUtil.unRar(archiveExt, archiveData, archivePath); 118 | if (archiveFiles == null) { 119 | logger.error("解压失败"); 120 | alert("压缩文件解压失败"); 121 | return; 122 | } 123 | 124 | } 125 | 126 | public boolean saveSelected(JSONArray items) { 127 | for (int i = 0; i < items.size(); i++) { 128 | JSONObject item = items.getJSONObject(i); 129 | DownParm downParm = new DownParm(); 130 | downParm.charset = item.getStr("charset", ""); 131 | downParm.simplified = item.getBool("simplified", false); 132 | downParm.filenameType = item.getInt("filenameType", 1); 133 | saveFile(item.getStr("title"), downParm); 134 | } 135 | return true; 136 | } 137 | 138 | private void saveFile(String dtitle, DownParm downParm) { 139 | for (int i = 0; i < archiveFiles.size(); i++) { 140 | File file = archiveFiles.get(i); 141 | String title = file.getName(); 142 | if (title.equals(dtitle)) { 143 | String filename = subFilename; 144 | if (downParm.filenameType == DownParm.filenameType_BAT) { 145 | filename += (".chn" + (zimuIndex + 1)) + "&" + i + "." + StringUtil.extName(file); 146 | } else { 147 | filename += "." + StringUtil.extName(file); 148 | } 149 | logger.info("save=" + filename); 150 | // if(MainWin.simplifiedCheckBox != null && MainWin.simplifiedCheckBox.isSelected()) { 151 | if (downParm.simplified) { 152 | String dataStr = null; 153 | try { 154 | dataStr = new String(MyFileUtil.fileReadBin(file), downParm.charset); 155 | dataStr = ChineseHelper.convertToSimplifiedChinese(dataStr); 156 | MyFileUtil.fileWrite(filename, dataStr, "UTF-8", ""); 157 | } catch (Exception e) { 158 | logger.error(e); 159 | } 160 | } else { 161 | MyFileUtil.fileWriteBin(filename, MyFileUtil.fileReadBin(file)); 162 | } 163 | } 164 | } 165 | } 166 | 167 | /** 168 | * 清除临时目录 169 | */ 170 | private void clear() { 171 | try { 172 | WinRarUtil.clear(archivePath); 173 | } catch (Exception e) { 174 | logger.error(e); 175 | } 176 | } 177 | 178 | private void initComponents() { 179 | ExtractDialog _this = this; 180 | setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); 181 | // setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 182 | setIconImage(MainWin.icon); 183 | setSize(820, 460); 184 | // setResizable(false); 185 | 186 | setLocationRelativeTo(this.getParent()); 187 | setTitle("请选择压缩包中要保存的字幕文件"); 188 | 189 | this.addWindowListener(new WindowAdapter() { 190 | public void windowClosing(WindowEvent e) { 191 | _this.clear(); 192 | _this.dispose(); 193 | } 194 | }); 195 | 196 | add(bsPanel, BorderLayout.CENTER); 197 | openUrl(MainWin.class.getResource("/html/extract_dialog.html").toExternalForm()); 198 | 199 | } 200 | 201 | /** 202 | * 打开网址 203 | * 204 | * @param url 205 | */ 206 | private void openUrl(String url) { 207 | com.sun.javafx.webkit.WebConsoleListener.setDefaultListener((webView, message, lineNumber, sourceId) -> { 208 | logger.info("from webview: " + message + " [" + sourceId + " - " + lineNumber + "]"); 209 | }); 210 | Platform.runLater(new Runnable() { 211 | @Override 212 | public void run() { 213 | 214 | 215 | webview = new WebView(); 216 | // webview.setContextMenuEnabled(false); 217 | 218 | WebEngine webEngine = webview.getEngine(); 219 | 220 | webEngine.setJavaScriptEnabled(true); 221 | webEngine.setOnAlert(event -> jsAlert(event.getData())); 222 | webEngine.setConfirmHandler(message -> jsConfirm(message)); 223 | 224 | webEngine.setOnError(event -> { 225 | logger.info(event.getMessage()); 226 | }); 227 | // webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { 228 | // 229 | // }); 230 | 231 | webviewScene = new Scene(webview); 232 | bsPanel.setScene(webviewScene); 233 | 234 | initData(); 235 | webEngine.load(url); 236 | webview.getEngine().executeScript("window.serverPort="+AppConfig.serverPort+""); 237 | 238 | } 239 | }); 240 | } 241 | 242 | public static void main(String args[]) { 243 | ServerMain.start(); 244 | GuiConfig.setUIFont(); 245 | // String filename = "E:/workspace/_me/dev/my_libs/test_lib/data/file/archive/test.7z"; 246 | 247 | String ext = "rar"; 248 | String filename = "H:/_tmp/MOV/[zmk.tw]Downsizing.2017.1080p.BluRay.x264-GECKOS." + ext; 249 | filename = "E:/workspace/_me/dev/my_tools/SubTitleSearcher/target/_test_data/data.zip"; 250 | 251 | byte[] data = MyFileUtil.fileReadBin(filename); 252 | 253 | final JFrame frame = new JFrame("test"); 254 | frame.setSize(900, 500); 255 | // frame.setBackground(Color.LIGHT_GRAY); 256 | frame.setVisible(true); 257 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 258 | 259 | new ExtractDialog(frame, 1, DownParm.def, "asdfffffff", ext, "aaa", data).setVisible(true); 260 | System.exit(0); 261 | } 262 | 263 | } 264 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/GuiConfig.java: -------------------------------------------------------------------------------- 1 | package zimu.gui; 2 | 3 | import java.awt.Font; 4 | 5 | import javax.swing.UIManager; 6 | 7 | public class GuiConfig { 8 | public static Font defaultFont = new Font("微软雅黑", Font.PLAIN, 12); 9 | 10 | public static void setUIFont() { 11 | 12 | String names[] = { "Label", "CheckBox", "PopupMenu", "MenuItem", "CheckBoxMenuItem", 13 | "JRadioButtonMenuItem", "ComboBox", "Button", "Tree", "ScrollPane", "TabbedPane", 14 | "EditorPane", "TitledBorder", "Menu", "TextArea", "OptionPane", "MenuBar", "ToolBar", 15 | "ToggleButton", "ToolTip", "ProgressBar", "TableHeader", "Panel", "List", 16 | "ColorChooser", "PasswordField", "TextField", "Table", "Label", "Viewport", 17 | "RadioButtonMenuItem", "RadioButton", "DesktopPane", "InternalFrame" }; 18 | for (String item : names) { 19 | UIManager.put(item + ".font", defaultFont); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/MainWin.java: -------------------------------------------------------------------------------- 1 | package zimu.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Dimension; 5 | import java.awt.Image; 6 | import java.awt.Toolkit; 7 | import java.io.IOException; 8 | 9 | import javax.swing.JFrame; 10 | import javax.swing.JOptionPane; 11 | 12 | import cn.hutool.log.Log; 13 | import cn.hutool.log.LogFactory; 14 | import javafx.application.Platform; 15 | import javafx.embed.swing.JFXPanel; 16 | import javafx.scene.Scene; 17 | import javafx.scene.input.Dragboard; 18 | import javafx.scene.input.TransferMode; 19 | import javafx.scene.web.WebEngine; 20 | import javafx.scene.web.WebView; 21 | import netscape.javascript.JSObject; 22 | import zimu.AppConfig; 23 | import zimu.gui.parms.MovFileInfo; 24 | import zimu.server.ServerMain; 25 | 26 | public class MainWin extends JFrame { 27 | private static final long serialVersionUID = 1L; 28 | static final Log logger = LogFactory.get(); 29 | public static Image icon = Toolkit.getDefaultToolkit().getImage(MainWin.class.getResource("/res/icon/app.png")); 30 | 31 | private JFXPanel bsPanel = new JFXPanel(); 32 | WebView webview; 33 | Scene webviewScene; 34 | 35 | public static MainWin frame; 36 | 37 | public static MainWin get() { 38 | frame = new MainWin(); 39 | return frame; 40 | } 41 | 42 | public void init() { 43 | ServerMain.start(); 44 | GuiConfig.setUIFont(); 45 | setVisible(true); 46 | setTitle(String.format("%s V%s", AppConfig.appTitle, AppConfig.appVer)); 47 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 48 | setSize(920, 600); 49 | setMinimumSize(new Dimension(800, 500)); 50 | setLayout(new BorderLayout()); 51 | setLocationRelativeTo(null); 52 | 53 | setIconImage(icon); 54 | 55 | add(bsPanel, BorderLayout.CENTER); 56 | openUrl(MainWin.class.getResource("/html/mainwin.html").toExternalForm()); 57 | 58 | 59 | } 60 | 61 | /** 62 | * 打开网址 63 | * 64 | * @param url 65 | */ 66 | private void openUrl(String url) { 67 | com.sun.javafx.webkit.WebConsoleListener.setDefaultListener((webView, message, lineNumber, sourceId) -> { 68 | logger.info("from webview: " + message + " [" + sourceId + " - " + lineNumber + "]"); 69 | }); 70 | final MainWinJsApp webkitJsApp = new MainWinJsApp(this); 71 | Platform.runLater(new Runnable() { 72 | @Override 73 | public void run() { 74 | webview = new WebView(); 75 | //webview.setContextMenuEnabled(false); 76 | 77 | 78 | WebEngine webEngine = webview.getEngine(); 79 | 80 | webEngine.setJavaScriptEnabled(true); 81 | webEngine.setOnAlert(event -> jsAlert(event.getData())); 82 | webEngine.setConfirmHandler(message -> jsConfirm(message)); 83 | 84 | webEngine.setOnStatusChanged(event -> { 85 | //logger.info(event.getData()); 86 | }); 87 | webEngine.setOnError(event -> { 88 | logger.info(event.getMessage()); 89 | }); 90 | 91 | // webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { 92 | // if (newState == State.SCHEDULED) { 93 | // //System.out.println("state: scheduled"); 94 | // } else if (newState == State.RUNNING) { 95 | // //System.out.println("state: running"); 96 | // } else if (newState == State.SUCCEEDED) { 97 | // //System.out.println("state: succeeded"); 98 | // //webview.getEngine().executeScript("search_start()"); 99 | // } 100 | // }); 101 | 102 | 103 | ((JSObject) webEngine.executeScript("window")).setMember("javaApp", webkitJsApp); 104 | 105 | 106 | 107 | webEngine.load(url); 108 | webviewScene = new Scene(webview); 109 | bsPanel.setScene(webviewScene); 110 | 111 | 112 | //webEngine.executeScript("alert(322)"); 113 | 114 | initDragImport(); 115 | } 116 | }); 117 | } 118 | 119 | /** 120 | * 设置拖拽文件 121 | */ 122 | public void initDragImport() { 123 | 124 | webview.setOnDragOver(event -> { 125 | if (event.getDragboard().hasFiles()) { 126 | /* allow for both copying and moving, whatever user chooses */ 127 | //event.acceptTransferModes(TransferMode.COPY_OR_MOVE); 128 | event.acceptTransferModes(TransferMode.LINK); 129 | } 130 | event.consume(); 131 | }); 132 | webview.setOnDragDropped(event -> { 133 | Dragboard db = event.getDragboard(); 134 | boolean success = false; 135 | if (db.hasFiles()) { 136 | //logger.info(db.getFiles().toString()); 137 | success = true; 138 | 139 | if (db.getFiles().get(0).isDirectory()) { 140 | alert("请选择有效的视频文件"); 141 | return ; 142 | } 143 | String filepath = db.getFiles().get(0).getAbsolutePath(); 144 | //System.out.println(">>>"+filepath); 145 | MovFileInfo.setFile(filepath); 146 | 147 | new Thread() { 148 | public void run() { 149 | Platform.runLater(new Runnable() { 150 | @Override 151 | public void run() { 152 | webview.getEngine().executeScript("page_callback()"); 153 | } 154 | }); 155 | 156 | } 157 | }.start(); 158 | // startSearch(); 159 | // JOptionPane.showMessageDialog(frame, filepath); 160 | } 161 | /* 162 | * let the source know whether the string was successfully transferred and used 163 | */ 164 | event.setDropCompleted(success); 165 | 166 | event.consume(); 167 | }); 168 | 169 | // webviewScene.addEventHandler(eventType, eventHandler); 170 | // setTransferHandler(transferHandler); 171 | } 172 | 173 | private void jsAlert(String message) { 174 | JOptionPane.showMessageDialog(this, message); 175 | } 176 | 177 | private boolean jsConfirm(String message) { 178 | int r = JOptionPane.showConfirmDialog(this, message, "提示信息", JOptionPane.YES_NO_OPTION); 179 | if (r == JOptionPane.YES_OPTION) { 180 | return true; 181 | } else if (r == JOptionPane.NO_OPTION) { 182 | return false; 183 | } 184 | return false; 185 | } 186 | 187 | public void alert(String str) { 188 | JOptionPane.showMessageDialog(this, str); 189 | } 190 | 191 | public void confirm(String title, String str, Runnable yes, Runnable no) { 192 | int r = JOptionPane.showConfirmDialog(this, str, title, JOptionPane.YES_NO_OPTION); 193 | if (r == JOptionPane.YES_OPTION && yes != null) { 194 | (new Thread(yes)).start(); 195 | } else if (r == JOptionPane.NO_OPTION && no != null) { 196 | (new Thread(no)).run(); 197 | } 198 | } 199 | 200 | public static void main(String[] args) throws IOException { 201 | //MovFileInfo.setFile("H:/_tmp/MOV/downsizing.2017.720p.bluray.x264-geckos.mkv"); 202 | MovFileInfo.setFile("E:/workspace/_me/dev/my_tools/SubTitleSearcher/target/downsizing.2017.720p.bluray.x264-geckos.mkv"); 203 | 204 | MainWin mainWin = new MainWin(); 205 | mainWin.init(); 206 | } 207 | 208 | 209 | } 210 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/MainWinJsApp.java: -------------------------------------------------------------------------------- 1 | package zimu.gui; 2 | 3 | import java.io.File; 4 | 5 | import javax.swing.JFileChooser; 6 | import javax.swing.JLabel; 7 | import javax.swing.filechooser.FileNameExtensionFilter; 8 | 9 | import cn.hutool.json.JSONObject; 10 | import cn.hutool.json.JSONUtil; 11 | import zimu.AppConfig; 12 | import zimu.common.ZiMuCommon; 13 | import zimu.gui.parms.MovFileInfo; 14 | import zimu.gui.parms.SearchParm; 15 | 16 | public class MainWinJsApp { 17 | MainWin mainWin; 18 | public MainWinJsApp(MainWin mainWin) { 19 | this.mainWin = mainWin; 20 | } 21 | 22 | /** 23 | * 选择视频文件 24 | * @return 25 | */ 26 | public boolean openMovFile() { 27 | JFileChooser jfc = new JFileChooser(); 28 | 29 | jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); 30 | FileNameExtensionFilter filter = new FileNameExtensionFilter( 31 | "视频文件(*.mkv; *mp4; *.mov; *.avi; *.ts)", "mkv", "mp4", "mov", "avi", "ts"); 32 | jfc.setFileFilter(filter); 33 | if(MovFileInfo.lastSelPath!=null) { 34 | jfc.setCurrentDirectory(new File(MovFileInfo.lastSelPath)); 35 | } 36 | int status = jfc.showDialog(new JLabel(), "选择视频文件"); 37 | 38 | if(JFileChooser.APPROVE_OPTION == status) { 39 | File file = jfc.getSelectedFile(); 40 | if (file != null && file.isFile()) { 41 | String filepath = file.getAbsolutePath(); 42 | if(file.isDirectory()) { 43 | alert("请选择有效的视频文件"); 44 | return false; 45 | } 46 | MovFileInfo.setFile(filepath); 47 | return true; 48 | } 49 | }else if(JFileChooser.ERROR_OPTION == status) { 50 | alert("选择文件失败"); 51 | return false; 52 | } 53 | return false; 54 | } 55 | //复制字符串 56 | public void copyClipboard(String str) { 57 | ZiMuCommon.copyClipboard(str); 58 | } 59 | 60 | //退出程序 61 | public void exit() { 62 | System.exit(0); 63 | } 64 | 65 | /** 66 | * 获取初始化数据 67 | */ 68 | public String getInitData() { 69 | JSONObject resp = new JSONObject(); 70 | JSONObject fileinfo = new JSONObject(); 71 | fileinfo.put("lastSelPath", MovFileInfo.lastSelPath); 72 | fileinfo.put("movFilename", MovFileInfo.movFilename); 73 | resp.put("fileinfo", fileinfo); 74 | resp.put("searchParm", JSONUtil.parseObj(SearchParm.def)); 75 | resp.put("serverPort", AppConfig.serverPort); 76 | return resp.toString(); 77 | } 78 | 79 | public void alert(String msg) { 80 | mainWin.alert(msg); 81 | } 82 | 83 | public void about() { 84 | new AboutDialog(mainWin).setVisible(true); 85 | } 86 | 87 | public void test() { 88 | System.out.println("test"); 89 | } 90 | 91 | protected void finalize() 92 | throws Throwable{ 93 | System.out.println("exit"); 94 | } 95 | 96 | public static void main(String[] args) { 97 | System.out.println(JSONUtil.parseObj(SearchParm.def)); 98 | 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/parms/DownParm.java: -------------------------------------------------------------------------------- 1 | package zimu.gui.parms; 2 | 3 | public class DownParm { 4 | public static DownParm def = new DownParm(); 5 | 6 | /** 7 | * 文件名规则 8 | * 0=与视频同名 9 | * 1=与视频同名后再追加chn数字 10 | */ 11 | public int filenameType = 0; 12 | 13 | public static int filenameType_DEF = 0; 14 | public static int filenameType_BAT = 1; 15 | 16 | 17 | public boolean simplified = false; 18 | public String charset = "UTF-8"; 19 | 20 | 21 | public boolean isSimplified() { 22 | return simplified; 23 | } 24 | 25 | 26 | 27 | public void setSimplified(boolean simplified) { 28 | this.simplified = simplified; 29 | } 30 | 31 | 32 | public String getCharset() { 33 | return charset; 34 | } 35 | 36 | 37 | 38 | public void setCharset(String charset) { 39 | this.charset = charset; 40 | } 41 | 42 | 43 | 44 | public int getFilenameType() { 45 | return filenameType; 46 | } 47 | 48 | 49 | 50 | public void setFilenameType(int filenameType) { 51 | this.filenameType = filenameType; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/parms/MovFileInfo.java: -------------------------------------------------------------------------------- 1 | package zimu.gui.parms; 2 | 3 | import java.io.File; 4 | 5 | import cn.hutool.log.Log; 6 | import cn.hutool.log.LogFactory; 7 | 8 | public class MovFileInfo { 9 | static final Log logger = LogFactory.get(); 10 | public static String movFilename = ""; 11 | public static String lastSelPath = null; 12 | 13 | 14 | public static void setFile(String filepath) { 15 | File file = new File(filepath); 16 | lastSelPath = file.getParentFile().getAbsolutePath(); 17 | movFilename = filepath; 18 | logger.info(movFilename); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/zimu/gui/parms/SearchParm.java: -------------------------------------------------------------------------------- 1 | package zimu.gui.parms; 2 | 3 | public class SearchParm { 4 | public static SearchParm def = new SearchParm(); 5 | 6 | 7 | public boolean from_sheshou = true; 8 | public boolean from_xunlei = true; 9 | public boolean from_zimuku = true; 10 | public boolean from_subhd = false; 11 | 12 | // public boolean from_sheshou = false; 13 | // public boolean from_xunlei = false; 14 | // public boolean from_zimuku = false; 15 | // public boolean from_subhd = true; 16 | 17 | 18 | 19 | public boolean isFrom_sheshou() { 20 | return from_sheshou; 21 | } 22 | 23 | 24 | 25 | public void setFrom_sheshou(boolean from_sheshou) { 26 | this.from_sheshou = from_sheshou; 27 | } 28 | 29 | 30 | 31 | public boolean isFrom_xunlei() { 32 | return from_xunlei; 33 | } 34 | 35 | 36 | 37 | public void setFrom_xunlei(boolean from_xunlei) { 38 | this.from_xunlei = from_xunlei; 39 | } 40 | 41 | 42 | 43 | public boolean isFrom_zimuku() { 44 | return from_zimuku; 45 | } 46 | 47 | 48 | 49 | public void setFrom_zimuku(boolean from_zimuku) { 50 | this.from_zimuku = from_zimuku; 51 | } 52 | 53 | 54 | 55 | public boolean isFrom_subhd() { 56 | return from_subhd; 57 | } 58 | 59 | 60 | 61 | public void setFrom_subhd(boolean from_subhd) { 62 | this.from_subhd = from_subhd; 63 | } 64 | 65 | 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/zimu/server/MyHttpJsonMessageConverter.java: -------------------------------------------------------------------------------- 1 | package zimu.server; 2 | 3 | import com.hibegin.http.server.config.HttpJsonMessageConverter; 4 | 5 | import cn.hutool.json.JSONUtil; 6 | 7 | public class MyHttpJsonMessageConverter implements HttpJsonMessageConverter { 8 | 9 | @Override 10 | public String toJson(Object obj) throws Exception { 11 | return JSONUtil.toJsonStr(obj); 12 | } 13 | 14 | @Override 15 | public Object fromJson(String jsonStr) throws Exception { 16 | return JSONUtil.parse(jsonStr); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/zimu/server/ServerMain.java: -------------------------------------------------------------------------------- 1 | package zimu.server; 2 | 3 | import com.hibegin.http.server.WebServerBuilder; 4 | import com.hibegin.http.server.config.ServerConfig; 5 | 6 | import cn.hutool.log.Log; 7 | import cn.hutool.log.LogFactory; 8 | import zimu.AppConfig; 9 | import zimu.server.controllers.ApiController; 10 | import zimu.server.controllers.ExtractApiController; 11 | import zimu.server.controllers.IndexController; 12 | 13 | public class ServerMain { 14 | static final Log logger = LogFactory.get(); 15 | static int tryCount = 0; 16 | public static void start() { 17 | logger.info("ServerMain start(port:"+AppConfig.serverPort+")"); 18 | ServerConfig serverConfig = new ServerConfig(); 19 | serverConfig.setHost("127.0.0.1"); 20 | serverConfig.setPort(AppConfig.serverPort); 21 | serverConfig.setHttpJsonMessageConverter(new MyHttpJsonMessageConverter()); 22 | serverConfig.getRouter().addMapper("", IndexController.class); 23 | serverConfig.getRouter().addMapper("/api", ApiController.class); 24 | serverConfig.getRouter().addMapper("/extract_api", ExtractApiController.class); 25 | boolean runResult = new WebServerBuilder.Builder().serverConfig(serverConfig).build().startWithThread(); 26 | logger.info("ServerMain start runResult="+runResult); 27 | if(!runResult && tryCount++ < 50) { 28 | AppConfig.serverPort++; 29 | start(); 30 | } 31 | 32 | } 33 | public static void main(String[] args) { 34 | start(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/zimu/server/controllers/ApiController.java: -------------------------------------------------------------------------------- 1 | package zimu.server.controllers; 2 | 3 | import java.awt.Desktop; 4 | import java.net.URI; 5 | 6 | import com.hibegin.http.server.api.HttpRequest; 7 | import com.hibegin.http.server.api.HttpResponse; 8 | 9 | import cn.hutool.json.JSONArray; 10 | import cn.hutool.json.JSONObject; 11 | import cn.hutool.json.JSONUtil; 12 | import cn.hutool.log.Log; 13 | import cn.hutool.log.LogFactory; 14 | import zimu.down.DownZIMu; 15 | import zimu.gui.parms.DownParm; 16 | import zimu.gui.parms.SearchParm; 17 | 18 | /** 19 | * 列表页面查询接口 20 | * @author FH 21 | * 22 | */ 23 | public class ApiController extends Base { 24 | static final Log logger = LogFactory.get(); 25 | 26 | public void open_url() { 27 | HttpRequest request = getRequest(); 28 | HttpResponse response = getResponse(); 29 | String url = request.getParaToStr("url"); 30 | if(url == null) { 31 | outJsonpMessage(request,response, 1, "请求数据错误"); 32 | return; 33 | } 34 | try { 35 | Desktop.getDesktop().browse(new URI(url)); 36 | } catch (Exception e1) { 37 | e1.printStackTrace(); 38 | outJsonpMessage(request,response, 1, "系统错误"); 39 | return; 40 | } 41 | outJsonpMessage(request,response, 0, "OK"); 42 | } 43 | /** 44 | * 查询字幕 45 | */ 46 | public void zimu_list() { 47 | HttpRequest request = getRequest(); 48 | HttpResponse response = getResponse(); 49 | String data = request.getParaToStr("data"); 50 | if(data == null) { 51 | outJsonpMessage(request,response, 1, "请求数据错误"); 52 | return; 53 | } 54 | 55 | JSONObject dataJson = JSONUtil.parseObj(data); 56 | 57 | 58 | SearchParm searchParm = new SearchParm(); 59 | searchParm.from_sheshou = dataJson.getJSONObject("searchParm").getBool("from_sheshou"); 60 | searchParm.from_subhd = dataJson.getJSONObject("searchParm").getBool("from_subhd"); 61 | searchParm.from_xunlei = dataJson.getJSONObject("searchParm").getBool("from_xunlei"); 62 | searchParm.from_zimuku = dataJson.getJSONObject("searchParm").getBool("from_zimuku"); 63 | try { 64 | DownZIMu.searchList(searchParm); 65 | System.out.println(DownZIMu.dataArr); 66 | }catch(Exception e) { 67 | logger.error(e); 68 | outJsonpMessage(request,response, 1, "查询出错"); 69 | return; 70 | } 71 | 72 | JSONObject resp = new JSONObject(); 73 | resp.put("list", DownZIMu.dataArr); 74 | outJsonpMessage(request,response, 0, "OK", resp); 75 | } 76 | 77 | /** 78 | * 下载字幕 79 | */ 80 | public void zimu_down() { 81 | HttpRequest request = getRequest(); 82 | HttpResponse response = getResponse(); 83 | String data = request.getParaToStr("data"); 84 | if(data == null) { 85 | outJsonpMessage(request,response, 1, "请求数据错误"); 86 | return; 87 | } 88 | 89 | JSONObject dataJson = JSONUtil.parseObj(data); 90 | JSONArray items = dataJson.getJSONArray("items"); 91 | if(items == null || items.size()==0) { 92 | outJsonpMessage(request,response, 1, "请选择字幕文件"); 93 | return; 94 | } 95 | //System.out.println(data); 96 | 97 | DownParm downParm; 98 | JSONObject row; 99 | int item_id; 100 | for(int i = 0; i < items.size(); i++) { 101 | row = items.getJSONObject(i); 102 | item_id = row.getInt("id"); 103 | downParm = new DownParm(); 104 | downParm.charset = row.getStr("charset", ""); 105 | downParm.simplified = row.getBool("simplified", false); 106 | downParm.filenameType = row.getInt("filenameType", 1); 107 | 108 | try { 109 | DownZIMu.down(item_id, downParm); 110 | }catch(Exception e) { 111 | logger.error(e); 112 | } 113 | 114 | } 115 | outJsonpMessage(request,response, 0, "OK"); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/zimu/server/controllers/Base.java: -------------------------------------------------------------------------------- 1 | package zimu.server.controllers; 2 | 3 | import java.io.ByteArrayInputStream; 4 | 5 | import com.hibegin.http.server.api.HttpRequest; 6 | import com.hibegin.http.server.api.HttpResponse; 7 | import com.hibegin.http.server.web.Controller; 8 | 9 | import cn.hutool.json.JSONObject; 10 | 11 | public class Base extends Controller { 12 | 13 | /** 14 | * 获取返回信息 15 | * 16 | * @param result 17 | * 0=成功 18 | * >=1=失败 19 | * @param message 20 | * @return 21 | */ 22 | protected JSONObject getAjaxMessage(int result, String message) { 23 | return getAjaxMessage(result, message, null); 24 | } 25 | 26 | protected JSONObject getAjaxMessage(int result, String message, JSONObject data) { 27 | JSONObject json = new JSONObject(); 28 | json.put("result", result); 29 | json.put("message", message); 30 | 31 | if (data != null) { 32 | json.putAll(data); 33 | } 34 | 35 | return json; 36 | } 37 | public void outAjaxMessage(HttpResponse resp, int result, String message) { 38 | outJson(resp, getAjaxMessage(result, message)); 39 | } 40 | public void outAjaxMessage(HttpResponse resp, int result, String message, JSONObject data) { 41 | outJson(resp, getAjaxMessage(result, message, data)); 42 | } 43 | public void outJsonpMessage(HttpRequest req, HttpResponse resp, int result, String message) { 44 | String callback = req.getParaToStr("callback"); 45 | if(callback == null || callback.length() ==0)callback="callback"; 46 | outJsonp(resp, callback + "(" + getAjaxMessage(result, message).toString()+");"); 47 | } 48 | public void outJsonpMessage(HttpRequest req, HttpResponse resp, int result, String message, JSONObject data) { 49 | String callback = req.getParaToStr("callback"); 50 | if(callback == null || callback.length() ==0)callback="callback"; 51 | outJsonp(resp, callback + "(" + getAjaxMessage(result, message, data).toString()+");"); 52 | } 53 | public void outText(HttpResponse resp, String str){ 54 | //resp.addHeader("Access-Control-Allow-Origin", "*"); 55 | resp.renderHtmlStr(str); 56 | } 57 | public void outHtml(HttpResponse resp, String str) { 58 | //resp.addHeader("Access-Control-Allow-Origin", "*"); 59 | resp.renderHtmlStr(str); 60 | } 61 | public void outJson(HttpResponse resp, JSONObject json) { 62 | resp.addHeader("Access-Control-Allow-Origin", "*"); 63 | resp.renderJson(json); 64 | } 65 | public void outJsonp(HttpResponse resp, String data) { 66 | resp.addHeader("Access-Control-Allow-Origin", "*"); 67 | out(resp, 200, "application/javascript; charset=utf-8", data.getBytes()); 68 | } 69 | public boolean out(HttpResponse resp,int status, String contentType, byte[] data) { 70 | try { 71 | resp.addHeader("Content-Type", contentType); 72 | resp.write( new ByteArrayInputStream(data), status); 73 | return true; 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | return false; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/zimu/server/controllers/ExtractApiController.java: -------------------------------------------------------------------------------- 1 | package zimu.server.controllers; 2 | 3 | import java.io.File; 4 | 5 | import com.hibegin.http.server.api.HttpRequest; 6 | import com.hibegin.http.server.api.HttpResponse; 7 | 8 | import cn.hutool.core.util.ArrayUtil; 9 | import cn.hutool.json.JSONArray; 10 | import cn.hutool.json.JSONObject; 11 | import cn.hutool.json.JSONUtil; 12 | import cn.hutool.log.Log; 13 | import cn.hutool.log.LogFactory; 14 | import zimu.AppConfig; 15 | import zimu.gui.ExtractDialog; 16 | import zimu.util.StringUtil; 17 | /* 18 | * 解压文件接口 19 | */ 20 | public class ExtractApiController extends Base { 21 | static final Log logger = LogFactory.get(); 22 | 23 | /** 24 | * 获取初始化数据 25 | */ 26 | public void get_init_data() { 27 | JSONObject resp = new JSONObject(); 28 | JSONArray list = new JSONArray(); 29 | for (int i = 0; i < ExtractDialog.extractDialog.archiveFiles.size(); i++) { 30 | File file = ExtractDialog.extractDialog.archiveFiles.get(i); 31 | String title = file.getName(); 32 | 33 | if(!ArrayUtil.contains(AppConfig.subExtNames, StringUtil.extName(file).toLowerCase())){ 34 | continue; 35 | } 36 | 37 | String key = title; 38 | JSONObject row = new JSONObject(); 39 | row.put("key", key); 40 | row.put("title", title); 41 | row.put("size", file.length()); 42 | row.put("sizeF", StringUtil.getPrintSize(file.length())); 43 | 44 | list.add(row); 45 | } 46 | resp.put("list", list); 47 | resp.put("title", ExtractDialog.extractDialog.title); 48 | resp.put("archiveExt", ExtractDialog.extractDialog.archiveExt); 49 | resp.put("archiveSize", ExtractDialog.extractDialog.archiveData.length); 50 | resp.put("archiveSizeF", StringUtil.getPrintSize(ExtractDialog.extractDialog.archiveData.length)); 51 | 52 | outJsonpMessage(request,response, 0, "OK", resp); 53 | } 54 | /** 55 | * 下载压缩文件中的字幕 56 | * @param data 57 | * @return 58 | */ 59 | public void down_archive_file() { 60 | HttpRequest request = getRequest(); 61 | HttpResponse response = getResponse(); 62 | String data = request.getParaToStr("data"); 63 | if(data == null) { 64 | outJsonpMessage(request,response, 1, "请求数据错误"); 65 | return; 66 | } 67 | logger.info("data="+data); 68 | if(data == null || data.length() < 10) { 69 | logger.error("data=null"); 70 | outJsonpMessage(request,response, 1, "参数错误"); 71 | return; 72 | } 73 | JSONObject dataJson = JSONUtil.parseObj(data); 74 | JSONArray items = dataJson.getJSONArray("items"); 75 | if(items == null || items.size() == 0) { 76 | logger.error("items=null"); 77 | outJsonpMessage(request,response, 1, "参数错误"); 78 | return; 79 | } 80 | 81 | JSONObject resp = new JSONObject(); 82 | resp.put("saveSelected", ExtractDialog.extractDialog.saveSelected(items)); 83 | outJsonpMessage(request,response, 0, "OK", resp); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/zimu/server/controllers/IndexController.java: -------------------------------------------------------------------------------- 1 | package zimu.server.controllers; 2 | 3 | import zimu.AppConfig; 4 | 5 | public class IndexController extends Base { 6 | public void index() { 7 | //ServerInfo.getVersion() 8 | outHtml(getResponse(), AppConfig.appName + " " + AppConfig.appVer); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/zimu/tests/Test1.java: -------------------------------------------------------------------------------- 1 | package zimu.tests; 2 | 3 | import cn.hutool.http.HttpRequest; 4 | import cn.hutool.http.HttpResponse; 5 | import zimu.util.StringUtil; 6 | 7 | public class Test1 { 8 | public static String getUrl(String url) { 9 | try { 10 | HttpResponse response = HttpRequest.get(url).execute(); 11 | 12 | System.out.println(response.toString()); 13 | int statusCode = response.getStatus(); 14 | if (statusCode == 301 || statusCode == 302) { 15 | String location = response.header("Location"); 16 | if (!location.toLowerCase().startsWith("http")) { 17 | location = StringUtil.getBaseUrl(url) + location; 18 | } 19 | return getUrl(location); 20 | } else if (statusCode == 200) { 21 | return response.body(); 22 | } else { 23 | System.out.println(url + ", failed: " + statusCode); 24 | return null; 25 | } 26 | } catch (Exception e) { 27 | e.printStackTrace(); 28 | return null; 29 | } finally { 30 | } 31 | } 32 | public static void main(String[] args) { 33 | getUrl("https://subhd.tv"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/zimu/tests/Test2.java: -------------------------------------------------------------------------------- 1 | package zimu.tests; 2 | 3 | import javax.script.Compilable; 4 | import javax.script.CompiledScript; 5 | import javax.script.ScriptEngine; 6 | import javax.script.ScriptEngineManager; 7 | 8 | public class Test2 { 9 | 10 | public static void main(String[] args) { 11 | ScriptEngineManager manager = new ScriptEngineManager(); 12 | ScriptEngine engine = manager.getEngineByName("JavaScript"); 13 | try { 14 | String script = "function getUrl(){var url='adsf';return url;} getUrl()"; 15 | Compilable compilable = (Compilable) engine; 16 | CompiledScript JSFunction = compilable.compile(script); 17 | Object result = JSFunction.eval(); 18 | System.out.println(result); 19 | } catch (Exception e) { 20 | e.printStackTrace(); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/ExeJsUtil.java: -------------------------------------------------------------------------------- 1 | package zimu.util; 2 | 3 | import javax.script.Compilable; 4 | import javax.script.CompiledScript; 5 | import javax.script.ScriptEngine; 6 | import javax.script.ScriptEngineManager; 7 | 8 | public class ExeJsUtil { 9 | 10 | /** 11 | * 执行js并返回结果 12 | * @param jsStr 13 | * @return 14 | */ 15 | public static String getJsVal(String jsStr) { 16 | ScriptEngineManager manager = new ScriptEngineManager(); 17 | ScriptEngine engine = manager.getEngineByName("JavaScript"); 18 | try { 19 | Compilable compilable = (Compilable) engine; 20 | CompiledScript JSFunction = compilable.compile(jsStr); 21 | Object result = JSFunction.eval(); 22 | return result != null ? result.toString() : null; 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/MyFileUtil.java: -------------------------------------------------------------------------------- 1 | package zimu.util; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedReader; 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileNotFoundException; 8 | import java.io.FileOutputStream; 9 | import java.io.InputStreamReader; 10 | import java.io.OutputStreamWriter; 11 | import java.io.PrintWriter; 12 | import java.util.ArrayList; 13 | 14 | import cn.hutool.log.Log; 15 | import cn.hutool.log.LogFactory; 16 | 17 | /** 18 | * 19 | * 功能说明:请补充 20 | */ 21 | public class MyFileUtil { 22 | static final Log logger = LogFactory.get(); 23 | 24 | /** 25 | * 获取指定目录文件列表。 26 | */ 27 | public static ArrayList getFileList(String filePath) { 28 | return getFileList(filePath, false); 29 | } 30 | public static ArrayList getFileList(String filePath, boolean sub) { 31 | File file = new File(filePath); 32 | if (!file.exists()) 33 | return null; 34 | return getFileList(file, sub); 35 | } 36 | 37 | private static ArrayList getFileList(File file, boolean sub) { 38 | File[] files = file.listFiles(); 39 | ArrayList r = new ArrayList(); 40 | for (File f : files) { 41 | if (f.isDirectory() && sub) { 42 | r.addAll(getFileList(f, sub)); 43 | } else if (f.isFile()) { 44 | r.add(f); 45 | } 46 | } 47 | return r; 48 | } 49 | 50 | /** 51 | * 获取指定目录子目录列表。 52 | */ 53 | public static ArrayList getPathList(String filePath) { 54 | File file = new File(filePath); 55 | if (!file.exists()) 56 | return null; 57 | return getPathList(file); 58 | } 59 | 60 | private static ArrayList getPathList(File file) { 61 | File[] files = file.listFiles(); 62 | ArrayList r = new ArrayList(); 63 | for (File f : files) { 64 | if (f.isDirectory()) { 65 | r.add(f); 66 | } else if (f.isFile()) { 67 | 68 | } 69 | } 70 | return r; 71 | } 72 | 73 | /* 74 | * isExists 75 | */ 76 | public static boolean isExists(String filename) { 77 | try { 78 | /**//* 查找文件,如果不存在,就创建 */ 79 | File file = new File(filename); 80 | return file.exists(); 81 | } catch (Exception e) { 82 | e.printStackTrace(); 83 | } 84 | return false; 85 | } 86 | 87 | /** 88 | * 删除此路径名表示的文件或目录。 如果此路径名表示一个目录,则会先删除目录下的内容再将目录删除,所以该操作不是原子性的。 如果目录中还有目录,则会引发递归动作。 89 | * 90 | * @param filePath 91 | * 要删除文件或目录的路径。 92 | * @return 当且仅当成功删除文件或目录时,返回 true;否则返回 false。 93 | */ 94 | public static boolean deleteFile(String filePath) { 95 | File file = new File(filePath); 96 | if (!file.exists()) 97 | return false; 98 | return deleteFile(file); 99 | } 100 | 101 | private static boolean deleteFile(File file) { 102 | File[] files = file.listFiles(); 103 | for (File deleteFile : files) { 104 | if (deleteFile.isDirectory()) { 105 | // 如果是文件夹,则递归删除下面的文件后再删除该文件夹 106 | if (!deleteFile(deleteFile)) { 107 | // 如果失败则返回 108 | return false; 109 | } 110 | } else { 111 | if (!deleteFile.delete()) { 112 | // 如果失败则返回 113 | return false; 114 | } 115 | } 116 | } 117 | return file.delete(); 118 | } 119 | 120 | // 取文件夹大小 121 | public static long getDirSize(File dir) { 122 | if (dir == null) { 123 | return 0; 124 | } 125 | if (!dir.isDirectory()) { 126 | return 0; 127 | } 128 | long dirSize = 0; 129 | File[] files = dir.listFiles(); 130 | for (File file : files) { 131 | if (file.isFile()) { 132 | dirSize += file.length(); 133 | } else if (file.isDirectory()) { 134 | dirSize += file.length(); 135 | dirSize += getDirSize(file); // 如果遇到目录则通过递归调用继续统计 136 | } 137 | } 138 | return dirSize; 139 | } 140 | 141 | /* 142 | * FileCreate 143 | */ 144 | public static void fileCreate(String filename) { 145 | try { 146 | /**//* 查找文件,如果不存在,就创建 */ 147 | File file = new File(filename); 148 | if (!file.exists()) 149 | if (!file.createNewFile()) 150 | throw new Exception("文件不存在,创建失败!"); 151 | 152 | } catch (Exception e) { 153 | logger.error(e); 154 | } 155 | } 156 | 157 | /* 158 | * DirCreate 159 | */ 160 | public static void dirCreate(String filepath) { 161 | try { 162 | /**//* 查找目录,如果不存在,就创建 */ 163 | File dirFile = new File(filepath); 164 | if (!dirFile.exists()) { 165 | if (!dirFile.mkdir()) 166 | throw new Exception("目录不存在,创建失败!"); 167 | } 168 | 169 | } catch (Exception e) { 170 | logger.error( e); 171 | } 172 | } 173 | 174 | public static void dirCreate(String filepath, boolean sub) { 175 | if (sub) { 176 | filepath = filepath.replaceAll("\\\\", "/"); 177 | String arr[] = filepath.split("\\/"); 178 | String path = ""; 179 | for (String dir : arr) { 180 | path += dir + "/"; 181 | dirCreate(path); 182 | } 183 | 184 | } else { 185 | dirCreate(filepath); 186 | } 187 | } 188 | 189 | /* 190 | * Write a TXT file 191 | */ 192 | public static boolean fileWrite(String filename, String str) { 193 | return MyFileUtil.fileWrite(filename, str, "UTF-8", ""); 194 | } 195 | 196 | public static boolean fileWrite(String filename, String str, String mode) { 197 | return fileWrite(filename, str, "UTF-8", mode); 198 | } 199 | 200 | public static boolean fileWrite(String filename, String str, String encode, String mode) { 201 | return fileWrite(new File(filename), str, encode, mode); 202 | } 203 | 204 | public static boolean fileWrite(File file, String str) { 205 | return MyFileUtil.fileWrite(file, str, "UTF-8", ""); 206 | } 207 | 208 | public static boolean fileWrite(File file, String str, String mode) { 209 | return fileWrite(file, str, "UTF-8", mode); 210 | } 211 | 212 | public static boolean fileWrite(File file, String str, String encode, String mode) { 213 | try { 214 | OutputStreamWriter fw; 215 | PrintWriter pw; 216 | if (mode.equals("a+")) { 217 | fw = new OutputStreamWriter(new FileOutputStream(file, true), encode); 218 | pw = new java.io.PrintWriter(fw); 219 | pw.print(str); 220 | } else { 221 | fw = new OutputStreamWriter(new FileOutputStream(file, false), encode); 222 | pw = new java.io.PrintWriter(fw); 223 | pw.print(str); 224 | } 225 | pw.close(); 226 | fw.close(); 227 | return true; 228 | } catch (Exception e) { 229 | logger.error( e); 230 | return false; 231 | } 232 | } 233 | 234 | public static boolean fileWriteBin(String filename, byte[] buf) { 235 | return fileWriteBin(new File(filename), buf); 236 | } 237 | 238 | public static boolean fileWriteBin(File file, byte[] buf) { 239 | try { 240 | if (!file.exists()) { 241 | file.createNewFile(); // 如果文件不存在,则创建 242 | } 243 | FileOutputStream fos = new FileOutputStream(file); 244 | fos.write(buf); 245 | fos.close(); 246 | return true; 247 | } catch (Exception e) { 248 | logger.error(e); 249 | return false; 250 | } 251 | } 252 | 253 | /* 254 | * 读取文件,原始数据,速度:中 2M文件读取10次:2.328秒 255 | */ 256 | public static String fileRead(String filename) { 257 | return fileRead(filename, "UTF-8"); 258 | } 259 | 260 | public static String fileRead(File file) { 261 | return fileRead(file, "UTF-8"); 262 | } 263 | 264 | public static String fileRead(String filename, String encode) { 265 | return fileRead(new File(filename), encode); 266 | } 267 | 268 | public static String fileRead(File file, String encode) { 269 | if (!file.exists()) { 270 | return null; 271 | } 272 | try { 273 | return fileRead(new FileInputStream(file), encode); 274 | } catch (FileNotFoundException e) { 275 | logger.error(e); 276 | return null; 277 | } 278 | } 279 | 280 | public static String fileRead(FileInputStream file, String encode) { 281 | int ch; 282 | StringBuffer strb = new StringBuffer(); 283 | try { 284 | BufferedReader fw = new BufferedReader(new InputStreamReader(file, encode)); 285 | while ((ch = fw.read()) > -1) { 286 | strb.append((char) ch); 287 | } 288 | fw.close(); 289 | } catch (Exception e) { 290 | logger.error( e); 291 | } 292 | return strb.toString(); 293 | } 294 | 295 | /* 296 | * Read a TXT file 297 | */ 298 | public static String[] fileReadArray(String filename) { 299 | try { 300 | return MyFileUtil.fileRead(filename).split("\n"); 301 | } catch (Exception e) { 302 | logger.error( e); 303 | } 304 | return new String[0]; 305 | } 306 | 307 | /* 308 | * 读取文件,以\n连接,速度:快 2M文件读取10次:1.406秒 309 | */ 310 | public static String fileReadLine(String filename, String encode) { 311 | String s; 312 | StringBuffer strb = new StringBuffer(); 313 | try { 314 | BufferedReader brIn = new BufferedReader(new InputStreamReader(new FileInputStream(filename), encode)); 315 | while ((s = brIn.readLine()) != null) { 316 | strb.append(s); 317 | strb.append("\n"); 318 | } 319 | brIn.close(); 320 | } catch (Exception e) { 321 | logger.error(e); 322 | } 323 | return strb.toString(); 324 | } 325 | 326 | /** 327 | * 读文件到字节数组 328 | * 329 | * @param file 330 | * @return 331 | * @throws Exception 332 | */ 333 | public static byte[] fileReadBin(String filePath) { 334 | return fileReadBin(new File(filePath)); 335 | } 336 | 337 | public static byte[] fileReadBin(File file) { 338 | try { 339 | if (file.exists() && file.isFile()) { 340 | long fileLength = file.length(); 341 | if (fileLength > 0L) { 342 | BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file)); 343 | byte[] b = new byte[(int) fileLength]; 344 | while (fis.read(b) != -1) { 345 | } 346 | fis.close(); 347 | fis = null; 348 | 349 | return b; 350 | } 351 | } else { 352 | return null; 353 | } 354 | } catch (Exception e) { 355 | logger.error( e); 356 | } 357 | return null; 358 | } 359 | 360 | public static BufferedInputStream getStream(String filePath) { 361 | File file = new File(filePath); 362 | return getStream(file); 363 | } 364 | 365 | public static BufferedInputStream getStream(File file) { 366 | try { 367 | if (file.exists() && file.isFile()) { 368 | return new BufferedInputStream(new FileInputStream(file)); 369 | } else { 370 | return null; 371 | } 372 | } catch (Exception e) { 373 | logger.error( e); 374 | } 375 | return null; 376 | } 377 | 378 | } 379 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package zimu.util; 2 | 3 | import java.io.File; 4 | 5 | public class StringUtil { 6 | public static String getPrintSize(long size) { 7 | // 如果字节数少于1024,则直接以B为单位,否则先除于1024,后3位因太少无意义 8 | if (size < 1024) { 9 | return String.valueOf(size) + "B"; 10 | } else { 11 | size = size / 1024; 12 | } 13 | // 如果原字节数除于1024之后,少于1024,则可以直接以KB作为单位 14 | // 因为还没有到达要使用另一个单位的时候 15 | // 接下去以此类推 16 | if (size < 1024) { 17 | return String.valueOf(size) + "KB"; 18 | } else { 19 | size = size / 1024; 20 | } 21 | if (size < 1024) { 22 | // 因为如果以MB为单位的话,要保留最后1位小数, 23 | // 因此,把此数乘以100之后再取余 24 | size = size * 100; 25 | return String.valueOf((size / 100)) + "." + String.valueOf((size % 100)) + "MB"; 26 | } else { 27 | // 否则如果要以GB为单位的,先除于1024再作同样的处理 28 | size = size * 100 / 1024; 29 | return String.valueOf((size / 100)) + "." + String.valueOf((size % 100)) + "GB"; 30 | } 31 | } 32 | /** 33 | * 返回字符串的文件名,过滤目录字符 34 | * 35 | * @param str 36 | * 字符串 37 | * 38 | * @return 字符串 39 | */ 40 | public static String basename(String str) { 41 | int pos = str.lastIndexOf('/'); 42 | int pos2 = str.lastIndexOf('\\'); 43 | if (str.length() == 0) 44 | return ""; 45 | if (pos > pos2) { 46 | return str.substring(pos + 1); 47 | } else { 48 | return str.substring(pos2 + 1); 49 | } 50 | } 51 | 52 | /** 53 | * 返回字符串的目录,过滤文件名字符 54 | * 55 | * @param str 56 | * 字符串 57 | * 58 | * @return 字符串 59 | */ 60 | public static String dirname(String str) { 61 | int pos = str.lastIndexOf('/'); 62 | int pos2 = str.lastIndexOf('\\'); 63 | if (str.length() == 0) 64 | return ""; 65 | if (pos > pos2) { 66 | return str.substring(0, pos + 1); 67 | } else { 68 | return str.substring(0, pos2 + 1); 69 | } 70 | } 71 | 72 | /** 73 | * 获得文件的扩展名,扩展名不带“.” 74 | * 75 | * @param fileName 文件名 76 | * @return 扩展名 77 | */ 78 | public static String extName(String fileName) { 79 | int pos = fileName.lastIndexOf('.'); 80 | if (pos>-1) { 81 | return fileName.substring(pos + 1); 82 | } else { 83 | return ""; 84 | } 85 | } 86 | public static String extName(File file) { 87 | return extName(file.getName()); 88 | } 89 | 90 | 91 | /** 92 | * 获取基础网址 93 | * @param url 94 | * @return 95 | */ 96 | public static String getBaseUrl(String url) { 97 | int pos = url.indexOf("/", 10); 98 | return pos > 0 ? url.substring(0, pos+1) : url+"/"; 99 | } 100 | 101 | public static void main(String[] args) { 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/WinRarUtil.java: -------------------------------------------------------------------------------- 1 | package zimu.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.util.List; 8 | 9 | import cn.hutool.json.JSONUtil; 10 | import cn.hutool.log.Log; 11 | import cn.hutool.log.LogFactory; 12 | import zimu.AppConfig; 13 | 14 | public class WinRarUtil { 15 | static final Log logger = LogFactory.get(); 16 | public static String binPath = ""; 17 | public static void main(String[] args) throws Exception { 18 | binPath = "E:\\workspace\\_me\\dev\\my_libs\\test_lib\\data\\file\\archive\\UnRAR.exe"; 19 | 20 | String srcData = "E:\\workspace\\_me\\dev\\my_libs\\test_lib\\data\\file\\archive\\test2.rar"; 21 | byte[] data = MyFileUtil.fileReadBin(srcData); 22 | String objPath = "E:\\workspace\\_me\\dev\\my_libs\\test_lib\\data\\file\\archive\\"+System.currentTimeMillis(); 23 | String extName = "rar"; 24 | List result = unRar(extName, data, objPath); 25 | 26 | System.out.println(JSONUtil.toJsonPrettyStr(result)); 27 | clear(objPath); 28 | } 29 | static { 30 | if(AppConfig.isExe) { 31 | binPath = AppConfig.appPath + "bin/7z.exe"; 32 | }else { 33 | binPath = AppConfig.appPath + "../../_release/bin/7z.exe"; 34 | } 35 | //System.out.println(binPath); 36 | } 37 | 38 | 39 | /** 40 | * 清除目录 41 | * @param objPath 42 | */ 43 | public static void clear(String objPath) { 44 | if(new File(objPath).exists()) { 45 | logger.info("清除临时目录:"+objPath); 46 | MyFileUtil.deleteFile(objPath); 47 | } 48 | } 49 | 50 | /** 51 | * 返回当前系统路径分隔符 52 | * @param objPath 53 | * @return 54 | */ 55 | public static String osPath(String objPath) { 56 | return objPath.replace("/", File.separator); 57 | } 58 | 59 | /** 60 | * 解压二进制压缩数据 61 | * @param extName 62 | * @param data 63 | * @param objPath 64 | * @return 65 | */ 66 | public static List unRar(String extName, byte[] data, String objPath) { 67 | Runtime rt = Runtime.getRuntime(); 68 | StringBuffer result = new StringBuffer(); 69 | try { 70 | logger.info("在临时目录中解压:"+objPath); 71 | if(!new File(objPath).exists()) { 72 | MyFileUtil.dirCreate(objPath, true); 73 | } 74 | String objFile = String.format("%s/data.%s", objPath, extName); 75 | MyFileUtil.fileWriteBin(objFile, data); 76 | //String execStr = String.format("%s e -r -o+ -ap %s -ad %s", osPath(binPath), osPath(objFile), osPath(objPath)); 77 | String execStr = String.format("%s e \"%s\" -o\"%s\" -aoa", osPath(binPath), osPath(objFile), osPath(objPath+"/data")); 78 | Process p = rt.exec(execStr);//rt.exec(execStr, null, new File(objPath)); 79 | logger.info("解压命令: "+execStr); 80 | 81 | InputStream fis = p.getInputStream(); 82 | InputStreamReader isr = new InputStreamReader(fis,"GBK"); 83 | BufferedReader br = new BufferedReader(isr); 84 | String line = null; 85 | while ((line = br.readLine()) != null) { 86 | result.append(line); 87 | result.append("\r\n"); 88 | } 89 | logger.info(result.toString()); 90 | if(result.indexOf("Everything is Ok") > 0) {//if(result.indexOf("全部正常") > 0) { 91 | logger.info("解压成功"); 92 | }else { 93 | logger.error("解压失败"); 94 | return null; 95 | } 96 | }catch(Exception e) { 97 | e.printStackTrace(); 98 | return null; 99 | } 100 | return MyFileUtil.getFileList(objPath, true); 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/regex/AbstractReplaceCallBack.java: -------------------------------------------------------------------------------- 1 | package zimu.util.regex; 2 | 3 | import java.util.regex.Matcher; 4 | 5 | public abstract class AbstractReplaceCallBack implements ReplaceCallBack { 6 | 7 | protected Matcher matcher; 8 | 9 | /* 10 | * (non-Javadoc) 11 | * 12 | * @see utils.ReplaceCallBack#replace(java.lang.String, int, java.util.regex.Matcher) 13 | */ 14 | final public String replace(String text, int index, Matcher matcher) { 15 | this.matcher = matcher; 16 | try { 17 | return doReplace(text, index, matcher); 18 | } finally { 19 | this.matcher = null; 20 | } 21 | } 22 | 23 | /** 24 | * 将text转化为特定的字串返回 25 | * 26 | * @param text 27 | * 指定的字符串 28 | * @param index 29 | * 替换的次序 30 | * @param matcher 31 | * Matcher对象 32 | * @return 33 | */ 34 | public abstract String doReplace(String text, int index, Matcher matcher); 35 | 36 | /** 37 | * 获得matcher中的组数据 38 | *

39 | * 等同于matcher.group(group) 40 | *

41 | * 该函数只能在{@link #doReplace(String, int, Matcher)} 中调用 42 | * 43 | * @param group 44 | * @return 45 | */ 46 | protected String $(int group) { 47 | String data = matcher.group(group); 48 | return data == null ? "" : data; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/regex/RegexUtil.java: -------------------------------------------------------------------------------- 1 | package zimu.util.regex; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import cn.hutool.core.util.StrUtil; 7 | import cn.hutool.json.JSONArray; 8 | 9 | 10 | 11 | /** 12 |

 13 |  
 14 |  多个flags 这样使用  Pattern.CASE_INSENSITIVE|Pattern.DOTALL
 15 | Pattern.CASE_INSENSITIVE  
 16 | 	将启动对ASCII字符不区分大小写匹配  
 17 | Pattern.UNICODE_CASE  
 18 | 	将启动Unicode字符不区分大小写匹配  
 19 | Pattern.DOTALL  
 20 | 	将启动dotall模式,该模式下,"."将表示任意字符,包括回车符  
 21 | 	
 22 | Pattern.CANON_EQ 当且仅当两个字符的”正规分解(canonical decomposition)”都完全相同的情况下,才认定匹配.比如用了这个标志之后,表达式”a\u030A”会匹配”?”.默认情况下,不考虑”规范相等性(canonical equivalence)”.
 23 | 
 24 | Pattern.CASE_INSENSITIVE(?i) 默认情况下,大小写不明感的匹配只适用于US-ASCII字符集.这个标志能让表达式忽略大小写进行匹配.要想对Unicode字符进行大小不明感的匹 配,只要将UNICODE_CASE与这个标志合起来就行了.
 25 | 
 26 | Pattern.COMMENTS(?x) 在这种模式下,匹配时会忽略(正则表达式里的)空格字符(译者注:不是指表达式里的”\s”,而是指表达式里的空格,tab,回车之类).注释从#开始,一直到这行结束.可以通过嵌入式的标志来启用Unix行模式.
 27 | 
 28 | Pattern.DOTALL(?s)在这种模式下,表达式’.’可以匹配任意字符,包括表示一行的结束符。默认情况下,表达式’.’不匹配行的结束符.
 29 | 
 30 | Pattern.MULTILINE(?m)在这种模式下,’\^’和’$’分别匹配一行的开始和结束.此外,’^’仍然匹配字符串的开始,’$’也匹配字符串的结束.默认情况下,这两个表达式仅仅匹配字符串的开始和结束.
 31 | 
 32 | Pattern.UNICODE_CASE(?u) 在这个模式下,如果你还启用了CASE_INSENSITIVE标志,那么它会对Unicode字符进行大小写不明感的匹配.默认情况下,大小写不敏感的匹配只适用于US-ASCII字符集.
 33 | 
 34 | Pattern.UNIX_LINES(?d) 在这个模式下,只有’\n’才被认作一行的中止,并且与’.’,’^’,以及’$’进行匹配.
 35 |  
36 | * 37 | */ 38 | public class RegexUtil { 39 | public static void main(String[] args) { 40 | System.out.println(getMatchStr("aaaabb=123bccc", "aaaabb=([\\d]+)")); 41 | System.out.println(getMatchList("aaaabb=123bccc345AAA,aaaabb123bccc345AAA,aaaabb123bccc345AAA", "aaaabb=([\\d]+)[^,]+(AAA)")); 42 | } 43 | 44 | /** 45 | * 获取匹配字符串 46 | * 47 | * @return 48 | */ 49 | public static String getMatchStr(String str, String regex) { 50 | if (str == null) { 51 | return ""; 52 | } 53 | Pattern pattern = Pattern.compile(regex); 54 | Matcher m = pattern.matcher(str); 55 | if (m.find()) { 56 | return m.group(1); 57 | } 58 | return ""; 59 | } 60 | public static String getMatchStr(String str, String regex, int flags) { 61 | if (str == null) { 62 | return ""; 63 | } 64 | Pattern pattern = Pattern.compile(regex, flags); 65 | Matcher m = pattern.matcher(str); 66 | if (m.find()) { 67 | return m.group(1); 68 | } 69 | return ""; 70 | } 71 | /** 72 | * 获取匹配列表--1维数组 73 | * @param str 74 | * @param regex 75 | * @return 76 | */ 77 | public static String[] getMatchArray(String str, String regex) { 78 | if (str == null) { 79 | return new String[]{}; 80 | } 81 | Pattern pattern = Pattern.compile(regex); 82 | Matcher m = pattern.matcher(str); 83 | while (m.find()) { 84 | String[] arr = new String[m.groupCount()]; 85 | for(int i = 1; i <= m.groupCount(); i++){ 86 | arr[i-1] = m.group(i); 87 | } 88 | return arr; 89 | } 90 | return new String[]{}; 91 | } 92 | 93 | public static String[] getMatchArray(String str, String regex, int flags) { 94 | if (str == null) { 95 | return new String[]{}; 96 | } 97 | Pattern pattern = Pattern.compile(regex, flags); 98 | Matcher m = pattern.matcher(str); 99 | while (m.find()) { 100 | String[] arr = new String[m.groupCount()]; 101 | for(int i = 1; i <= m.groupCount(); i++){ 102 | arr[i-1] = m.group(i); 103 | } 104 | return arr; 105 | } 106 | return new String[]{}; 107 | } 108 | 109 | /** 110 | * 获取匹配列表--2维数组 111 | * @param str 112 | * @param regex 113 | * @return 114 | */ 115 | public static JSONArray getMatchList(String str, String regex) { 116 | JSONArray list = new JSONArray(); 117 | if (str == null) { 118 | return list; 119 | } 120 | Pattern pattern = Pattern.compile(regex); 121 | Matcher m = pattern.matcher(str); 122 | while (m.find()) { 123 | JSONArray row = new JSONArray(); 124 | for(int i = 1; i <= m.groupCount(); i++){ 125 | row.add(m.group(i)); 126 | } 127 | list.add(row); 128 | } 129 | return list; 130 | } 131 | public static JSONArray getMatchList(String str, String regex, int flags) { 132 | JSONArray list = new JSONArray(); 133 | if (str == null) { 134 | return list; 135 | } 136 | Pattern pattern = Pattern.compile(regex, flags); 137 | Matcher m = pattern.matcher(str); 138 | while (m.find()) { 139 | JSONArray row = new JSONArray(); 140 | for(int i = 1; i <= m.groupCount(); i++){ 141 | row.add(m.group(i)); 142 | } 143 | list.add(row); 144 | } 145 | return list; 146 | } 147 | 148 | /** 149 | * 将String中的所有regex匹配的字串全部替换掉 150 | * 151 | * @param string 152 | * 代替换的字符串 153 | * @param regex 154 | * 替换查找的正则表达式 155 | * @param replacement 156 | * 替换函数 157 | * @return 158 | */ 159 | public static String replaceAll(String string, String regex, ReplaceCallBack replacement) { 160 | return replaceAll(string, Pattern.compile(regex), replacement); 161 | } 162 | public static String replaceAll(String string, String regex, int flags, ReplaceCallBack replacement) { 163 | return replaceAll(string, Pattern.compile(regex, flags), replacement); 164 | } 165 | 166 | /** 167 | * 将String中的所有pattern匹配的字串替换掉 168 | * 169 | * @param string 170 | * 代替换的字符串 171 | * @param pattern 172 | * 替换查找的正则表达式对象 173 | * @param replacement 174 | * 替换函数 175 | * @return 176 | */ 177 | public static String replaceAll(String string, Pattern pattern, ReplaceCallBack replacement) { 178 | if (string == null) { 179 | return null; 180 | } 181 | Matcher m = pattern.matcher(string); 182 | if (m.find()) { 183 | StringBuffer sb = new StringBuffer(); 184 | int index = 0; 185 | while (true) { 186 | m.appendReplacement(sb, replacement.replace(m.group(0), index++, m)); 187 | if (!m.find()) { 188 | break; 189 | } 190 | } 191 | m.appendTail(sb); 192 | return sb.toString(); 193 | } 194 | return string; 195 | } 196 | 197 | /** 198 | * 将String中的regex第一次匹配的字串替换掉 199 | * 200 | * @param string 201 | * 代替换的字符串 202 | * @param regex 203 | * 替换查找的正则表达式 204 | * @param replacement 205 | * 替换函数 206 | * @return 207 | */ 208 | public static String replaceFirst(String string, String regex, ReplaceCallBack replacement) { 209 | return replaceFirst(string, Pattern.compile(regex), replacement); 210 | } 211 | public static String replaceFirst(String string, String regex, int flags, ReplaceCallBack replacement) { 212 | return replaceFirst(string, Pattern.compile(regex, flags), replacement); 213 | } 214 | 215 | /** 216 | * 将String中的pattern第一次匹配的字串替换掉 217 | * 218 | * @param string 219 | * 代替换的字符串 220 | * @param pattern 221 | * 替换查找的正则表达式对象 222 | * @param replacement 223 | * 替换函数 224 | * @return 225 | */ 226 | public static String replaceFirst(String string, Pattern pattern, ReplaceCallBack replacement) { 227 | if (string == null) { 228 | return null; 229 | } 230 | Matcher m = pattern.matcher(string); 231 | StringBuffer sb = new StringBuffer(); 232 | if (m.find()) { 233 | m.appendReplacement(sb, replacement.replace(m.group(0), 0, m)); 234 | } 235 | m.appendTail(sb); 236 | return sb.toString(); 237 | } 238 | 239 | 240 | 241 | /** 242 | * 转义正则特殊字符 ($()*+.[]?\^{},|) 243 | * 244 | * @param keyword 245 | * @return 246 | */ 247 | public static String escapeExprSpecialWord(String keyword) { 248 | if (StrUtil.isNotEmpty(keyword)) { 249 | //Java过滤正则表达式特殊字代码如下(注意:\\需要第一个替换,否则replace方法替换时会有逻辑bug) 250 | String[] fbsArr = { "\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" }; 251 | for (String key : fbsArr) { 252 | if (keyword.contains(key)) { 253 | keyword = keyword.replace(key, "\\" + key); 254 | } 255 | } 256 | } 257 | return keyword; 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/regex/ReplaceCallBack.java: -------------------------------------------------------------------------------- 1 | package zimu.util.regex; 2 | 3 | import java.util.regex.Matcher; 4 | 5 | /** 6 | * 字符串替换的回调接口 7 | * 8 | * @author yeyong 9 | * 10 | */ 11 | public interface ReplaceCallBack { 12 | /** 13 | * 将text转化为特定的字串返回 14 | * 15 | * @param text 16 | * 指定的字符串 17 | * @param index 18 | * 替换的次序 19 | * @param matcher 20 | * Matcher对象 21 | * @return 22 | */ 23 | public String replace(String text, int index, Matcher matcher); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/zimu/util/regex/Test.java: -------------------------------------------------------------------------------- 1 | package zimu.util.regex; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.regex.Matcher; 6 | 7 | public class Test { 8 | 9 | public static void main(String[] args) { 10 | String string = "the quick-brown fox jumps over the lazy-dog."; 11 | String pattern = "\\b(\\w)(\\w*?)\\b"; 12 | // 将每个单词改为首字大写其他字母小写 13 | System.out.println(RegexUtil.replaceAll(string, pattern, new AbstractReplaceCallBack() { 14 | public String doReplace(String text, int index, Matcher matcher) { 15 | return $(1).toUpperCase() + $(2).toLowerCase(); 16 | } 17 | })); 18 | // 输出:The Quick-Brown Fox Jumps Over The Lazy-Dog. 19 | 20 | // 将文本中类似aaa-bbb-ccc的替换为AaaBbbCcc 21 | string = "the quick-brown fox jumps over the lazy-dog. aaa-bbbb-cccc-ddd"; 22 | pattern = "\\b\\w+(?:-\\w+)+\\b"; 23 | System.out.println(RegexUtil.replaceAll(string, pattern, new AbstractReplaceCallBack() { 24 | private ReplaceCallBack callBack = new AbstractReplaceCallBack() { 25 | public String doReplace(String text, int index, Matcher matcher) { 26 | return $(1).toUpperCase() + $(2).toLowerCase(); 27 | } 28 | }; 29 | 30 | public String doReplace(String text, int index, Matcher matcher) { 31 | return RegexUtil.replaceAll(text, "(?:\\b|-)(\\w)(\\w*?)\\b", callBack); 32 | } 33 | })); 34 | // 输出: the QuickBrown fox jumps over the LazyDog. AaaBbbbCcccDdd 35 | 36 | // 过滤安全字符... TODO 应提取为一个方法 37 | final Map map = new HashMap() { 38 | private static final long serialVersionUID = 1L; 39 | { 40 | put("<", "<"); 41 | put(">", ">"); 42 | put("\"", """); 43 | put("'", "'"); 44 | } 45 | }; 46 | ReplaceCallBack callBack = new ReplaceCallBack() { 47 | public String replace(String text, int index, Matcher matcher) { 48 | return map.get(text); 49 | } 50 | }; 51 | string = "xxxxx 1<4 & 7>5"; 52 | System.out.println(RegexUtil.replaceAll(string.replace("&", "&"), "[<>\"\']", callBack)); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/resources/html/extract_dialog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ExtractDialog 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 40 | 44 |
45 |
46 | 47 | 48 | 68 | 69 |
70 |
71 | 87 |
88 | 89 | 90 | -------------------------------------------------------------------------------- /src/main/resources/html/images/btn_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/btn_about.png -------------------------------------------------------------------------------- /src/main/resources/html/images/css/style.css: -------------------------------------------------------------------------------- 1 | /*公共属性*/ 2 | body, dl, dt, dd, ol, ul, pre, form,input, textarea, select, button, file, field, p, blockquote, h1, h2, h3, h4, h5, h6,th, td { 3 | font-family:"微软雅黑","Microsoft Yahei","Source Sans Pro", Helvetica, Arial, sans-serif,"宋体"; 4 | margin:0; padding:0; 5 | 6 | font-size:12px; 7 | } 8 | 9 | a{text-decoration:none;} 10 | a:link, a:visited { text-decoration:none; } 11 | a:hover, a:active { text-decoration:underline; } 12 | 13 | 14 | ul, ol { list-style:none;list-style-type:none;} 15 | img { border:0;} 16 | 17 | 18 | b{font-size:bold;} 19 | :focus { 20 | outline: 0; 21 | } 22 | input,textarea,button{ 23 | outline:none; 24 | resize:none; 25 | 26 | -webkit-appearance:none; 27 | appearance:none; 28 | 29 | -webkit-border-radius: 0px; 30 | -moz-border-radius: 0px; 31 | border-radius: 0px; 32 | 33 | } 34 | button,input[type=button],input[type=submit],input[type=reset]{ 35 | 36 | } 37 | 38 | select, input, textarea, button {outline:none; resize:none;} 39 | 40 | 41 | 42 | .clearfix { 43 | *zoom: 1; 44 | } 45 | .clearfix:before, 46 | .clearfix:after { 47 | display: table; 48 | content: ""; 49 | line-height: 0; 50 | } 51 | .clearfix:after { 52 | clear: both; 53 | } 54 | 55 | body{ 56 | -webkit-touch-callout: none; 57 | -webkit-user-select: none; 58 | -moz-user-select: none; 59 | -ms-user-select: none; 60 | user-select: none; 61 | background:#fff; 62 | } 63 | 64 | html,body{ 65 | height:100%; 66 | box-sizing:border-box; 67 | overflow: hidden; 68 | } 69 | 70 | 71 | .input {height:22px; line-height:22px;background:#FFFFFF; color:#666666; border:1px solid #CCCCCC; padding:1px} 72 | .input:hover {background:#FFFAF0; color:#666666; border:1px solid #7F9DB9;} 73 | .input:focus {background:#FFFFFF; color:#14238A; border:1px solid #7F9DB9;} 74 | .input[readonly] {background:#eeeeee; color:#888888; border:1px solid #CCCCCC;} 75 | .input[disabled] {background:#efefef; color:#aaa; border:1px solid #ddd;} 76 | 77 | 78 | .textarea {background:#FFFFFF; color:#666666; border:1px solid #CCCCCC; padding:1px} 79 | .textarea:hover {background:#FFFAF0; color:#666666; border:1px solid #7F9DB9;} 80 | .textarea:focus {background:#FFFFFF; color:#14238A; border:1px solid #7F9DB9;} 81 | .textarea[readonly] {background:#eeeeee; color:#888888; border:1px solid #CCCCCC;} 82 | .textarea[disabled] {background:#efefef; color:#aaa; border:1px solid #ddd;} 83 | 84 | 85 | 86 | .button1{ 87 | box-sizing:border-box; 88 | -moz-box-sizing:border-box; 89 | -webkit-box-sizing:border-box; 90 | 91 | padding:6px 10px 6px 10px; 92 | height:28px; 93 | line-height:28px; 94 | 95 | color: #565f64; 96 | 97 | border: 1px solid #cecece; 98 | background: #fcfcfc; 99 | background: -webkit-linear-gradient(top,#fcfcfc 0,#fcfcfc 50%,#e7e7e7 100%); 100 | background: -moz-linear-gradient(top,#fcfcfc 0,#fcfcfc 50%,#e7e7e7 100%); 101 | background: -ms-linear-gradient(top,#fcfcfc 0,#fcfcfc 50%,#e7e7e7 100%); 102 | background: -o-linear-gradient(top,#fcfcfc 0,#fcfcfc 50%,#e7e7e7 100%); 103 | background: linear-gradient(top,#fcfcfc 0,#fcfcfc 50%,#e7e7e7 100%); 104 | 105 | border-radius: 2px; 106 | 107 | cursor:pointer; 108 | text-decoration:none; 109 | } 110 | input.button1{ 111 | padding:4px 10px 4px 10px; 112 | height:26px; 113 | line-height:16px; 114 | } 115 | .button1:hover{ 116 | text-decoration:none; 117 | color: #565f64; 118 | background: #fcfcfc; 119 | background: -webkit-linear-gradient(top,#fcfcfc 0,#e7e7e7 100%); 120 | background: -moz-linear-gradient(top,#fcfcfc 0,#e7e7e7 100%); 121 | background: -ms-linear-gradient(top,#fcfcfc 0,#e7e7e7 100%); 122 | background: -o-linear-gradient(top,#fcfcfc 0,#e7e7e7 100%); 123 | background: linear-gradient(top,#fcfcfc 0,#e7e7e7 100%) 124 | } 125 | .button1:active{ 126 | text-decoration:none; 127 | background: #f7f7f7; 128 | box-shadow: inset 3px 3px 5px -2px #cecece; 129 | } 130 | 131 | .button1:focus{ 132 | text-decoration:none; 133 | border-color: #9b9b9b 134 | } 135 | .button1[disabled]{ 136 | cursor:default; 137 | border:0px; 138 | background:#E1E1E1; 139 | color:#AAAAAA; 140 | } 141 | 142 | 143 | .button2{ 144 | box-sizing:border-box; 145 | -moz-box-sizing:border-box; 146 | -webkit-box-sizing:border-box; 147 | 148 | padding:6px 10px 6px 10px; 149 | height:24px; 150 | line-height:24px; 151 | 152 | color: #fff; 153 | 154 | border: 0; 155 | background:#A3A3A3; 156 | 157 | border-radius: 2px; 158 | 159 | cursor:pointer; 160 | text-decoration:none; 161 | } 162 | input.button2{ 163 | padding:4px 10px 4px 10px; 164 | height:26px; 165 | line-height:16px; 166 | } 167 | .button2:hover{ 168 | text-decoration:none; 169 | background:#666666; 170 | color:#fff; 171 | 172 | -webkit-transition: all 0.20s ease-in; 173 | -moz-transition: all 0.20s ease-in; 174 | -o-transition: all 0.20s ease-in; 175 | -ms-transition: all 0.20s ease-in; 176 | transition: all 0.20s ease-in; 177 | } 178 | .button2:active{ 179 | text-decoration:none; 180 | background:#666666; 181 | color:#fff; 182 | 183 | -webkit-transition: all 0.20s ease-in; 184 | -moz-transition: all 0.20s ease-in; 185 | -o-transition: all 0.20s ease-in; 186 | -ms-transition: all 0.20s ease-in; 187 | transition: all 0.20s ease-in; 188 | } 189 | 190 | .button2:focus{ 191 | text-decoration:none; 192 | border-color: #9b9b9b 193 | } 194 | .button2[disabled]{ 195 | cursor:default; 196 | border:0px; 197 | background:#E1E1E1; 198 | color:#AAAAAA; 199 | } 200 | 201 | 202 | #search_box{ 203 | background:#eee; 204 | } 205 | #search_box .con{ 206 | padding:5px; 207 | } 208 | #list_body{ 209 | overflow-y:scroll; 210 | 211 | height:100px; 212 | 213 | -webkit-user-select: text; 214 | -moz-user-select: text; 215 | -ms-user-select: text; 216 | user-select: text; 217 | } 218 | #list_header{ 219 | 220 | } 221 | #list_footer{ 222 | position:fixed; 223 | bottom:0; 224 | left:0; 225 | width:100%; 226 | line-height:40px; 227 | background:#eee; 228 | } 229 | 230 | .list_table { 231 | width: 100%; 232 | border-collapse: collapse; 233 | background:#ffffff; 234 | } 235 | .list_table>tbody>tr{ 236 | background:#F9F9F9; 237 | } 238 | .list_table>tbody>tr>td:nth-child(even){ 239 | background:#FFFFFF; 240 | } 241 | .list_table>tbody>tr:nth-child(even){ 242 | background:#EEEEEE; 243 | } 244 | .list_table>tbody>tr:nth-child(even)>td:nth-child(even){ 245 | background:#F6F6F6; 246 | } 247 | 248 | .list_table>tbody>tr:hover>td{ 249 | background:#F2ED7C !important; 250 | } 251 | .list_table>tbody>tr:hover>td:nth-child(even){ 252 | background:#FCF790 !important; 253 | } 254 | .list_table>tbody>tr .td_op{ 255 | background:#F0EDE8 !important; 256 | } 257 | .list_table>tbody>tr:nth-child(even) .td_op{ 258 | background:#DFDFDF !important; 259 | } 260 | .list_table>tbody>tr:hover>td.td_op{ 261 | background:#C6F0F5 !important; 262 | } 263 | 264 | .list_table>tbody>tr .btn{ 265 | margin:1px 2px; 266 | padding:4px 9px 3px 9px; 267 | -webkit-border-radius: 5px; 268 | -moz-border-radius: 5px; 269 | border-radius: 5px; 270 | display:inline-block; 271 | text-align:center; 272 | text-decoration: none; 273 | color:#1C84C6; 274 | } 275 | .list_table>tbody>tr .btn_gray{ 276 | color:#aaa; 277 | } 278 | 279 | .list_table>tbody>tr:hover .btn{ 280 | background:rgba(163,163,163, 0.6); 281 | color:#fff; 282 | 283 | } 284 | .list_table>tbody>tr:hover .btn *{ 285 | color:#000; 286 | } 287 | .list_table>tbody>tr:hover .font_gray{ 288 | color:#eee; 289 | } 290 | 291 | 292 | .list_table>tbody>tr:hover .btn:hover{ 293 | background:#A3A3A3; 294 | color:#fff; 295 | text-decoration: none; 296 | } 297 | .list_table>tbody>tr:hover .btn:hover *{ 298 | color:#fff; 299 | } 300 | 301 | 302 | .list_table>thead>tr>th { 303 | color: #555; 304 | background:#E1E1E1; 305 | border-top: 1px solid #DDDDDD; 306 | text-align:center; 307 | padding:8px 3px; 308 | } 309 | .list_table>thead>tr>th:nth-child(even){ 310 | background:#E8E8E8; 311 | } 312 | .list_table>tbody>tr>td { 313 | border-top: 1px solid #DDDDDD; 314 | border-bottom: none; 315 | color:#898E94; 316 | padding:4px 3px; 317 | } 318 | 319 | .list_table>tbody>tr:last-child{ 320 | border-bottom: 1px solid #DDDDDD; 321 | } 322 | 323 | 324 | .list_no_data{ 325 | padding:20px; 326 | margin:0px auto; 327 | text-align:center; 328 | font-size:14px; 329 | border:1px solid #DDDDDD; 330 | border-left:0px; 331 | border-right:0px; 332 | background:#F7F7F7; 333 | } 334 | .list_button_op{ 335 | padding:10px 24px; 336 | margin:0px auto; 337 | background:#EEEFF2; 338 | border-bottom:1px solid #DDDDDD; 339 | 340 | } 341 | 342 | 343 | .list_tips{ 344 | padding:10px 20px; 345 | margin:0px auto; 346 | text-align:left; 347 | font-size:12px; 348 | color:#8A6D3B; 349 | border:1px solid #FAEBCC; 350 | border-left:0px; 351 | border-right:0px; 352 | background:#FCF8E3; 353 | } 354 | .pages{ 355 | text-align:right; 356 | } 357 | 358 | .batch_ctl{ 359 | line-height:40px; 360 | margin-bottom:-40px; 361 | 362 | } 363 | 364 | .table_sort_none a{ 365 | display:inline-block; 366 | } 367 | .table_sort_desc a,.table_sort_asc a{ 368 | display:inline-block; 369 | position: relative; 370 | padding-right:10px; 371 | } 372 | .table_sort_desc a::after,.table_sort_asc a::after{ 373 | content:""; 374 | position:absolute; 375 | display:block; 376 | right:0; 377 | top:50%; 378 | margin-top:-2px; 379 | width:7px; 380 | height:4px; 381 | background-image:url(../table_sort.png); 382 | background-repeat:no-repeat; 383 | background-position:0 -5px; 384 | } 385 | 386 | .table_sort_asc a::after{ 387 | background-position:0 0; 388 | } 389 | 390 | 391 | -------------------------------------------------------------------------------- /src/main/resources/html/images/js/extract_dialog.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | set_select_all('#select_all', 'item_id'); 3 | 4 | $('.list_table').contextmenu(function (e) { 5 | var sel_text = window.getSelection().toString(); 6 | var menu=[ 7 | [ 8 | '下载字幕', 9 | function (dom) { 10 | down_last_tr_zimu(); 11 | } 12 | ], 13 | '|', 14 | [ 15 | '下载字幕(UTF-8 繁转简)', 16 | function (dom) { 17 | down_last_tr_zimu('UTF-8'); 18 | } 19 | ], 20 | [ 21 | '下载字幕(GBK 繁转简)', 22 | function (dom) { 23 | down_last_tr_zimu('GBK'); 24 | } 25 | ], 26 | [ 27 | '下载字幕(Big5 繁转简)', 28 | function (dom) { 29 | down_last_tr_zimu('Big5'); 30 | } 31 | ] 32 | ]; 33 | var title; 34 | if(typeof(last_list_table_tr) != 'undefined' && last_list_table_tr.length > 0){ 35 | title = last_list_table_tr.find('.title').text(); 36 | if(title){ 37 | title = title.trim(); 38 | if(title.length > 100){ 39 | title = title.substring(0,100); 40 | } 41 | menu.push('|'); 42 | menu.push([ 43 | '复制文字:'+title, 44 | function (dom) { 45 | app.copyClipboard(title); 46 | } 47 | ]); 48 | } 49 | } 50 | if(sel_text){ 51 | sel_text = sel_text.trim(); 52 | if(sel_text.length > 100){ 53 | sel_text = sel_text.substring(0,100); 54 | } 55 | if(title!=sel_text){ 56 | menu.push([ 57 | '复制文字:'+sel_text, 58 | function (dom) { 59 | app.copyClipboard(sel_text); 60 | } 61 | ]); 62 | } 63 | } 64 | ContextMenu.render(e,menu,this); //开始渲染 65 | }); 66 | $('.list_table').on('mouseenter','tr',function(){ 67 | window.last_list_table_tr = $(this); 68 | }); 69 | $('.list_table').on('click','.download',function(){ 70 | var btn = this; 71 | btn.disabled = true; 72 | var tr = $(this).parents('tr'); 73 | down_zimu(tr.find('input[name="item_id"]').val(), tr.find('select[name="item_simplified_charset"]').val()); 74 | window.setTimeout(function(){ 75 | btn.disabled = false; 76 | }, 300); 77 | }); 78 | 79 | $('#simplified_select_all').change(function(){ 80 | var checkbox = this; 81 | $('select[name="item_simplified_charset"]').each(function(){ 82 | console.log(checkbox.checked) 83 | if($(this).val() == '' && checkbox.checked){ 84 | $(this).val('UTF-8'); 85 | $(this).trigger('nf_change'); 86 | }else if(!checkbox.checked){ 87 | $(this).val(''); 88 | $(this).trigger('nf_change'); 89 | } 90 | }); 91 | }); 92 | 93 | $('#btn_download').on('click', function(){ 94 | var btn = this; 95 | btn.disabled = true; 96 | 97 | var items_ids = []; 98 | 99 | var item_simplified_charset = $('select[name="item_simplified_charset"]'); 100 | $('input[type="checkbox"][name="item_id"]').each(function(index){ 101 | var charset = item_simplified_charset.eq(index).val(); 102 | var title = $('.list_table .title').eq(index).attr('val'); 103 | if(this.checked){ 104 | items_ids.push({ 105 | id:this.value, 106 | filenameType:1, 107 | title:title, 108 | simplified:charset.length>0, 109 | charset:charset 110 | }); 111 | } 112 | }); 113 | if(items_ids.length == 0){ 114 | btn.disabled = false; 115 | my_alert('请选择字幕'); 116 | return; 117 | } 118 | 119 | var searchData = { 120 | items : items_ids 121 | }; 122 | ajax_jsonp('/extract_api/down_archive_file',{ 123 | data : json_encode(searchData) 124 | }, function (data){ 125 | btn.disabled = false; 126 | if(data.result > 0){ 127 | my_alert(data.message); 128 | return; 129 | } 130 | if(data == null){ 131 | my_alert('初始化数据失败'); 132 | return; 133 | } 134 | if(data.saveSelected){ 135 | my_tip('下载成功'); 136 | }else{ 137 | my_tip('下载失败'); 138 | } 139 | }); 140 | }); 141 | 142 | //window.serverPort = serverPort; 143 | window.serverUrl = "http://127.0.0.1:"+serverPort; 144 | laytpl_preload('#rec_list_tpl'); 145 | init_data(); 146 | }); 147 | 148 | function init_data(){ 149 | ajax_jsonp('/extract_api/get_init_data',{ 150 | 151 | }, function (data){ 152 | if(data.result > 0){ 153 | my_alert(data.message); 154 | return; 155 | } 156 | if(data == null){ 157 | my_alert('初始化数据失败'); 158 | return; 159 | } 160 | 161 | $('#search_box .con').html(data.title + '('+data.archiveExt+', '+data.archiveSizeF+')'); 162 | 163 | $('#status_label').html('压缩包里共有'+data.list.length+'个字幕文件'); 164 | $('#rec_list').empty(); 165 | laytpl_render('#rec_list_tpl', data, function(html){ 166 | $('#rec_list').append(html); 167 | $('#batch_from').newforms(); 168 | }); 169 | }); 170 | } 171 | //下载鼠标最后移动到的字幕 172 | function down_last_tr_zimu(charset){ 173 | if(typeof(last_list_table_tr) == 'undefined' || last_list_table_tr.length == 0){ 174 | my_alert('数据错误'); 175 | return; 176 | } 177 | down_zimu(last_list_table_tr.find('input[name="item_id"]').val(), charset); 178 | } 179 | //下载指定字幕 180 | function down_zimu(id, charset){ 181 | 182 | var items_ids = []; 183 | if(!charset){ 184 | charset = $('select[name="item_simplified_charset"]').eq(id).val(); 185 | } 186 | var title = $('.list_table .title').eq(id).attr('val'); 187 | items_ids.push({ 188 | id:id, 189 | filenameType:0, 190 | title:title, 191 | simplified:charset.length>0, 192 | charset:charset 193 | }); 194 | if(items_ids.length == 0){ 195 | my_alert('请选择字幕'); 196 | return; 197 | } 198 | 199 | var searchData = { 200 | items : items_ids 201 | }; 202 | ajax_jsonp('/extract_api/down_archive_file',{ 203 | data : json_encode(searchData) 204 | }, function (data){ 205 | if(data.result > 0){ 206 | my_alert(data.message); 207 | return; 208 | } 209 | if(data == null){ 210 | my_alert('初始化数据失败'); 211 | return; 212 | } 213 | if(data.saveSelected){ 214 | my_tip('下载成功'); 215 | }else{ 216 | my_tip('下载失败'); 217 | } 218 | }); 219 | } 220 | -------------------------------------------------------------------------------- /src/main/resources/html/images/js/layer/theme/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/layer/theme/default/icon-ext.png -------------------------------------------------------------------------------- /src/main/resources/html/images/js/layer/theme/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/layer/theme/default/icon.png -------------------------------------------------------------------------------- /src/main/resources/html/images/js/layer/theme/default/layer.css: -------------------------------------------------------------------------------- 1 | .layui-layer-imgbar,.layui-layer-imgtit a,.layui-layer-tab .layui-layer-title span,.layui-layer-title{text-overflow:ellipsis;white-space:nowrap}html #layuicss-layer{display:none;position:absolute;width:1989px}.layui-layer,.layui-layer-shade{position:fixed;_position:absolute;pointer-events:auto}.layui-layer-shade{top:0;left:0;width:100%;height:100%;_height:expression(document.body.offsetHeight+"px")}.layui-layer{-webkit-overflow-scrolling:touch;top:150px;left:0;margin:0;padding:0;background-color:#fff;-webkit-background-clip:content;border-radius:2px;box-shadow:1px 1px 50px rgba(0,0,0,.3)}.layui-layer-close{position:absolute}.layui-layer-content{position:relative}.layui-layer-border{border:1px solid #B2B2B2;border:1px solid rgba(0,0,0,.1);box-shadow:1px 1px 5px rgba(0,0,0,.2)}.layui-layer-load{background:url(loading-1.gif) center center no-repeat #eee}.layui-layer-ico{background:url(icon.png) no-repeat}.layui-layer-btn a,.layui-layer-dialog .layui-layer-ico,.layui-layer-setwin a{display:inline-block;*display:inline;*zoom:1;vertical-align:top}.layui-layer-move{display:none;position:fixed;*position:absolute;left:0;top:0;width:100%;height:100%;cursor:move;opacity:0;filter:alpha(opacity=0);background-color:#fff;z-index:2147483647}.layui-layer-resize{position:absolute;width:15px;height:15px;right:0;bottom:0;cursor:se-resize}.layer-anim{-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.3s;animation-duration:.3s}@-webkit-keyframes layer-bounceIn{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes layer-bounceIn{0%{opacity:0;-webkit-transform:scale(.5);-ms-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.layer-anim-00{-webkit-animation-name:layer-bounceIn;animation-name:layer-bounceIn}@-webkit-keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);-ms-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);-ms-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-01{-webkit-animation-name:layer-zoomInDown;animation-name:layer-zoomInDown}@-webkit-keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);-ms-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}.layer-anim-02{-webkit-animation-name:layer-fadeInUpBig;animation-name:layer-fadeInUpBig}@-webkit-keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);-ms-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);-ms-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-03{-webkit-animation-name:layer-zoomInLeft;animation-name:layer-zoomInLeft}@-webkit-keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0) rotate(0);transform:translateX(0) rotate(0)}}@keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);-ms-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0) rotate(0);-ms-transform:translateX(0) rotate(0);transform:translateX(0) rotate(0)}}.layer-anim-04{-webkit-animation-name:layer-rollIn;animation-name:layer-rollIn}@keyframes layer-fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:layer-fadeIn;animation-name:layer-fadeIn}@-webkit-keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);transform:translateX(10px)}}@keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);-ms-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);-ms-transform:translateX(10px);transform:translateX(10px)}}.layer-anim-06{-webkit-animation-name:layer-shake;animation-name:layer-shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}.layui-layer-title{padding:0 80px 0 20px;height:42px;line-height:42px;border-bottom:1px solid #eee;font-size:14px;color:#333;overflow:hidden;background-color:#F8F8F8;border-radius:2px 2px 0 0}.layui-layer-setwin{position:absolute;right:15px;*right:0;top:15px;font-size:0;line-height:initial}.layui-layer-setwin a{position:relative;width:16px;height:16px;margin-left:10px;font-size:12px;_overflow:hidden}.layui-layer-setwin .layui-layer-min cite{position:absolute;width:14px;height:2px;left:0;top:50%;margin-top:-1px;background-color:#2E2D3C;cursor:pointer;_overflow:hidden}.layui-layer-setwin .layui-layer-min:hover cite{background-color:#2D93CA}.layui-layer-setwin .layui-layer-max{background-position:-32px -40px}.layui-layer-setwin .layui-layer-max:hover{background-position:-16px -40px}.layui-layer-setwin .layui-layer-maxmin{background-position:-65px -40px}.layui-layer-setwin .layui-layer-maxmin:hover{background-position:-49px -40px}.layui-layer-setwin .layui-layer-close1{background-position:1px -40px;cursor:pointer}.layui-layer-setwin .layui-layer-close1:hover{opacity:.7}.layui-layer-setwin .layui-layer-close2{position:absolute;right:-28px;top:-28px;width:30px;height:30px;margin-left:0;background-position:-149px -31px;*right:-18px;_display:none}.layui-layer-setwin .layui-layer-close2:hover{background-position:-180px -31px}.layui-layer-btn{text-align:right;padding:0 15px 12px;pointer-events:auto;user-select:none;-webkit-user-select:none}.layui-layer-btn a{height:28px;line-height:28px;margin:5px 5px 0;padding:0 15px;border:1px solid #dedede;background-color:#fff;color:#333;border-radius:2px;font-weight:400;cursor:pointer;text-decoration:none}.layui-layer-btn a:hover{opacity:.9;text-decoration:none}.layui-layer-btn a:active{opacity:.8}.layui-layer-btn .layui-layer-btn0{border-color:#1E9FFF;background-color:#1E9FFF;color:#fff}.layui-layer-btn-l{text-align:left}.layui-layer-btn-c{text-align:center}.layui-layer-dialog{min-width:260px}.layui-layer-dialog .layui-layer-content{position:relative;padding:20px;line-height:24px;word-break:break-all;overflow:hidden;font-size:14px;overflow-x:hidden;overflow-y:auto}.layui-layer-dialog .layui-layer-content .layui-layer-ico{position:absolute;top:16px;left:15px;_left:-40px;width:30px;height:30px}.layui-layer-ico1{background-position:-30px 0}.layui-layer-ico2{background-position:-60px 0}.layui-layer-ico3{background-position:-90px 0}.layui-layer-ico4{background-position:-120px 0}.layui-layer-ico5{background-position:-150px 0}.layui-layer-ico6{background-position:-180px 0}.layui-layer-rim{border:6px solid #8D8D8D;border:6px solid rgba(0,0,0,.3);border-radius:5px;box-shadow:none}.layui-layer-msg{min-width:180px;border:1px solid #D3D4D3;box-shadow:none}.layui-layer-hui{min-width:100px;background-color:#000;filter:alpha(opacity=60);background-color:rgba(0,0,0,.6);color:#fff;border:none}.layui-layer-hui .layui-layer-content{padding:12px 25px;text-align:center}.layui-layer-dialog .layui-layer-padding{padding:20px 20px 20px 55px;text-align:left}.layui-layer-page .layui-layer-content{position:relative;overflow:auto}.layui-layer-iframe .layui-layer-btn,.layui-layer-page .layui-layer-btn{padding-top:10px}.layui-layer-nobg{background:0 0}.layui-layer-iframe iframe{display:block;width:100%}.layui-layer-loading{border-radius:100%;background:0 0;box-shadow:none;border:none}.layui-layer-loading .layui-layer-content{width:60px;height:24px;background:url(loading-0.gif) no-repeat}.layui-layer-loading .layui-layer-loading1{width:37px;height:37px;background:url(loading-1.gif) no-repeat}.layui-layer-ico16,.layui-layer-loading .layui-layer-loading2{width:32px;height:32px;background:url(loading-2.gif) no-repeat}.layui-layer-tips{background:0 0;box-shadow:none;border:none}.layui-layer-tips .layui-layer-content{position:relative;line-height:22px;min-width:12px;padding:8px 15px;font-size:12px;_float:left;border-radius:2px;box-shadow:1px 1px 3px rgba(0,0,0,.2);background-color:#000;color:#fff}.layui-layer-tips .layui-layer-close{right:-2px;top:-1px}.layui-layer-tips i.layui-layer-TipsG{position:absolute;width:0;height:0;border-width:8px;border-color:transparent;border-style:dashed;*overflow:hidden}.layui-layer-tips i.layui-layer-TipsB,.layui-layer-tips i.layui-layer-TipsT{left:5px;border-right-style:solid;border-right-color:#000}.layui-layer-tips i.layui-layer-TipsT{bottom:-8px}.layui-layer-tips i.layui-layer-TipsB{top:-8px}.layui-layer-tips i.layui-layer-TipsL,.layui-layer-tips i.layui-layer-TipsR{top:5px;border-bottom-style:solid;border-bottom-color:#000}.layui-layer-tips i.layui-layer-TipsR{left:-8px}.layui-layer-tips i.layui-layer-TipsL{right:-8px}.layui-layer-lan[type=dialog]{min-width:280px}.layui-layer-lan .layui-layer-title{background:#4476A7;color:#fff;border:none}.layui-layer-lan .layui-layer-btn{padding:5px 10px 10px;text-align:right;border-top:1px solid #E9E7E7}.layui-layer-lan .layui-layer-btn a{background:#fff;border-color:#E9E7E7;color:#333}.layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5}.layui-layer-molv .layui-layer-title{background:#009f95;color:#fff;border:none}.layui-layer-molv .layui-layer-btn a{background:#009f95;border-color:#009f95}.layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1}.layui-layer-iconext{background:url(icon-ext.png) no-repeat}.layui-layer-prompt .layui-layer-input{display:block;width:230px;height:36px;margin:0 auto;line-height:30px;padding-left:10px;border:1px solid #e6e6e6;color:#333}.layui-layer-prompt textarea.layui-layer-input{width:300px;height:100px;line-height:20px;padding:6px 10px}.layui-layer-prompt .layui-layer-content{padding:20px}.layui-layer-prompt .layui-layer-btn{padding-top:0}.layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4)}.layui-layer-tab .layui-layer-title{padding-left:0;overflow:visible}.layui-layer-tab .layui-layer-title span{position:relative;float:left;min-width:80px;max-width:260px;padding:0 20px;text-align:center;overflow:hidden;cursor:pointer}.layui-layer-tab .layui-layer-title span.layui-this{height:43px;border-left:1px solid #eee;border-right:1px solid #eee;background-color:#fff;z-index:10}.layui-layer-tab .layui-layer-title span:first-child{border-left:none}.layui-layer-tabmain{line-height:24px;clear:both}.layui-layer-tabmain .layui-layer-tabli{display:none}.layui-layer-tabmain .layui-layer-tabli.layui-this{display:block}.layui-layer-photos{-webkit-animation-duration:.8s;animation-duration:.8s}.layui-layer-photos .layui-layer-content{overflow:hidden;text-align:center}.layui-layer-photos .layui-layer-phimg img{position:relative;width:100%;display:inline-block;*display:inline;*zoom:1;vertical-align:top}.layui-layer-imgbar,.layui-layer-imguide{display:none}.layui-layer-imgnext,.layui-layer-imgprev{position:absolute;top:50%;width:27px;_width:44px;height:44px;margin-top:-22px;outline:0;blr:expression(this.onFocus=this.blur())}.layui-layer-imgprev{left:10px;background-position:-5px -5px;_background-position:-70px -5px}.layui-layer-imgprev:hover{background-position:-33px -5px;_background-position:-120px -5px}.layui-layer-imgnext{right:10px;_right:8px;background-position:-5px -50px;_background-position:-70px -50px}.layui-layer-imgnext:hover{background-position:-33px -50px;_background-position:-120px -50px}.layui-layer-imgbar{position:absolute;left:0;bottom:0;width:100%;height:32px;line-height:32px;background-color:rgba(0,0,0,.8);background-color:#000\9;filter:Alpha(opacity=80);color:#fff;overflow:hidden;font-size:0}.layui-layer-imgtit *{display:inline-block;*display:inline;*zoom:1;vertical-align:top;font-size:12px}.layui-layer-imgtit a{max-width:65%;overflow:hidden;color:#fff}.layui-layer-imgtit a:hover{color:#fff;text-decoration:underline}.layui-layer-imgtit em{padding-left:10px;font-style:normal}@-webkit-keyframes layer-bounceOut{100%{opacity:0;-webkit-transform:scale(.7);transform:scale(.7)}30%{-webkit-transform:scale(1.05);transform:scale(1.05)}0%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes layer-bounceOut{100%{opacity:0;-webkit-transform:scale(.7);-ms-transform:scale(.7);transform:scale(.7)}30%{-webkit-transform:scale(1.05);-ms-transform:scale(1.05);transform:scale(1.05)}0%{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.layer-anim-close{-webkit-animation-name:layer-bounceOut;animation-name:layer-bounceOut;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.2s;animation-duration:.2s}@media screen and (max-width:1100px){.layui-layer-iframe{overflow-y:auto;-webkit-overflow-scrolling:touch}} -------------------------------------------------------------------------------- /src/main/resources/html/images/js/layer/theme/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/layer/theme/default/loading-0.gif -------------------------------------------------------------------------------- /src/main/resources/html/images/js/layer/theme/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/layer/theme/default/loading-1.gif -------------------------------------------------------------------------------- /src/main/resources/html/images/js/layer/theme/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/layer/theme/default/loading-2.gif -------------------------------------------------------------------------------- /src/main/resources/html/images/js/main.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | $(window).resize(function(){ 3 | $('#list_body').height($(window).height() - $('#search_box').height() - $('#list_footer').height()); 4 | }).resize(); 5 | if(document.search_from){ 6 | $('#search_from').newforms(); 7 | $('#batch_from').newforms(); 8 | } 9 | 10 | 11 | 12 | }); 13 | window.app = { 14 | about : function(){ 15 | if(!this.inApp())return; 16 | javaApp.about(); 17 | //javaApp.alert('test'); 18 | }, 19 | getInitData : function(){ 20 | if(!this.inApp())return null; 21 | return javaApp.getInitData(); 22 | }, 23 | openMovFile : function(){ 24 | if(!this.inApp())return false; 25 | return javaApp.openMovFile(); 26 | }, 27 | copyClipboard : function(str){ 28 | if(!this.inApp())return false; 29 | return javaApp.copyClipboard(str); 30 | }, 31 | inApp : function(){ 32 | return (typeof(javaApp)=='object' && typeof(javaApp.test) == 'function') 33 | } 34 | }; 35 | 36 | function json_encode(data){ 37 | return JSON.stringify(data); 38 | } 39 | function json_decode(data){ 40 | ////data = $.parseJSON(data); 41 | return JSON.parse(data); 42 | } 43 | 44 | function ajax_jsonp(url, data, succ_fun, fail_fun){ 45 | my_loading_show(); 46 | $.ajax({ 47 | type : "POST", 48 | url : serverUrl+url, 49 | data : data, 50 | dataType : "jsonp", 51 | success : function(data) { 52 | my_loading_hide(); 53 | succ_fun && succ_fun(data); 54 | }, 55 | error : function(XMLHttpRequest, textStatus, errorThrown) { 56 | my_loading_hide(); 57 | if(fail_fun){ 58 | fail_fun(XMLHttpRequest, textStatus, errorThrown); 59 | }else{ 60 | my_alert('网络异常'); 61 | } 62 | } 63 | }); 64 | } 65 | 66 | /** 67 | 设置列表批量选择框 68 | */ 69 | function set_select_all(id, bat_name){ 70 | $(id).change(function (){ 71 | var _this = this; 72 | $('input[name="'+bat_name+'"]').each(function (){ 73 | this.checked = _this.checked; 74 | if(this.checked){ 75 | $(this).attr('checked', 'checked'); 76 | $(this).prop("checked"); 77 | }else{ 78 | $(this).removeAttr('checked'); 79 | $(this).removeProp("checked"); 80 | } 81 | 82 | $(this).trigger('nf_change'); 83 | }) 84 | }); 85 | $(document).on('change', 'input[name="'+bat_name+'"]', function (){ 86 | var _this = this; 87 | var bat_list = $('input[name="'+bat_name+'"]'); 88 | ///console.log($('.list_table').html()) 89 | //console.log(bat_list.filter('[checked]').length+","+bat_list.length) 90 | if(bat_list.filter('[checked]').length == bat_list.length){ 91 | $(id).get(0).checked = true; 92 | $(id).trigger('nf_change'); 93 | }else{ 94 | $(id).get(0).checked = false; 95 | $(id).trigger('nf_change'); 96 | } 97 | }); 98 | } 99 | -------------------------------------------------------------------------------- /src/main/resources/html/images/js/mainwin.js: -------------------------------------------------------------------------------- 1 | //alert(navigator.userAgent); 2 | $(function(){ 3 | set_select_all('#select_all', 'item_id'); 4 | 5 | $('.list_table').contextmenu(function (e) { 6 | var sel_text = window.getSelection().toString(); 7 | var menu=[ 8 | [ 9 | '下载字幕', 10 | function (dom) { 11 | down_last_tr_zimu(); 12 | } 13 | ], 14 | '|', 15 | [ 16 | '下载字幕(UTF-8 繁转简)', 17 | function (dom) { 18 | down_last_tr_zimu('UTF-8'); 19 | } 20 | ], 21 | [ 22 | '下载字幕(GBK 繁转简)', 23 | function (dom) { 24 | down_last_tr_zimu('GBK'); 25 | } 26 | ], 27 | [ 28 | '下载字幕(Big5 繁转简)', 29 | function (dom) { 30 | down_last_tr_zimu('Big5'); 31 | } 32 | ] 33 | ]; 34 | if(typeof(last_list_table_tr) == 'undefined' || last_list_table_tr.find('.download[url]').length>0){ 35 | menu = []; 36 | } 37 | var title; 38 | if(typeof(last_list_table_tr) != 'undefined' && last_list_table_tr.length > 0){ 39 | title = last_list_table_tr.find('.title').text(); 40 | if(title){ 41 | title = title.trim(); 42 | if(title.length > 100){ 43 | title = title.substring(0,100); 44 | } 45 | if(menu.length>0)menu.push('|'); 46 | menu.push([ 47 | '复制文字:'+title, 48 | function (dom) { 49 | app.copyClipboard(title); 50 | } 51 | ]); 52 | } 53 | } 54 | if(sel_text){ 55 | sel_text = sel_text.trim(); 56 | if(sel_text.length > 100){ 57 | sel_text = sel_text.substring(0,100); 58 | } 59 | if(title!=sel_text){ 60 | menu.push([ 61 | '复制文字:'+sel_text, 62 | function (dom) { 63 | app.copyClipboard(sel_text); 64 | } 65 | ]); 66 | } 67 | } 68 | if(menu.length==0){ 69 | return; 70 | } 71 | ContextMenu.render(e,menu,this); //开始渲染 72 | }); 73 | $('.list_table').on('mouseenter','tr',function(){ 74 | window.last_list_table_tr = $(this); 75 | }); 76 | $('.list_table').on('click','.download',function(){ 77 | var tr = $(this).parents('tr'); 78 | 79 | if($(this).attr('url')){ 80 | ajax_jsonp('/api/open_url',{ 81 | url : $(this).attr('url') 82 | }, function (data){ 83 | if(data.result > 0){ 84 | my_alert(data.message); 85 | return; 86 | } 87 | 88 | }); 89 | return; 90 | } 91 | down_zimu(tr.find('input[name="item_id"]').val(), tr.find('select[name="item_simplified_charset"]').val()); 92 | }); 93 | 94 | $('#btn_about').on('click', function(){ 95 | app.about(); 96 | }); 97 | 98 | 99 | $('#simplified_select_all').change(function(){ 100 | var checkbox = this; 101 | $('select[name="item_simplified_charset"]').each(function(){ 102 | console.log(checkbox.checked) 103 | if($(this).val() == '' && checkbox.checked){ 104 | $(this).val('UTF-8'); 105 | $(this).trigger('nf_change'); 106 | }else if(!checkbox.checked){ 107 | $(this).val(''); 108 | $(this).trigger('nf_change'); 109 | } 110 | }); 111 | }); 112 | $('#btn_sel_file').on('click', function(){ 113 | var _this = this; 114 | this.disabled = true; 115 | if(app.openMovFile()){ 116 | init_data_fileinfo(); 117 | search_start_thread(); 118 | } 119 | window.setTimeout(function(){ 120 | _this.disabled = false; 121 | }, 300); 122 | }); 123 | $('#btn_search').on('click', function(){ 124 | var _this = this; 125 | this.disabled = true; 126 | search_start_thread(true); 127 | window.setTimeout(function(){ 128 | _this.disabled = false; 129 | }, 300); 130 | }); 131 | $('#btn_download').on('click', function(){ 132 | var _this = this; 133 | this.disabled = true; 134 | 135 | var items_ids = []; 136 | 137 | var item_simplified_charset = $('select[name="item_simplified_charset"]'); 138 | $('input[type="checkbox"][name="item_id"]').each(function(index){ 139 | var charset = item_simplified_charset.eq(index).val(); 140 | if(this.checked){ 141 | items_ids.push({ 142 | id:this.value, 143 | filenameType:1, 144 | simplified:charset.length>0, 145 | charset:charset 146 | }); 147 | } 148 | }); 149 | if(items_ids.length == 0){ 150 | my_alert('请选择字幕'); 151 | return; 152 | } 153 | 154 | var searchData = { 155 | items : items_ids 156 | }; 157 | ajax_jsonp('/api/zimu_down',{ 158 | data : json_encode(searchData) 159 | }, function (data){ 160 | if(data.result > 0){ 161 | my_alert(data.message); 162 | return; 163 | } 164 | my_tip('下载完成'); 165 | }); 166 | 167 | window.setTimeout(function(){ 168 | _this.disabled = false; 169 | }, 300); 170 | }); 171 | 172 | laytpl_preload('#rec_list_tpl'); 173 | init_data(); 174 | search_start_thread(); 175 | }); 176 | //下载鼠标最后移动到的字幕 177 | function down_last_tr_zimu(charset){ 178 | if(typeof(last_list_table_tr) == 'undefined' || last_list_table_tr.length == 0){ 179 | my_alert('数据错误'); 180 | return; 181 | } 182 | down_zimu(last_list_table_tr.find('input[name="item_id"]').val(), charset); 183 | } 184 | //下载指定字幕 185 | function down_zimu(id, charset){ 186 | var items_ids = []; 187 | if(!charset){ 188 | charset = $('select[name="item_simplified_charset"]').eq(id).val(); 189 | } 190 | items_ids.push({ 191 | id:id, 192 | filenameType:0, 193 | simplified:charset.length>0, 194 | charset:charset 195 | }); 196 | if(items_ids.length == 0){ 197 | my_alert('请选择字幕'); 198 | return; 199 | } 200 | 201 | var searchData = { 202 | items : items_ids 203 | }; 204 | ajax_jsonp('/api/zimu_down',{ 205 | data : json_encode(searchData) 206 | }, function (data){ 207 | if(data.result > 0){ 208 | my_alert(data.message); 209 | return; 210 | } 211 | my_tip('下载完成'); 212 | }); 213 | } 214 | //java调用 215 | function page_callback(){ 216 | init_data_fileinfo(); 217 | search_start_thread(); 218 | return true; 219 | } 220 | function search_start_thread(is_click){ 221 | window.setTimeout(function(){ 222 | search_start(is_click); 223 | }, 100); 224 | } 225 | //开始搜索 226 | function search_start(is_click){ 227 | if($('input[name="filename"]').val().length == 0){ 228 | if(is_click){ 229 | my_alert('请选择视频文件'); 230 | } 231 | return; 232 | } 233 | 234 | var searchParm = {}; 235 | var form_count = 0; 236 | $('input[name="froms"]').each(function(){ 237 | var val = $(this).attr('value'); 238 | searchParm['from_'+val] = this.checked; 239 | if(this.checked){ 240 | form_count++; 241 | } 242 | }); 243 | if(form_count == 0){ 244 | my_loading_hide(); 245 | if(is_click){ 246 | my_alert('请选择至少1个字幕数据源'); 247 | } 248 | return; 249 | } 250 | 251 | var items = []; 252 | 253 | var searchData = { 254 | searchParm : searchParm, 255 | items : items 256 | }; 257 | var time1 = (new Date()).getTime(); 258 | ajax_jsonp('/api/zimu_list',{ 259 | data : json_encode(searchData) 260 | }, function (data){ 261 | if(data.result > 0){ 262 | my_alert(data.message); 263 | return; 264 | } 265 | var data = { 266 | list : data.list 267 | }; 268 | var useTime = (((new Date()).getTime() - time1)/1000).toFixed(2); 269 | $('#status_label').html('查询到'+data.list.length+'个字幕数据,共耗时:'+(useTime)+'秒'); 270 | $('#rec_list').empty(); 271 | laytpl_render('#rec_list_tpl', data, function(html){ 272 | $('#rec_list').append(html); 273 | $('#batch_from').newforms(); 274 | }); 275 | }); 276 | 277 | //var dataStr = app.searchList(json_encode(searchData)); 278 | 279 | 280 | 281 | } 282 | function init_data(){ 283 | my_loading_show(); 284 | var data = app.getInitData(); 285 | if(data == null){ 286 | my_alert('初始化数据失败'); 287 | return; 288 | } 289 | 290 | 291 | data = json_decode(data); 292 | 293 | if(data.fileinfo && data.fileinfo.movFilename){ 294 | $('input[name="filename"]').val(data.fileinfo.movFilename); 295 | } 296 | if(data.searchParm){ 297 | var froms = ["sheshou", "xunlei", "zimuku", "subhd"]; 298 | for(var i in froms){ 299 | if(data.searchParm['from_'+froms[i]]){ 300 | $('input[name="froms"][value="'+froms[i]+'"]')[0].checked = true; 301 | $('input[name="froms"][value="'+froms[i]+'"]').trigger('nf_change'); 302 | } 303 | } 304 | } 305 | window.serverPort = data.serverPort; 306 | window.serverUrl = "http://127.0.0.1:"+serverPort; 307 | 308 | my_loading_hide(); 309 | } 310 | function init_data_fileinfo(){ 311 | my_loading_show(); 312 | var data = app.getInitData(); 313 | if(data == null){ 314 | my_alert('初始化数据失败'); 315 | return; 316 | } 317 | 318 | 319 | data = json_decode(data); 320 | 321 | if(data.fileinfo && data.fileinfo.movFilename){ 322 | $('input[name="filename"]').val(data.fileinfo.movFilename); 323 | } 324 | my_loading_hide(); 325 | } 326 | 327 | -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/ContextMenu/contextMenu.css: -------------------------------------------------------------------------------- 1 | .yuri2-context-menu { 2 | left: 0; 3 | top: 0; 4 | position: fixed; 5 | height: auto; 6 | background-color: rgb(61, 61, 61); 7 | display: block; 8 | /*border-radius: 5px;*/ 9 | z-index: 99999999; 10 | color: white; 11 | /*overflow: hidden;*/ 12 | } 13 | 14 | .yuri2-context-menu.sub { 15 | left: 98%; 16 | position: absolute; 17 | display: none; 18 | } 19 | 20 | .yuri2-context-menu.sub.left { 21 | left: auto; 22 | right: 98%; 23 | } 24 | 25 | .yuri2-context-menu ul li:hover .yuri2-context-menu.sub { 26 | display: block; 27 | } 28 | 29 | .yuri2-context-menu ul.left .yuri2-context-menu.sub { 30 | left: -100%; 31 | } 32 | 33 | .yuri2-context-menu ul { 34 | margin: 0px; 35 | padding: 0px; 36 | box-shadow: 0 0 16px rgba(0, 0, 0, 0.54); 37 | } 38 | 39 | .yuri2-context-menu ul li { 40 | cursor: default; 41 | padding: 0px 1em; 42 | list-style: none; 43 | line-height: 30px; 44 | height: 30px; 45 | font-size: 12px; 46 | /*overflow: hidden;*/ 47 | position: relative; 48 | } 49 | 50 | .yuri2-context-menu ul li div.title { 51 | overflow: hidden; 52 | height: 100%; 53 | float: left; 54 | word-break: break-all; 55 | } 56 | 57 | .yuri2-context-menu ul li div.title.disable { 58 | color: darkgrey; 59 | } 60 | 61 | .yuri2-context-menu ul li.sub:after { 62 | content: ">"; 63 | float: right; 64 | transform: scale3d(0.5, 1.5, 1); 65 | position: relative; 66 | } 67 | 68 | .yuri2-context-menu ul li:hover { 69 | background-color: #636363; 70 | } 71 | 72 | .yuri2-context-menu ul li a { 73 | text-decoration: none; 74 | display: block; 75 | height: 100%; 76 | color: #333; 77 | outline: none; 78 | } 79 | 80 | .yuri2-context-menu ul hr { 81 | margin: 0; 82 | height: 0; 83 | border: 0; 84 | border-bottom: rgba(132, 132, 132, 0.47) 1px solid; 85 | border-top: none 86 | } 87 | 88 | /*浅色主题*/ 89 | .yuri2-context-menu.light { 90 | background-color: #e0e0e0; 91 | border-color: #535353; 92 | color: #333333; 93 | } 94 | 95 | .yuri2-context-menu.light ul li:hover { 96 | background-color: #707070; 97 | color: #ffffff; 98 | } 99 | 100 | .yuri2-context-menu.light ul hr { 101 | border-color: #535353; 102 | } -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/ContextMenu/contextMenu.js: -------------------------------------------------------------------------------- 1 | /** 2 | * contextMenu v2.2.4 3 | * 4 | * @author Yuri2(yuri2peter@qq.com) 5 | * @link https://github.com/yuri2peter/contextMenu Enjoy! (●'◡'●) 基于jq的右键菜单(动态绑定) 6 | * @author Yuri2 7 | */ 8 | window.ContextMenu = { 9 | _className : 'yuri2-context-menu', 10 | _stopProp : function(e) { 11 | if (e.cancelable) { 12 | // 判断默认行为是否已经被禁用 13 | if (!e.defaultPrevented) { 14 | e.preventDefault(); 15 | } 16 | } 17 | e.stopImmediatePropagation(); 18 | e.stopPropagation(); 19 | }, 20 | _getMainContent : function(text) { 21 | return text.replace(/<\/?.+?>/g, ""); 22 | }, 23 | render : function(e, menu, trigger, theme) { 24 | theme || (theme = ''); 25 | var x = e.clientX, y = e.clientY; 26 | this._stopProp(e); 27 | this._removeContextMenu(); 28 | if (menu === true) { 29 | return; 30 | } 31 | if (typeof menu === 'object' && menu.length === 0) { 32 | menu = [ [ '...' ] ] 33 | } 34 | var dom = $("
    "); 35 | $('body').append(dom); 36 | var ul = dom.find('ul'); 37 | if (x + 150 > document.body.clientWidth) { 38 | x -= 150; 39 | ul.addClass('left') 40 | } 41 | menu.forEach(function(item) { 42 | if (item === '|') { 43 | ul.append($('
    ')); 44 | } else if (typeof (item) === 'string') { 45 | ul.append($('
  • ' + item + '
  • ')); 46 | } else if (typeof (item) === 'object') { 47 | var sub = $('
  • ' + item[0] + '
  • '); 48 | ul.append(sub); 49 | if (typeof (item[1]) === 'object') { 50 | var subMenu = $("
    \
    "); 51 | var subUl = $("
      "); 52 | sub.addClass('sub'); 53 | subMenu.append(subUl); 54 | if (x + 300 > document.body.clientWidth) { 55 | subMenu.addClass('left') 56 | } 57 | sub.append(subMenu); 58 | var counterForTop = -1; 59 | item[1].forEach(function(t) { 60 | if (t === '|') { 61 | subUl.append($('
      ')); 62 | } else if (typeof (t) === 'string') { 63 | subUl.append($('
    • ' + t + '
    • ')); 64 | counterForTop++; 65 | } else if (typeof (t) === 'object') { 66 | var subLi = $('
    • ' + t[0] 67 | + '
    • '); 68 | subUl.append(subLi); 69 | if (t[2] !== true) { 70 | subLi.click(trigger, t[1]); 71 | subLi.click(function() { 72 | ContextMenu._removeContextMenu(); 73 | }); 74 | } 75 | counterForTop++; 76 | } 77 | }); 78 | if (y + dom.height() > document.body.clientHeight && document.body.clientHeight > 0) { 79 | subMenu.css('top', '-' + (counterForTop * 30) + 'px') 80 | } 81 | } else if (typeof (item[1]) === 'function' && item[2] !== true) { 82 | sub.click(trigger, item[1]); 83 | sub.click(function() { 84 | ContextMenu._removeContextMenu(); 85 | }); 86 | } 87 | } 88 | }); 89 | // 修正坐标 90 | if (y + dom.height() > document.body.clientHeight && document.body.clientHeight > 0) { 91 | y -= dom.height() 92 | } 93 | dom.css({ 94 | top : y, 95 | left : x, 96 | }); 97 | }, 98 | _removeContextMenu : function() { 99 | $('.' + ContextMenu._className).remove(); 100 | }, 101 | }; 102 | 103 | $(document).click(function(e) { 104 | if ($(e.target).hasClass(ContextMenu._className) || $(e.target).parents('.' + ContextMenu._className).length > 0) 105 | return; 106 | ContextMenu._removeContextMenu(); 107 | }); -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/newforms/skins/default/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/plugins/newforms/skins/default/checkbox.png -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/newforms/skins/default/date-trigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/plugins/newforms/skins/default/date-trigger.png -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/newforms/skins/default/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/plugins/newforms/skins/default/radio.png -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/newforms/skins/default/spinner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/plugins/newforms/skins/default/spinner.png -------------------------------------------------------------------------------- /src/main/resources/html/images/js/plugins/newforms/skins/default/trigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/html/images/js/plugins/newforms/skins/default/trigger.png -------------------------------------------------------------------------------- /src/main/resources/html/mainwin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | SubTitleSearcher 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 63 | 96 |
      97 |
      98 | 99 | 100 | 144 | 145 |
      146 |
      147 | 163 |
      164 | 165 | 166 | -------------------------------------------------------------------------------- /src/main/resources/res/icon/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/res/icon/app.ico -------------------------------------------------------------------------------- /src/main/resources/res/icon/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/res/icon/app.png -------------------------------------------------------------------------------- /src/main/resources/res/img/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/res/img/about.png -------------------------------------------------------------------------------- /src/main/resources/res/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andyfoo/SubTitleSearcher/a0c1c99d5c38c6878dd2a486228bc13804a431a8/src/main/resources/res/img/loading.gif --------------------------------------------------------------------------------