diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 58eecea..4f85971 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -3,7 +3,7 @@ Please make sure these boxes are checked before submitting your issue – thank - [ ] You can actually watch the video in your browser, but not download them with `GUI-YouGet`. - [ ] Your `GUI-YouGet` is up-to-date. - [ ] Your downloading core is up-to-date. -Please paste the full `log/debug.log` inside the fences: +Please paste the full `app/log/debug.log` inside the fences: ``` [PASTE IN ME] @@ -18,7 +18,7 @@ If there's anything else you would like to say(e.g some new features) fill in th - [ ] 您的`GUI-YouGet`为最新版。 - [ ] 您的下载引擎为最新版。 -请将`log/debug.log`文件内容粘贴在下面: +请将`app/log/debug.log`文件内容粘贴在下面: ``` [在这里粘贴完整日志] diff --git a/.gitignore b/.gitignore index dd45b37..c154b4d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,11 @@ .idea/ build/ out/ -app.properties +/app.properties conf/ gradle/ gradlew gradlew.bat log/ +/engine/ +GUI-YouGet.iml diff --git a/README.md b/README.md index 7c227eb..f3706f3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # GUI-YouGet -![](https://img.shields.io/badge/v0.2.1-pass-green.svg) +![](https://img.shields.io/badge/v0.2.2-pass-green.svg) ![](https://img.shields.io/github/forks/ingbyr/GUI-YouGet.svg) ![](https://img.shields.io/github/stars/ingbyr/GUI-YouGet.svg) ![](https://img.shields.io/badge/license-MIT-blue.svg) @@ -8,18 +8,16 @@ > [中文说明](http://www.ingbyr.com/2016/06/18/youget-zh/) # Download -> **NOTICE:** Before you run the GUI-YouGet, you need to install [jre8 ](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)(recommended) or [jdk8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) first. +[Download Page](https://github.com/ingbyr/GUI-YouGet/releases) -[GUI-YouGet Download Page](https://github.com/ingbyr/GUI-YouGet/releases) - -# Screenshot -![](screenshot/main.png) -![](screenshot/medias.png) -![](screenshot/download.png) +# Screenshots +![](screenshots/main.png) +![](screenshots/medias.png) +![](screenshots/download.png) # Feedback bugs If something is broken and `GUI-YouGet` can't get you things you want, don't panic. (Yes, this happens all the time!) -Open a new issue on [GitHub](https://github.com/ingbyr/GUI-YouGet/issues), with detailed `/log/debug.log` output attached. +Open a new issue on [GitHub](https://github.com/ingbyr/GUI-YouGet/issues), with detailed `app/log/debug.log` output attached. # Legal Issues diff --git a/RemoteConf.json b/RemoteConf.json deleted file mode 100644 index 9e14337..0000000 --- a/RemoteConf.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "youget": "https://raw.githubusercontent.com/soimort/you-get/master/src/you_get/version.py", - "youtubedl": "https://raw.githubusercontent.com/rg3/youtube-dl/master/youtube_dl/version.py", - "app-version": "0.2" -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index c51ec0a..ffa1998 100644 --- a/build.gradle +++ b/build.gradle @@ -1,47 +1,58 @@ -group 'com.ingbyr.guiyouget' -version '0.2.1' +group "com.ingbyr.guiyouget" +version "0.2.2" buildscript { - ext.kotlin_version = '1.1.60' + ext.kotlin_version = "1.2.20" repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath group: "de.dynamicfiles.projects.gradle.plugins", name: "javafx-gradle-plugin", version: "8.8.2" } } -apply plugin: 'kotlin' - -jar { - manifest { - attributes('Main-Class': 'com.ingbyr.guiyouget.MainKt') - } - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } -} - +apply plugin: "kotlin" +apply plugin: "javafx-gradle-plugin" sourceCompatibility = 1.8 - repositories { - mavenCentral() jcenter() + mavenCentral() } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" - compile 'no.tornado:tornadofx:1.7.10' - compile 'com.jfoenix:jfoenix:1.4.0' - compile 'com.beust:klaxon:0.30' - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - compile 'com.squareup.okhttp3:okhttp:3.9.0' + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "no.tornado:tornadofx:1.7.14" + compile "com.jfoenix:jfoenix:1.11.1" + compile "com.beust:klaxon:0.30" + compile group: "ch.qos.logback", name: "logback-classic", version: "1.2.3" + compile "com.github.kittinunf.fuel:fuel:1.12.0" } compileKotlin { kotlinOptions.jvmTarget = "1.8" } + compileTestKotlin { kotlinOptions.jvmTarget = "1.8" +} + +jfx { + verbose = false + mainClass = "com.ingbyr.guiyouget.MainKt" + jfxMainAppJarName="GUI-YouGet.jar" + vendor = "ingbyr" + appName = "GUI-YouGet" + additionalAppResources = "src/main/deploy" + skipMainClassScanning = true + jvmProperties = ["-Dfile.encoding": "UTF-8"] + nativeReleaseVersion = "0.2.2" + bundler = 'exe' + needShortcut = true + bundleArguments = [ + installdirChooser: 'true' + ] } \ No newline at end of file diff --git a/core/you-get.exe.REMOVED.git-id b/core/you-get.exe.REMOVED.git-id deleted file mode 100644 index 068b792..0000000 --- a/core/you-get.exe.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -9d07f237555a7dddb6622e6c333b497cd3541719 \ No newline at end of file diff --git a/core/youtube-dl.exe.REMOVED.git-id b/core/youtube-dl.exe.REMOVED.git-id deleted file mode 100644 index 264e3bc..0000000 --- a/core/youtube-dl.exe.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -a00eb4f12a25036a1d2ab772654032a4579944d4 \ No newline at end of file diff --git a/screenshot/download.png b/screenshots/download.png similarity index 100% rename from screenshot/download.png rename to screenshots/download.png diff --git a/screenshot/main.png b/screenshots/main.png similarity index 100% rename from screenshot/main.png rename to screenshots/main.png diff --git a/screenshot/medias.png b/screenshots/medias.png similarity index 100% rename from screenshot/medias.png rename to screenshots/medias.png diff --git a/src/main/deploy/app.properties b/src/main/deploy/app.properties new file mode 100644 index 0000000..7a98cfc --- /dev/null +++ b/src/main/deploy/app.properties @@ -0,0 +1,8 @@ +version=0.2.2 +you-get-version=0.4.985 +youtube-dl-version=2018.01.18 +proxy-port= +proxy-type= +proxy-address= +storage-path= +download-core=youtube-dl \ No newline at end of file diff --git a/src/main/deploy/engine/you-get.exe.REMOVED.git-id b/src/main/deploy/engine/you-get.exe.REMOVED.git-id new file mode 100644 index 0000000..e5b28da --- /dev/null +++ b/src/main/deploy/engine/you-get.exe.REMOVED.git-id @@ -0,0 +1 @@ +29ec6541f4f140bea844df64d7c5b87a28a66400 \ No newline at end of file diff --git a/src/main/deploy/engine/youtube-dl.exe.REMOVED.git-id b/src/main/deploy/engine/youtube-dl.exe.REMOVED.git-id new file mode 100644 index 0000000..074d709 --- /dev/null +++ b/src/main/deploy/engine/youtube-dl.exe.REMOVED.git-id @@ -0,0 +1 @@ +9ae2ad2118e26dd1df2aab680f5ed6b7ebf6c1e7 \ No newline at end of file diff --git a/src/main/deploy/package/windows/GUI-YouGet-setup-icon.bmp b/src/main/deploy/package/windows/GUI-YouGet-setup-icon.bmp new file mode 100644 index 0000000..5b35c33 Binary files /dev/null and b/src/main/deploy/package/windows/GUI-YouGet-setup-icon.bmp differ diff --git a/src/main/deploy/package/windows/GUI-YouGet.ico b/src/main/deploy/package/windows/GUI-YouGet.ico new file mode 100644 index 0000000..cb5265a Binary files /dev/null and b/src/main/deploy/package/windows/GUI-YouGet.ico differ diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt index 100ccbd..1b373d6 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt @@ -1,10 +1,10 @@ package com.ingbyr.guiyouget.controllers -import com.ingbyr.guiyouget.core.YouGet -import com.ingbyr.guiyouget.core.YoutubeDL +import com.ingbyr.guiyouget.engine.YouGet +import com.ingbyr.guiyouget.engine.YoutubeDL import com.ingbyr.guiyouget.events.RequestMediasWithYouGet import com.ingbyr.guiyouget.events.RequestMediasWithYoutubeDL -import com.ingbyr.guiyouget.utils.CoreUtils +import com.ingbyr.guiyouget.utils.ContentsUtil import org.slf4j.Logger import org.slf4j.LoggerFactory import tornadofx.* @@ -14,21 +14,21 @@ class MainController : Controller() { private val logger: Logger = LoggerFactory.getLogger(MainController::class.java) fun requestMediaInfo(url: String) { - val core = app.config[CoreUtils.DOWNLOAD_CORE] - logger.debug("download core is $core") + val core = app.config[ContentsUtil.DOWNLOAD_CORE] + logger.debug("download engine is $core") // Init the request args when (core) { - CoreUtils.YOUTUBE_DL -> { + ContentsUtil.YOUTUBE_DL -> { fire(RequestMediasWithYoutubeDL(YoutubeDL(url))) } - CoreUtils.YOU_GET -> { + ContentsUtil.YOU_GET -> { fire(RequestMediasWithYouGet(YouGet(url))) } else -> { - logger.error("bad downloading core $core") + logger.error("bad downloading engine $core") } } @@ -36,6 +36,6 @@ class MainController : Controller() { fun updateGUI() { - hostServices.showDocument(CoreUtils.APP_UPDATE_URL) + hostServices.showDocument(ContentsUtil.APP_UPDATE_URL) } } \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/MediaListController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/MediaListController.kt index 45e87e4..b190c9a 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/MediaListController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/MediaListController.kt @@ -31,8 +31,7 @@ class MediaListController : Controller() { } catch (e: Exception) { logger.error(e.toString()) fire(DisplayMediasWithYoutubeDL(JsonObject(mapOf( - "title" to messages["getInfoFailed"], - "description" to messages["getInfoFailedDes"])))) + "title" to messages["failed"])))) } } @@ -42,7 +41,7 @@ class MediaListController : Controller() { fire(DisplayMediasWithYouGet(json)) } catch (e: Exception) { logger.error(e.toString()) - fire(DisplayMediasWithYouGet(JsonObject(mapOf("title" to messages["getInfoFailed"])))) + fire(DisplayMediasWithYouGet(JsonObject(mapOf("title" to messages["failed"])))) } } } diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt index f51ec42..35fb5d9 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt @@ -1,7 +1,7 @@ package com.ingbyr.guiyouget.controllers -import com.ingbyr.guiyouget.core.YouGet -import com.ingbyr.guiyouget.core.YoutubeDL +import com.ingbyr.guiyouget.engine.YouGet +import com.ingbyr.guiyouget.engine.YoutubeDL import com.ingbyr.guiyouget.events.DownloadingRequestWithYouGet import com.ingbyr.guiyouget.events.DownloadingRequestWithYoutubeDL import com.ingbyr.guiyouget.events.ResumeDownloading diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt index 8b3f2e6..e851fb2 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt @@ -1,88 +1,132 @@ package com.ingbyr.guiyouget.controllers -import com.ingbyr.guiyouget.core.OkHttpController -import com.ingbyr.guiyouget.events.* -import com.ingbyr.guiyouget.utils.CoreUtils +import com.github.kittinunf.fuel.Fuel +import com.github.kittinunf.result.Result +import com.ingbyr.guiyouget.events.RequestCheckUpdatesYouGet +import com.ingbyr.guiyouget.events.RequestCheckUpdatesYoutubeDL +import com.ingbyr.guiyouget.events.UpdateYouGetStates +import com.ingbyr.guiyouget.events.UpdateYoutubeDLStates +import com.ingbyr.guiyouget.utils.ContentsUtil import org.slf4j.LoggerFactory import tornadofx.* import java.nio.file.Paths import java.util.* + class UpdatesController : Controller() { init { messages = ResourceBundle.getBundle("i18n/UpdatesView") } private val logger = LoggerFactory.getLogger(this::class.java) - private val okhttp = OkHttpController() fun subscribeEvents() { + subscribe { fire(UpdateYouGetStates(messages["checkForUpdates"])) - val remoteJson = okhttp.requestJson(CoreUtils.REMOTE_CONF_URL) - if (remoteJson != null) { - val youget = remoteJson["youget"] as String - logger.debug("[you-get] remote version url $youget") - doUpdates(CoreUtils.YOU_GET, youget) - } else { - fire(UpdateYouGetStates(messages["failToUpdate"])) - logger.error("remote updating json is null") + Fuel.get(ContentsUtil.REMOTE_YOU_GET_VERSION).responseString { _, _, result -> + when (result) { + is Result.Success -> { + val remoteV = parseVersion(result.get()) + if (needUpdate(app.config[ContentsUtil.YOU_GET_VERSION] as String, remoteV)) { + logger.debug("[you-get] try to download new version") + downloadYouGet(remoteV) + } else { + fire(UpdateYouGetStates(messages["noUpdates"])) + } + } + is Result.Failure -> { + fire(UpdateYouGetStates(messages["failToUpdate"])) + logger.error("[you-get] failed to check the remote version") + } + } } } subscribe { fire(UpdateYoutubeDLStates(messages["checkForUpdates"])) - val remoteJson = okhttp.requestJson(CoreUtils.REMOTE_CONF_URL) - if (remoteJson != null) { - val youtubedl = remoteJson["youtubedl"] as String - logger.debug("[youtube-dl] remote version url $youtubedl") - doUpdates(CoreUtils.YOUTUBE_DL, youtubedl) - } else { - fire(UpdateYoutubeDLStates(messages["failToUpdate"])) - logger.error("remote updating json is null") + Fuel.get(ContentsUtil.REMOTE_YOUTUBE_DL_VERSION).responseString { _, _, result -> + when (result) { + is Result.Success -> { + val remoteV = parseVersion(result.get()) + if (needUpdate(app.config[ContentsUtil.YOUTUBE_DL_VERSION] as String, remoteV)) { + logger.debug("[youtube-dl] try to download new version") + downloadYoutubeDL(remoteV) + } else { + fire(UpdateYoutubeDLStates(messages["noUpdates"])) + } + } + is Result.Failure -> { + fire(UpdateYoutubeDLStates(messages["failToUpdate"])) + logger.error("[youtube-dl] failed to check the remote version") + } + } } } } - private fun doUpdates(core: String, url: String) { - val vStr = okhttp.requestString(url) - val v = Regex("'\\d+.+'").findAll(vStr.toString()).toList().flatMap(MatchResult::groupValues) - val remoteVersion = v.first().substring(1, v.first().length - 1) - when (core) { - CoreUtils.YOU_GET -> { - val localVersion = app.config["you-get-version"] as String - logger.debug("[you-get] remote version is $remoteVersion, local version is $localVersion") - if (remoteVersion > localVersion) { - // do updates - fire(UpdateYouGetStates("${messages["newVersionIs"]} $remoteVersion, ${messages["downloading"]}")) - val url = CoreUtils.yougetUpdateURL(remoteVersion) - logger.debug("[you-get] update url $url") - okhttp.downloadFile(url, - Paths.get(System.getProperty("user.dir"), "core", "you-get.exe").toString(), - CoreUtils.YOU_GET_VERSION, - remoteVersion) - } else { - fire(UpdateYouGetStates(messages["noUpdates"])) - logger.debug("[you-get] no updates") - } - } - CoreUtils.YOUTUBE_DL -> { - val localVersion = app.config["youtube-dl-version"] as String - logger.debug("[youtube-dl] remote version is $remoteVersion, local version is $localVersion") - if (remoteVersion > localVersion) { - // do updates - fire(UpdateYoutubeDLStates("${messages["newVersionIs"]} $remoteVersion, ${messages["downloading"]}")) - val url = CoreUtils.youtubedlUpdateURL(remoteVersion) - logger.debug("[youtube-dl] update url $url") - okhttp.downloadFile(url, - Paths.get(System.getProperty("user.dir"), "core", "youtube-dl.exe").toString(), - CoreUtils.YOUTUBE_DL_VERSION, - remoteVersion) - } else { - fire(UpdateYoutubeDLStates(messages["noUpdates"])) - logger.debug("[youtube-dl] no updates") - } - } + private fun needUpdate(localVersion: String, remoteVersion: String): Boolean { + logger.debug("local version: $localVersion, remote version: $remoteVersion") + val lv = localVersion.split(".").map { it.toInt() } + val rv = remoteVersion.split(".").map { it.toInt() } + return rv.indices.any { rv[it] - lv[it] > 0 } + } + + private fun parseVersion(vStr: String): String { + val v = Regex("'\\d+.+'").findAll(vStr).toList().flatMap(MatchResult::groupValues) + return v.first().replace("'", "").replace("\"", "") + } + + + private fun downloadYouGet(remoteV: String) { + val url = ContentsUtil.yougetUpdateURL(remoteV) + logger.debug("[you-get] downloading from $url") + Fuel.get(url).response { _, response, _ -> + logger.debug("[you-get] downloading from ${response.url}") + Fuel.download(response.url.toString()).destination { _, _ -> + Paths.get(System.getProperty("user.dir"), "engine", "you-get.exe").toFile() + }.progress { readBytes, totalBytes -> + fire(UpdateYouGetStates("${messages["newVersionIs"]} $remoteV, ${messages["downloading"]} ${(readBytes.toFloat() / totalBytes.toFloat() * 100).toInt()}%")) + }.response { _, _, result -> + when (result) { + is Result.Success -> { + app.config[ContentsUtil.YOU_GET_VERSION] = remoteV + app.config.save() + logger.debug("[you-get] finished updating") + fire(UpdateYouGetStates(messages["compeleted"])) + } + is Result.Failure -> { + logger.debug("[you-get] failed to update") + fire(UpdateYouGetStates(messages["noUpdates"])) + } + } + } + } + } + + private fun downloadYoutubeDL(remoteV: String) { + val url = ContentsUtil.youtubedlUpdateURL(remoteV) + logger.debug("[youtube-dl] downloading from $url") + Fuel.get(url).response { _, response, _ -> + logger.debug("[youtube-dl] downloading from ${response.url}") + Fuel.download(response.url.toString()).destination { _, _ -> + Paths.get(System.getProperty("user.dir"), "engine", "youtube-dl.exe").toFile() + }.progress { readBytes, totalBytes -> + fire(UpdateYoutubeDLStates("${messages["newVersionIs"]} $remoteV, ${messages["downloading"]} ${(readBytes.toFloat() / totalBytes.toFloat() * 100).toInt()}%")) + }.response { _, _, result -> + when (result) { + is Result.Success -> { + app.config[ContentsUtil.YOUTUBE_DL_VERSION] = remoteV + app.config.save() + logger.debug("[youtube-dl] finished updating") + fire(UpdateYoutubeDLStates(messages["compeleted"])) + } + is Result.Failure -> { + logger.debug("[youtube-dl] failed to update") + fire(UpdateYoutubeDLStates(messages["noUpdates"])) + } + } + } } } } \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt b/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt deleted file mode 100644 index cd7e9a1..0000000 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt +++ /dev/null @@ -1,116 +0,0 @@ -package com.ingbyr.guiyouget.core - -import com.beust.klaxon.JsonObject -import com.beust.klaxon.Parser -import com.ingbyr.guiyouget.events.UpdateYouGetStates -import com.ingbyr.guiyouget.events.UpdateYoutubeDLStates -import com.ingbyr.guiyouget.utils.CoreUtils -import okhttp3.* -import okio.Okio -import org.slf4j.LoggerFactory -import tornadofx.* -import java.io.IOException -import java.nio.file.Paths -import java.util.* - - -class OkHttpController : Controller() { - private val logger = LoggerFactory.getLogger(this::class.java) - private val client = OkHttpClient() - private val parser = Parser() - - init { - messages = ResourceBundle.getBundle("i18n/core") - } - - fun requestString(url: String): String? { - val request = Request.Builder().get().url(url).build() - var msg: String? = null - client.newCall(request).execute().let { response -> - msg = response.body()?.string() - } - return msg - } - - fun requestJson(url: String): JsonObject? { - val request = Request.Builder().get().url(url).build() - var msg: String? = null - client.newCall(request).execute().let { response -> - msg = response.body()?.string() - } - if (msg != null) { - return parser.parse(StringBuilder(msg)) as JsonObject - } else { - return null - } - } - - fun downloadFile(url: String, file: String, k: String? = null, v: String? = null) { - val request = Request.Builder().url(url).build() - logger.debug("file path is $file") - try { - client.newCall(request).enqueue(DownloadFileCallBack(file, k, v)) - } catch (e: Exception) { - logger.error(e.message) - } - } -} - -class DownloadFileCallBack(private val file: String, private val k: String?, private val v: String?) : Callback, Controller() { - init { - messages = ResourceBundle.getBundle("i18n/core") - } - - private val logger = LoggerFactory.getLogger(this::class.java) - - override fun onFailure(call: Call?, e: IOException?) { - when (k) { - CoreUtils.YOUTUBE_DL_VERSION -> { - logger.debug("failed to update youtube-dl") - fire(UpdateYoutubeDLStates(messages["failed"])) - } - CoreUtils.YOU_GET_VERSION -> { - logger.debug("failed to update you-get") - fire(UpdateYouGetStates(messages["failed"])) - } - } - logger.error(e.toString()) - } - - override fun onResponse(call: Call?, response: Response) { - if (response.isSuccessful) { - val sink = Okio.buffer(Okio.sink(Paths.get(file).toFile())) - sink.writeAll(response.body()!!.source()) - sink.close() - response.close() - - // Update config of APP - if (k != null && v != null) { - app.config[k] = v - app.config.save() - } - - when (k) { - CoreUtils.YOUTUBE_DL_VERSION -> { - fire(UpdateYoutubeDLStates(messages["completed"])) - } - CoreUtils.YOU_GET_VERSION -> { - fire(UpdateYouGetStates(messages["completed"])) - } - } - } else { - logger.error("bad request") - response.close() - when (k) { - CoreUtils.YOUTUBE_DL_VERSION -> { - logger.debug("failed to update youtube-dl") - fire(UpdateYoutubeDLStates(messages["failed"])) - } - CoreUtils.YOU_GET_VERSION -> { - logger.debug("failed to update you-get") - fire(UpdateYouGetStates(messages["failed"])) - } - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/CoreArgs.kt b/src/main/kotlin/com/ingbyr/guiyouget/engine/DownloadEngine.kt similarity index 73% rename from src/main/kotlin/com/ingbyr/guiyouget/core/CoreArgs.kt rename to src/main/kotlin/com/ingbyr/guiyouget/engine/DownloadEngine.kt index f2e1fc7..4e1ae00 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/CoreArgs.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/engine/DownloadEngine.kt @@ -1,9 +1,9 @@ -package com.ingbyr.guiyouget.core +package com.ingbyr.guiyouget.engine import org.slf4j.LoggerFactory -class CoreArgs(val core: String) { - private val logger = LoggerFactory.getLogger(CoreArgs::class.java) +class DownloadEngine(val core: String) { + private val logger = LoggerFactory.getLogger(DownloadEngine::class.java) private val argsMap = mutableMapOf() @@ -11,7 +11,7 @@ class CoreArgs(val core: String) { argsMap.put(key, value) } - // Build args except core arg + // Build args except engine arg fun build(): MutableList { val args = mutableListOf(core) argsMap.forEach { diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/CoreController.kt b/src/main/kotlin/com/ingbyr/guiyouget/engine/DownloadEngineController.kt similarity index 81% rename from src/main/kotlin/com/ingbyr/guiyouget/core/CoreController.kt rename to src/main/kotlin/com/ingbyr/guiyouget/engine/DownloadEngineController.kt index d2f837e..570130e 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/CoreController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/engine/DownloadEngineController.kt @@ -1,15 +1,14 @@ -package com.ingbyr.guiyouget.core +package com.ingbyr.guiyouget.engine -import org.slf4j.LoggerFactory import tornadofx.* import java.io.BufferedReader import java.io.InputStreamReader import java.util.* -abstract class CoreController : Controller() { +abstract class DownloadEngineController : Controller() { init { - messages = ResourceBundle.getBundle("i18n/core") + messages = ResourceBundle.getBundle("i18n/engine") } fun runCommand(args: MutableList): StringBuilder { diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt b/src/main/kotlin/com/ingbyr/guiyouget/engine/YouGet.kt similarity index 61% rename from src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt rename to src/main/kotlin/com/ingbyr/guiyouget/engine/YouGet.kt index e2d210b..d52f537 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/engine/YouGet.kt @@ -1,22 +1,22 @@ -package com.ingbyr.guiyouget.core +package com.ingbyr.guiyouget.engine import com.beust.klaxon.JsonObject import com.beust.klaxon.Parser import com.ingbyr.guiyouget.events.StopDownloading import com.ingbyr.guiyouget.events.UpdateProgressWithYouGet -import com.ingbyr.guiyouget.utils.CoreUtils +import com.ingbyr.guiyouget.utils.ContentsUtil import org.slf4j.LoggerFactory import tornadofx.* import java.io.BufferedReader import java.io.InputStreamReader import java.nio.file.Paths -class YouGet(val url: String) : CoreController() { +class YouGet(val url: String) : DownloadEngineController() { companion object { val logger = LoggerFactory.getLogger(this::class.java) } - val core = Paths.get(System.getProperty("user.dir"), "core", "you-get.exe").toAbsolutePath().toString() + val core = Paths.get(System.getProperty("user.dir"), "engine", "you-get.exe").toAbsolutePath().toString() private val parser = Parser() private var progress = 0.0 private var speed = "0MB/s" @@ -29,21 +29,21 @@ class YouGet(val url: String) : CoreController() { } } - private fun requestJsonAargs(): CoreArgs { - val args = CoreArgs(core) - args.add("simulator", "--json") - when (app.config[CoreUtils.PROXY_TYPE]) { - CoreUtils.PROXY_SOCKS -> { - args.add("-x", - "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + private fun requestJsonAargs(): DownloadEngine { + val engine = DownloadEngine(core) + engine.add("simulator", "--json") + when (app.config[ContentsUtil.PROXY_TYPE]) { + ContentsUtil.PROXY_SOCKS -> { + engine.add("-x", + "${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}") } - CoreUtils.PROXY_HTTP -> { - args.add("-x", - "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + ContentsUtil.PROXY_HTTP -> { + engine.add("-x", + "${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}") } } - args.add("url", url) - return args + engine.add("url", url) + return engine } fun getMediasInfo(): JsonObject { @@ -56,21 +56,21 @@ class YouGet(val url: String) : CoreController() { isDownloading = true status = messages["downloading"] var line: String? - val args = CoreArgs(core) - when (app.config[CoreUtils.PROXY_TYPE]) { - CoreUtils.PROXY_SOCKS -> { - args.add("-x", - "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + val engine = DownloadEngine(core) + when (app.config[ContentsUtil.PROXY_TYPE]) { + ContentsUtil.PROXY_SOCKS -> { + engine.add("-x", + "${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}") } - CoreUtils.PROXY_HTTP -> { - args.add("-x", - "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + ContentsUtil.PROXY_HTTP -> { + engine.add("-x", + "${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}") } } - args.add("foramtID", "--itag=$formatID") - args.add("-o", app.config["storagePath"] as String) - args.add("url", url) - val builder = ProcessBuilder(args.build()) + engine.add("foramtID", "--itag=$formatID") + engine.add("-o", app.config[ContentsUtil.STORAGE_PATH] as String) + engine.add("url", url) + val builder = ProcessBuilder(engine.build()) builder.redirectErrorStream(true) val p = builder.start() val r = BufferedReader(InputStreamReader(p.inputStream)) diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt b/src/main/kotlin/com/ingbyr/guiyouget/engine/YoutubeDL.kt similarity index 60% rename from src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt rename to src/main/kotlin/com/ingbyr/guiyouget/engine/YoutubeDL.kt index a28d18e..9f476fe 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/engine/YoutubeDL.kt @@ -1,10 +1,10 @@ -package com.ingbyr.guiyouget.core +package com.ingbyr.guiyouget.engine import com.beust.klaxon.JsonObject import com.beust.klaxon.Parser import com.ingbyr.guiyouget.events.StopDownloading import com.ingbyr.guiyouget.events.UpdateProgressWithYoutubeDL -import com.ingbyr.guiyouget.utils.CoreUtils +import com.ingbyr.guiyouget.utils.ContentsUtil import org.slf4j.LoggerFactory import tornadofx.* import java.io.BufferedReader @@ -12,12 +12,12 @@ import java.io.InputStreamReader import java.nio.file.Paths -class YoutubeDL(private val url: String) : CoreController() { +class YoutubeDL(private val url: String) : DownloadEngineController() { companion object { val logger = LoggerFactory.getLogger(this::class.java) } - val core = Paths.get(System.getProperty("user.dir"), "core", "youtube-dl.exe").toAbsolutePath().toString() + val core = Paths.get(System.getProperty("user.dir"), "engine", "youtube-dl.exe").toAbsolutePath().toString() private val parser = Parser() private var progress = 0.0 private var speed = "0MiB/s" @@ -32,21 +32,21 @@ class YoutubeDL(private val url: String) : CoreController() { } } - private fun requestJsonArgs(): CoreArgs { - val args = CoreArgs(core) - args.add("simulator", "-j") - when (app.config[CoreUtils.PROXY_TYPE]) { - CoreUtils.PROXY_SOCKS -> { - args.add("--proxy", - "socks5://${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}/") + private fun requestJsonArgs(): DownloadEngine { + val engine = DownloadEngine(core) + engine.add("simulator", "-j") + when (app.config[ContentsUtil.PROXY_TYPE]) { + ContentsUtil.PROXY_SOCKS -> { + engine.add("--proxy", + "socks5://${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}/") } - CoreUtils.PROXY_HTTP -> { - args.add("--proxy", - "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + ContentsUtil.PROXY_HTTP -> { + engine.add("--proxy", + "${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}") } } - args.add("url", url) - return args + engine.add("url", url) + return engine } fun getMediasInfo(): JsonObject { @@ -60,21 +60,21 @@ class YoutubeDL(private val url: String) : CoreController() { isDownloading = true status = messages["downloading"] var line: String? - val args = CoreArgs(core) - when (app.config[CoreUtils.PROXY_TYPE]) { - CoreUtils.PROXY_SOCKS -> { - args.add("--proxy", - "socks5://${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}/") + val engine = DownloadEngine(core) + when (app.config[ContentsUtil.PROXY_TYPE]) { + ContentsUtil.PROXY_SOCKS -> { + engine.add("--proxy", + "socks5://${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}/") } - CoreUtils.PROXY_HTTP -> { - args.add("--proxy", - "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + ContentsUtil.PROXY_HTTP -> { + engine.add("--proxy", + "${app.config[ContentsUtil.PROXY_ADDRESS]}:${app.config[ContentsUtil.PROXY_PORT]}") } } - args.add("-f", formatID) - args.add("-o", Paths.get(app.config["storagePath"] as String, outputTemplate).toString()) - args.add("url", url) - val builder = ProcessBuilder(args.build()) + engine.add("-f", formatID) + engine.add("-o", Paths.get(app.config[ContentsUtil.STORAGE_PATH] as String, outputTemplate).toString()) + engine.add("url", url) + val builder = ProcessBuilder(engine.build()) builder.redirectErrorStream(true) val p = builder.start() val r = BufferedReader(InputStreamReader(p.inputStream)) diff --git a/src/main/kotlin/com/ingbyr/guiyouget/events/MediaEvents.kt b/src/main/kotlin/com/ingbyr/guiyouget/events/MediaEvents.kt index 070b7ba..cf6a282 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/events/MediaEvents.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/events/MediaEvents.kt @@ -1,8 +1,8 @@ package com.ingbyr.guiyouget.events import com.beust.klaxon.JsonObject -import com.ingbyr.guiyouget.core.YouGet -import com.ingbyr.guiyouget.core.YoutubeDL +import com.ingbyr.guiyouget.engine.YouGet +import com.ingbyr.guiyouget.engine.YoutubeDL import tornadofx.* // common events diff --git a/src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt b/src/main/kotlin/com/ingbyr/guiyouget/utils/ContentsUtil.kt similarity index 74% rename from src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt rename to src/main/kotlin/com/ingbyr/guiyouget/utils/ContentsUtil.kt index 22d8eb0..b7a172e 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/utils/ContentsUtil.kt @@ -1,13 +1,14 @@ package com.ingbyr.guiyouget.utils -object CoreUtils { - var DOWNLOAD_CORE = "download-core" - var REMOTE_CONF_URL = "https://raw.githubusercontent.com/ingbyr/GUI-YouGet/master/RemoteConf.json" +object ContentsUtil { + val DOWNLOAD_CORE = "download-engine" + val REMOTE_YOU_GET_VERSION = "https://raw.githubusercontent.com/soimort/you-get/master/src/you_get/version.py" + val REMOTE_YOUTUBE_DL_VERSION = "https://raw.githubusercontent.com/rg3/youtube-dl/master/youtube_dl/version.py" val YOUTUBE_DL = "youtube-dl" val YOUTUBE_DL_VERSION = "youtube-dl-version" val YOU_GET = "you-get" val YOU_GET_VERSION = "you-get-version" - val STORAGE_PATH = "storagePath" + val STORAGE_PATH = "storage-path" val PROXY_TYPE = "proxy-type" val PROXY_ADDRESS = "proxy-address" @@ -21,7 +22,6 @@ object CoreUtils { val APP_LICENSE = "https://raw.githubusercontent.com/ingbyr/GUI-YouGet/master/LICENSE.txt" val APP_AUTHOR = "http://www.ingbyr.com/" val APP_REPORT_BUGS = "https://github.com/ingbyr/GUI-YouGet/issues" - val APP_DONATE = "http://wx3.sinaimg.cn/large/bca3b20dly1fjx6l6j4r2j20ci0cgq55.jpg" fun yougetUpdateURL(ver: String) = "https://github.com/soimort/you-get/releases/download/v$ver/you-get-$ver-win32.exe" diff --git a/src/main/kotlin/com/ingbyr/guiyouget/views/ImageView.kt b/src/main/kotlin/com/ingbyr/guiyouget/views/ImageView.kt new file mode 100644 index 0000000..38226b3 --- /dev/null +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/ImageView.kt @@ -0,0 +1,9 @@ +package com.ingbyr.guiyouget.views + +import tornadofx.* + +class ImageView : View("捐赠") { + override val root = vbox { + imageview("/img/zhifubao_compress.jpg", lazyload = false) + } +} diff --git a/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt b/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt index bce4b55..a390487 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt @@ -3,14 +3,11 @@ package com.ingbyr.guiyouget.views import com.ingbyr.guiyouget.controllers.MainController import com.ingbyr.guiyouget.events.RequestCheckUpdatesYouGet import com.ingbyr.guiyouget.events.RequestCheckUpdatesYoutubeDL -import com.ingbyr.guiyouget.utils.CoreUtils +import com.ingbyr.guiyouget.utils.ContentsUtil import com.jfoenix.controls.JFXButton import com.jfoenix.controls.JFXCheckBox -import com.jfoenix.controls.JFXComboBox import com.jfoenix.controls.JFXTextField import javafx.application.Platform -import javafx.beans.property.SimpleStringProperty -import javafx.collections.FXCollections import javafx.scene.control.Label import javafx.scene.input.MouseEvent import javafx.scene.layout.AnchorPane @@ -89,25 +86,25 @@ class MainView : View("GUI-YouGet") { } // Storage path - if (app.config[CoreUtils.STORAGE_PATH] == null || app.config[CoreUtils.STORAGE_PATH] == "") { + if (app.config[ContentsUtil.STORAGE_PATH] == null || app.config[ContentsUtil.STORAGE_PATH] == "") { labelStoragePath.text = Paths.get(System.getProperty("user.dir")).toAbsolutePath().toString() - app.config[CoreUtils.STORAGE_PATH] = labelStoragePath.text + app.config[ContentsUtil.STORAGE_PATH] = labelStoragePath.text app.config.save() } else { - labelStoragePath.text = app.config[CoreUtils.STORAGE_PATH] as String + labelStoragePath.text = app.config[ContentsUtil.STORAGE_PATH] as String } btnChangePath.setOnMouseClicked { val file = DirectoryChooser().showDialog(primaryStage) - if (file != null) { - app.config[CoreUtils.STORAGE_PATH] = file.absolutePath.toString() + file?.apply { + app.config[ContentsUtil.STORAGE_PATH] = file.absolutePath.toString() app.config.save() labelStoragePath.text = file.absolutePath.toString() } } btnOpenDir.setOnMouseClicked { - val dir = Paths.get(app.config[CoreUtils.STORAGE_PATH] as String).toFile() + val dir = Paths.get(app.config[ContentsUtil.STORAGE_PATH] as String).toFile() Desktop.getDesktop().open(dir) } @@ -119,32 +116,32 @@ class MainView : View("GUI-YouGet") { } } - // Load download core config - val core = app.config[CoreUtils.DOWNLOAD_CORE] + // Load download engine config + val core = app.config[ContentsUtil.DOWNLOAD_CORE] when (core) { - CoreUtils.YOUTUBE_DL -> { + ContentsUtil.YOUTUBE_DL -> { cbYoutubeDL.isSelected = true } - CoreUtils.YOU_GET -> { + ContentsUtil.YOU_GET -> { cbYouGet.isSelected = true } else -> { - app.config[CoreUtils.DOWNLOAD_CORE] = CoreUtils.YOUTUBE_DL + app.config[ContentsUtil.DOWNLOAD_CORE] = ContentsUtil.YOUTUBE_DL app.config.save() cbYoutubeDL.isSelected = true } } // Init version - labelYouGet.text = app.config[CoreUtils.YOU_GET_VERSION] as String - labelYoutubeDL.text = app.config[CoreUtils.YOUTUBE_DL_VERSION] as String - labelAPP.text = app.config[CoreUtils.APP_VERSION] as String + labelYouGet.text = app.config[ContentsUtil.YOU_GET_VERSION] as String + labelYoutubeDL.text = app.config[ContentsUtil.YOUTUBE_DL_VERSION] as String + labelAPP.text = app.config[ContentsUtil.APP_VERSION] as String - // Change download core + // Change download engine cbYouGet.action { if (cbYouGet.isSelected) { cbYoutubeDL.isSelected = false - app.config[CoreUtils.DOWNLOAD_CORE] = CoreUtils.YOU_GET + app.config[ContentsUtil.DOWNLOAD_CORE] = ContentsUtil.YOU_GET app.config.save() } } @@ -152,7 +149,7 @@ class MainView : View("GUI-YouGet") { cbYoutubeDL.action { if (cbYoutubeDL.isSelected) { cbYouGet.isSelected = false - app.config[CoreUtils.DOWNLOAD_CORE] = CoreUtils.YOUTUBE_DL + app.config[ContentsUtil.DOWNLOAD_CORE] = ContentsUtil.YOUTUBE_DL app.config.save() } } @@ -169,17 +166,17 @@ class MainView : View("GUI-YouGet") { } // Proxy - val proxy = app.config[CoreUtils.PROXY_TYPE] + val proxy = app.config[ContentsUtil.PROXY_TYPE] when (proxy) { - CoreUtils.PROXY_HTTP -> { + ContentsUtil.PROXY_HTTP -> { cbHTTP.isSelected = true - tfHTTPAddress.text = app.config[CoreUtils.PROXY_ADDRESS] as String - tfHTTPPort.text = app.config[CoreUtils.PROXY_PORT] as String + tfHTTPAddress.text = app.config[ContentsUtil.PROXY_ADDRESS] as String + tfHTTPPort.text = app.config[ContentsUtil.PROXY_PORT] as String } - CoreUtils.PROXY_SOCKS -> { + ContentsUtil.PROXY_SOCKS -> { cbSocks5.isSelected = true - tfSocksAddress.text = app.config[CoreUtils.PROXY_ADDRESS] as String - tfSocksPort.text = app.config[CoreUtils.PROXY_PORT] as String + tfSocksAddress.text = app.config[ContentsUtil.PROXY_ADDRESS] as String + tfSocksPort.text = app.config[ContentsUtil.PROXY_PORT] as String } else -> { cbHTTP.isSelected = false @@ -188,29 +185,29 @@ class MainView : View("GUI-YouGet") { } tfSocksAddress.textProperty().addListener { _, _, newValue -> - if (app.config[CoreUtils.PROXY_TYPE] == CoreUtils.PROXY_SOCKS) { - app.config[CoreUtils.PROXY_ADDRESS] = newValue + if (app.config[ContentsUtil.PROXY_TYPE] == ContentsUtil.PROXY_SOCKS) { + app.config[ContentsUtil.PROXY_ADDRESS] = newValue app.config.save() } } tfSocksPort.textProperty().addListener { _, _, newValue -> - if (app.config[CoreUtils.PROXY_TYPE] == CoreUtils.PROXY_SOCKS) { - app.config[CoreUtils.PROXY_PORT] = newValue + if (app.config[ContentsUtil.PROXY_TYPE] == ContentsUtil.PROXY_SOCKS) { + app.config[ContentsUtil.PROXY_PORT] = newValue app.config.save() } } tfHTTPAddress.textProperty().addListener { _, _, newValue -> - if (app.config[CoreUtils.PROXY_TYPE] == CoreUtils.PROXY_HTTP) { - app.config[CoreUtils.PROXY_ADDRESS] = newValue + if (app.config[ContentsUtil.PROXY_TYPE] == ContentsUtil.PROXY_HTTP) { + app.config[ContentsUtil.PROXY_ADDRESS] = newValue app.config.save() } } tfHTTPPort.textProperty().addListener { _, _, newValue -> - if (app.config[CoreUtils.PROXY_TYPE] == CoreUtils.PROXY_HTTP) { - app.config[CoreUtils.PROXY_PORT] = newValue + if (app.config[ContentsUtil.PROXY_TYPE] == ContentsUtil.PROXY_HTTP) { + app.config[ContentsUtil.PROXY_PORT] = newValue app.config.save() } } @@ -220,16 +217,16 @@ class MainView : View("GUI-YouGet") { val port = tfSocksPort.text // Disable socks proxy if (!cbSocks5.isSelected) { - app.config[CoreUtils.PROXY_TYPE] = "" + app.config[ContentsUtil.PROXY_TYPE] = "" app.config.save() } // Enable socks proxy if (cbSocks5.isSelected) { cbHTTP.isSelected = false - app.config[CoreUtils.PROXY_TYPE] = CoreUtils.PROXY_SOCKS - app.config[CoreUtils.PROXY_ADDRESS] = address - app.config[CoreUtils.PROXY_PORT] = port + app.config[ContentsUtil.PROXY_TYPE] = ContentsUtil.PROXY_SOCKS + app.config[ContentsUtil.PROXY_ADDRESS] = address + app.config[ContentsUtil.PROXY_PORT] = port app.config.save() } } @@ -239,29 +236,27 @@ class MainView : View("GUI-YouGet") { val port = tfHTTPPort.text // Disable http proxy if (!cbHTTP.isSelected) { - app.config[CoreUtils.PROXY_TYPE] = "" + app.config[ContentsUtil.PROXY_TYPE] = "" app.config.save() } // Enable http proxy if (cbHTTP.isSelected) { cbSocks5.isSelected = false - app.config[CoreUtils.PROXY_TYPE] = CoreUtils.PROXY_HTTP - app.config[CoreUtils.PROXY_ADDRESS] = address - app.config[CoreUtils.PROXY_PORT] = port + app.config[ContentsUtil.PROXY_TYPE] = ContentsUtil.PROXY_HTTP + app.config[ContentsUtil.PROXY_ADDRESS] = address + app.config[ContentsUtil.PROXY_PORT] = port app.config.save() } } // About view - labelVersion.text = app.config[CoreUtils.APP_VERSION] as String - labelGitHub.setOnMouseClicked { hostServices.showDocument(CoreUtils.APP_SOURCE_CODE) } - labelLicense.setOnMouseClicked { hostServices.showDocument(CoreUtils.APP_LICENSE) } - labelAuthor.setOnMouseClicked { hostServices.showDocument(CoreUtils.APP_AUTHOR) } - btnReportBug.action { hostServices.showDocument(CoreUtils.APP_REPORT_BUGS) } - btnDonate.action { hostServices.showDocument(CoreUtils.APP_DONATE) } - - //todo 增加获取不同解析度选线,跳过JSON部分直接下载 + labelVersion.text = app.config[ContentsUtil.APP_VERSION] as String + labelGitHub.setOnMouseClicked { hostServices.showDocument(ContentsUtil.APP_SOURCE_CODE) } + labelLicense.setOnMouseClicked { hostServices.showDocument(ContentsUtil.APP_LICENSE) } + labelAuthor.setOnMouseClicked { hostServices.showDocument(ContentsUtil.APP_AUTHOR) } + btnReportBug.action { hostServices.showDocument(ContentsUtil.APP_REPORT_BUGS) } + btnDonate.action { openInternalWindow(ImageView::class)} } // clean the url textfield diff --git a/src/main/kotlin/com/ingbyr/guiyouget/views/MediaListView.kt b/src/main/kotlin/com/ingbyr/guiyouget/views/MediaListView.kt index 97c47d5..6baa9b9 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/views/MediaListView.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/MediaListView.kt @@ -3,13 +3,13 @@ package com.ingbyr.guiyouget.views import com.beust.klaxon.array import com.beust.klaxon.string import com.ingbyr.guiyouget.controllers.MediaListController -import com.ingbyr.guiyouget.core.YouGet -import com.ingbyr.guiyouget.core.YoutubeDL +import com.ingbyr.guiyouget.engine.YouGet +import com.ingbyr.guiyouget.engine.YoutubeDL import com.ingbyr.guiyouget.events.DisplayMediasWithYouGet import com.ingbyr.guiyouget.events.DisplayMediasWithYoutubeDL import com.ingbyr.guiyouget.events.DownloadingRequestWithYouGet import com.ingbyr.guiyouget.events.DownloadingRequestWithYoutubeDL -import com.ingbyr.guiyouget.utils.CoreUtils +import com.ingbyr.guiyouget.utils.ContentsUtil import com.jfoenix.controls.JFXListView import javafx.application.Platform import javafx.scene.control.Label @@ -79,9 +79,9 @@ class MediaListView : View("GUI-YouGet") { val formatID = it.text.split(" ")[0] logger.debug("select format id is ${formatID}") ProgressView().openModal(StageStyle.UNDECORATED) - when (app.config[CoreUtils.DOWNLOAD_CORE]) { - CoreUtils.YOUTUBE_DL -> fire(DownloadingRequestWithYoutubeDL(YoutubeDL(url), formatID)) - CoreUtils.YOU_GET -> fire(DownloadingRequestWithYouGet(YouGet(url), formatID)) + when (app.config[ContentsUtil.DOWNLOAD_CORE]) { + ContentsUtil.YOUTUBE_DL -> fire(DownloadingRequestWithYoutubeDL(YoutubeDL(url), formatID)) + ContentsUtil.YOU_GET -> fire(DownloadingRequestWithYouGet(YouGet(url), formatID)) } } } diff --git a/src/main/kotlin/com/ingbyr/guiyouget/views/ProgressView.kt b/src/main/kotlin/com/ingbyr/guiyouget/views/ProgressView.kt index a2266d7..a4c4e0b 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/views/ProgressView.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/ProgressView.kt @@ -18,7 +18,7 @@ class ProgressView : View() { private val logger = LoggerFactory.getLogger(this::class.java) init { - messages = ResourceBundle.getBundle("i18n/core") + messages = ResourceBundle.getBundle("i18n/engine") } private val controller: ProgressController by inject() diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index 6f7b457..b0b4eac 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -166,7 +166,7 @@ - - - + diff --git a/src/main/resources/fxml/UpdatesWindow.fxml b/src/main/resources/fxml/UpdatesWindow.fxml index 451ac9c..1c8b4b5 100644 --- a/src/main/resources/fxml/UpdatesWindow.fxml +++ b/src/main/resources/fxml/UpdatesWindow.fxml @@ -6,7 +6,7 @@ - + @@ -24,12 +24,12 @@ -