diff --git a/.gitignore b/.gitignore index e09dcd7..dd45b37 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ conf/ gradle/ gradlew gradlew.bat +log/ diff --git a/LICENSE.txt b/LICENSE.txt index 8c86422..42b3558 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ ============================================== This is a copy of the MIT license. ============================================== -Copyright (C) 2016 InG_byr +Copyright (C) 2016-2017 ingbyr Copyright (C) 2012, 2013, 2014, 2015, 2016 Mort Yao Copyright (C) 2012 Boyu Guo diff --git a/README.md b/README.md index a2b0c98..f5818ab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,38 @@ # GUI-YouGet +![](https://img.shields.io/badge/v0.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) +![](https://img.shields.io/github/issues/ingbyr/GUI-YouGet.svg) -## Authors +> [中文说明](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. + +[GUI-YouGet Download Page](https://github.com/ingbyr/GUI-YouGet/releases) + +# Screenshot +![](screenshot/main.png) +![](screenshot/medias.png) +![](screenshot/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. + +# Legal Issues + +This software is distributed under the [MIT license](https://raw.githubusercontent.com/ingbyr/GUI-YouGet/master/LICENSE.txt). +In particular, please be aware that +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +# Authors Made by [@ingbyr](http://www.ingbyr.com) diff --git a/build.gradle b/build.gradle index 9efdf26..f99fa09 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'com.ingbyr.guiyouget' -version '1.0-SNAPSHOT' +version '0.2' buildscript { ext.kotlin_version = '1.1.50' @@ -13,12 +13,18 @@ buildscript { } apply plugin: 'kotlin' -apply plugin: 'application' -mainClassName = "com.ingbyr.guiyouget.Main" +jar { + manifest { + attributes('Main-Class': 'com.ingbyr.guiyouget.MainKt') + } + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } +} + sourceCompatibility = 1.8 + repositories { mavenCentral() jcenter() diff --git a/src/main/resources/core/you-get.exe.REMOVED.git-id b/core/you-get.exe.REMOVED.git-id similarity index 100% rename from src/main/resources/core/you-get.exe.REMOVED.git-id rename to core/you-get.exe.REMOVED.git-id diff --git a/core/youtube-dl.exe.REMOVED.git-id b/core/youtube-dl.exe.REMOVED.git-id new file mode 100644 index 0000000..3dab9aa --- /dev/null +++ b/core/youtube-dl.exe.REMOVED.git-id @@ -0,0 +1 @@ +772ac2cc9a9eabd17bcb3d0c14d787d48dd5c941 \ No newline at end of file diff --git a/screenshot/download.png b/screenshot/download.png new file mode 100644 index 0000000..3a8300e Binary files /dev/null and b/screenshot/download.png differ diff --git a/screenshot/main.png b/screenshot/main.png new file mode 100644 index 0000000..9dea31b Binary files /dev/null and b/screenshot/main.png differ diff --git a/screenshot/medias.png b/screenshot/medias.png new file mode 100644 index 0000000..38a6de2 Binary files /dev/null and b/screenshot/medias.png differ diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt index fa0e9f8..100ccbd 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/MainController.kt @@ -14,7 +14,7 @@ class MainController : Controller() { private val logger: Logger = LoggerFactory.getLogger(MainController::class.java) fun requestMediaInfo(url: String) { - val core = app.config["core"] as String + val core = app.config[CoreUtils.DOWNLOAD_CORE] logger.debug("download core is $core") // Init the request args @@ -36,6 +36,6 @@ class MainController : Controller() { fun updateGUI() { - + hostServices.showDocument(CoreUtils.APP_UPDATE_URL) } } \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt index d50f9b7..77c9e51 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/ProgressController.kt @@ -1,6 +1,5 @@ package com.ingbyr.guiyouget.controllers -import com.ingbyr.guiyouget.core.OkHttpController import com.ingbyr.guiyouget.core.YouGet import com.ingbyr.guiyouget.core.YoutubeDL import com.ingbyr.guiyouget.events.DownloadingRequestWithYouGet @@ -9,8 +8,7 @@ import org.slf4j.LoggerFactory import tornadofx.* class ProgressController : Controller() { - val logger = LoggerFactory.getLogger(this::class.java) - val okhttp = OkHttpController() + private val logger = LoggerFactory.getLogger(this::class.java) fun subscribeEvents() { subscribe { diff --git a/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt b/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt index 61c10e6..1382083 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/controllers/UpdatesController.kt @@ -1,25 +1,23 @@ package com.ingbyr.guiyouget.controllers import com.ingbyr.guiyouget.core.OkHttpController -import com.ingbyr.guiyouget.events.RequestCheckUpdatesYouGet -import com.ingbyr.guiyouget.events.RequestCheckUpdatesYoutubeDL -import com.ingbyr.guiyouget.events.UpdateStates +import com.ingbyr.guiyouget.events.* import com.ingbyr.guiyouget.utils.CoreUtils import org.slf4j.LoggerFactory import tornadofx.* -import java.io.File +import java.nio.file.Paths -class UpdatesController: Controller() { - val logger = LoggerFactory.getLogger(this::class.java) - val okhttp = OkHttpController() +class UpdatesController : Controller() { + private val logger = LoggerFactory.getLogger(this::class.java) + private val okhttp = OkHttpController() fun subscribeEvents() { subscribe { - fire(UpdateStates("Check for updates of you-get")) + fire(UpdateYouGetStates("[you-get] Check for updates...")) val remoteJson = okhttp.requestJson(CoreUtils.REMOTE_CONF_URL) if (remoteJson != null) { val youget = remoteJson["youget"] as String - logger.debug("get remote version file url $youget") + logger.debug("[you-get] remote version url $youget") doUpdates(CoreUtils.YOU_GET, youget) } else { //todo update failed @@ -27,11 +25,11 @@ class UpdatesController: Controller() { } subscribe { - fire(UpdateStates("Check for updates of youyube-dl")) + fire(UpdateYoutubeDLStates("[youtube-dl] Check for updates...")) val remoteJson = okhttp.requestJson(CoreUtils.REMOTE_CONF_URL) if (remoteJson != null) { val youtubedl = remoteJson["youtubedl"] as String - logger.debug("get remote version file url $youtubedl") + logger.debug("[youtube-dl] remote version url $youtubedl") doUpdates(CoreUtils.YOUTUBE_DL, youtubedl) } else { //todo update failed @@ -46,26 +44,38 @@ class UpdatesController: Controller() { when (core) { CoreUtils.YOU_GET -> { val localVersion = app.config["you-get-version"] as String - logger.debug("remote version is $remoteVersion, local version is $localVersion") + logger.debug("[you-get] remote version is $remoteVersion, local version is $localVersion") if (remoteVersion > localVersion) { // do updates - fire(UpdateStates("New version $remoteVersion of you-get, downloading")) + fire(UpdateYouGetStates("[you-get] New version $remoteVersion downloading...")) val url = CoreUtils.yougetUpdateURL(remoteVersion) - logger.debug("you-get update url $url") - okhttp.downloadFile(url, File(MainController::class.java.getResource("/core/you-get.exe").toURI())) + logger.debug("[you-get] update url $url") + okhttp.downloadFile(url, + Paths.get(System.getProperty("user.dir"), "core", "you-get.exe").toFile(), + CoreUtils.YOU_GET_VERSION, + remoteVersion) + } else { + fire(UpdateYouGetStates("[you-get] No updates")) + 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(UpdateStates("New version $remoteVersion of youtube-dl, downloading")) + fire(UpdateYoutubeDLStates("[youtube-dl] New version $remoteVersion downloading...")) val url = CoreUtils.youtubedlUpdateURL(remoteVersion) - logger.debug("youtube-dl update url $url") - okhttp.downloadFile(url, File(MainController::class.java.getResource("/core/youtube-dl.exe").toURI())) + logger.debug("[youtube-dl] update url $url") + okhttp.downloadFile(url, + Paths.get(System.getProperty("user.dir"), "core", "youtube-dl.exe").toFile(), + CoreUtils.YOUTUBE_DL_VERSION, + remoteVersion) + } else { + fire(UpdateYoutubeDLStates("[youtube-dl]No updates")) + logger.debug("[youtube-dl] no updates") } } } - } } \ 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/core/CoreArgs.kt index 1a7d942..f2e1fc7 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/CoreArgs.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/core/CoreArgs.kt @@ -3,8 +3,8 @@ package com.ingbyr.guiyouget.core import org.slf4j.LoggerFactory class CoreArgs(val core: String) { - val logger = LoggerFactory.getLogger(CoreArgs::class.java) - val argsMap = mutableMapOf() + private val logger = LoggerFactory.getLogger(CoreArgs::class.java) + private val argsMap = mutableMapOf() fun add(key: String, value: String) { diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt b/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt index ed10dc0..e62e49d 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt @@ -2,6 +2,9 @@ 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 org.slf4j.LoggerFactory import tornadofx.* @@ -11,9 +14,9 @@ import java.io.IOException class OkHttpController : Controller() { - val logger = LoggerFactory.getLogger(this::class.java) - val client = OkHttpClient() - val parser = Parser() + private val logger = LoggerFactory.getLogger(this::class.java) + private val client = OkHttpClient() + private val parser = Parser() fun requestString(url: String): String? { val request = Request.Builder().get().url(url).build() @@ -37,17 +40,25 @@ class OkHttpController : Controller() { } } - fun downloadFile(url: String, file: File) { + fun downloadFile(url: String, file: File, k: String? = null, v: String? = null) { val request = Request.Builder().url(url).build() logger.debug("save file to ${file.absolutePath}") - client.newCall(request).enqueue(DownloadFileCallBack(file)) + client.newCall(request).enqueue(DownloadFileCallBack(file, k, v)) } } -class DownloadFileCallBack(var file: File) : Callback, Controller() { - val logger = LoggerFactory.getLogger(this::class.java) +class DownloadFileCallBack(private val file: File, private val k: String?, private val v: String?) : Callback, Controller() { + private val logger = LoggerFactory.getLogger(this::class.java) override fun onFailure(call: Call?, e: IOException?) { + when (k) { + CoreUtils.YOUTUBE_DL_VERSION -> { + fire(UpdateYoutubeDLStates("[youtube-dl] Fail to update")) + } + CoreUtils.YOU_GET_VERSION -> { + fire(UpdateYouGetStates("[you-get] Fail to update")) + } + } logger.error(e.toString()) } @@ -74,7 +85,7 @@ class DownloadFileCallBack(var file: File) : Callback, Controller() { } if (bytesRead == -1) break process += bytesRead - println(process) + logger.trace(process.toString()) os.write(buffer, 0, bytesRead) } while (true) } catch (e: Exception) { @@ -82,5 +93,18 @@ class DownloadFileCallBack(var file: File) : Callback, Controller() { } + when (k) { + CoreUtils.YOUTUBE_DL_VERSION -> { + fire(UpdateYoutubeDLStates("[youtube-dl] Updating completed")) + } + CoreUtils.YOU_GET_VERSION -> { + fire(UpdateYouGetStates("[you-get] Updating completed")) + } + } + // Update config of APP + if (k != null && v != null) { + app.config[k] = v + app.config.save() + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt b/src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt index c1f5296..21d4ff8 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt @@ -4,14 +4,14 @@ 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 java.io.BufferedReader import java.io.InputStreamReader -import java.nio.file.Files import java.nio.file.Paths class YouGet(val url: String) : CoreController() { - val core = this::class.java.getResource("/core/you-get.exe").path - val parser = Parser() + val core = Paths.get(System.getProperty("user.dir"), "core", "you-get.exe").toAbsolutePath().toString() + private val parser = Parser() private var progress = 0.0 private var speed = "0MB/s" private var status = "Analyzing..." @@ -26,6 +26,17 @@ 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 -> { +// logger.error("[you-get] Not support socks proxy") + args.add("-x", + "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + } + CoreUtils.PROXY_HTTP -> { + args.add("-x", + "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + } + } args.add("url", url) return args } @@ -38,8 +49,19 @@ class YouGet(val url: String) : CoreController() { override fun runDownloadCommand(formatID: String) { isDownloading = true + status = "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]}") + } + CoreUtils.PROXY_HTTP -> { + args.add("-x", + "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + } + } args.add("foramtID", "--itag=$formatID") args.add("-o", app.config["storagePath"] as String) args.add("url", url) diff --git a/src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt b/src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt index 7e31050..aa3f871 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/core/YoutubeDL.kt @@ -4,15 +4,15 @@ 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 java.io.BufferedReader import java.io.InputStreamReader -import java.nio.file.Files import java.nio.file.Paths class YoutubeDL(private val url: String) : CoreController() { - private val core = this::class.java.getResource("/core/youtube-dl.exe").path + val core = Paths.get(System.getProperty("user.dir"), "core", "youtube-dl.exe").toAbsolutePath().toString() private val parser = Parser() private var progress = 0.0 private var speed = "0MiB/s" @@ -27,16 +27,26 @@ class YoutubeDL(private val url: String) : CoreController() { } } - private fun requestJsonAargs(): CoreArgs { + private fun requestJsonArgs(): CoreArgs { val args = CoreArgs(core) args.add("simulator", "-j") - args.add("--proxy", "socks5://127.0.0.1:1080/") + when (app.config[CoreUtils.PROXY_TYPE]) { + CoreUtils.PROXY_SOCKS -> { + args.add("--proxy", + "socks5://${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}/") + } + CoreUtils.PROXY_HTTP -> { + args.add("--proxy", + "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + } + } +// args.add("--proxy", "socks5://127.0.0.1:1080/") args.add("url", url) return args } fun getMediasInfo(): JsonObject { - val output = runCommand(requestJsonAargs().build()) + val output = runCommand(requestJsonArgs().build()) // Files.write(Paths.get(System.getProperty("user.dir"), "info.json"), output.toString().toByteArray()) return parser.parse(output) as JsonObject } @@ -44,10 +54,19 @@ class YoutubeDL(private val url: String) : CoreController() { override fun runDownloadCommand(formatID: String) { isDownloading = true + status = "Downloading..." var line: String? val args = CoreArgs(core) - // todo remove proxy from this - args.add("--proxy", "socks5://127.0.0.1:1080/") + when (app.config[CoreUtils.PROXY_TYPE]) { + CoreUtils.PROXY_SOCKS -> { + args.add("--proxy", + "socks5://${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}/") + } + CoreUtils.PROXY_HTTP -> { + args.add("--proxy", + "${app.config[CoreUtils.PROXY_ADDRESS]}:${app.config[CoreUtils.PROXY_PORT]}") + } + } args.add("-f", formatID) args.add("-o", Paths.get(app.config["storagePath"] as String, outputTemplate).toString()) args.add("url", url) diff --git a/src/main/kotlin/com/ingbyr/guiyouget/events/UpdatesEvents.kt b/src/main/kotlin/com/ingbyr/guiyouget/events/UpdatesEvents.kt index 06df9d6..fa968ed 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/events/UpdatesEvents.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/events/UpdatesEvents.kt @@ -2,16 +2,12 @@ package com.ingbyr.guiyouget.events import tornadofx.* -// common event -class UpdateStates(val status: String) : FXEvent() - // you-get updates object RequestCheckUpdatesYouGet : FXEvent(EventBus.RunOn.BackgroundThread) -object UpdateYouGet : FXEvent(EventBus.RunOn.BackgroundThread) +class UpdateYouGetStates(val status: String) : FXEvent() // you-get updates object RequestCheckUpdatesYoutubeDL : FXEvent(EventBus.RunOn.BackgroundThread) -object UpdateYoutubeDL : FXEvent(EventBus.RunOn.BackgroundThread) - +class UpdateYoutubeDLStates(val status: String) : FXEvent() \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt b/src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt index 5ef9f39..0b55e95 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/utils/CoreUtils.kt @@ -1,12 +1,29 @@ package com.ingbyr.guiyouget.utils object CoreUtils { - lateinit var current: String + var DOWNLOAD_CORE = "download-core" var REMOTE_CONF_URL = "https://raw.githubusercontent.com/ingbyr/GUI-YouGet/master/RemoteConf.json" - val YOUTUBE_DL = "YOUTUBE_DL" - val YOU_GET = "YOU_GET" + val YOUTUBE_DL = "youtube-dl" + val YOUTUBE_DL_VERSION = "youtube-dl-version" + val YOU_GET = "you-get" + val YOU_GET_VERSION = "you-get-version" - fun yougetUpdateURL(ver:String) = "https://github.com/soimort/you-get/releases/download/v$ver/you-get-$ver-win32.exe" + val PROXY_TYPE = "proxy-type" + val PROXY_ADDRESS = "proxy-address" + val PROXY_PORT = "proxy-port" + val PROXY_HTTP = "http" + val PROXY_SOCKS = "socks5" - fun youtubedlUpdateURL(ver:String) = "https://github.com/rg3/youtube-dl/releases/download/$ver/youtube-dl.exe" + val APP_VERSION = "version" + val APP_UPDATE_URL = "https://github.com/ingbyr/GUI-YouGet/releases/latest" + val APP_SOURCE_CODE = "https://github.com/ingbyr/GUI-YouGet" + val APP_LICENSE = "https://raw.githubusercontent.com/ingbyr/GUI-YouGet/master/LICENSE.txt" + val APP_AUTHOR = "http://www.ingbyr.com/" + val APP_AUTHOR_GITHUB = "https://github.com/ingbyr" + 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" + + fun youtubedlUpdateURL(ver: String) = "https://github.com/rg3/youtube-dl/releases/download/$ver/youtube-dl.exe" } \ No newline at end of file diff --git a/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt b/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt index c9e0d37..fd770fc 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/MainView.kt @@ -28,7 +28,6 @@ class MainView : View("GUI-YouGet") { private val tfURL: JFXTextField by fxid() private val labelStoragePath: Label by fxid() - private val labelCoreVersion: Label by fxid() private val labelVersion: Label by fxid() private val labelYoutubeDL: Label by fxid() private val labelYouGet: Label by fxid() @@ -44,6 +43,22 @@ class MainView : View("GUI-YouGet") { private val paneExit: Pane by fxid() private val apBorder: AnchorPane by fxid() + private val cbSocks5: JFXCheckBox by fxid() + private val tfSocksAddress: JFXTextField by fxid() + private val tfSocksPort: JFXTextField by fxid() + private val cbHTTP: JFXCheckBox by fxid() + private val tfHTTPAddress: JFXTextField by fxid() + private val tfHTTPPort: JFXTextField by fxid() + + private val labelAboutVersion: Label by fxid() + private val labelGitHub: Label by fxid() + private val labelLicense: Label by fxid() + private val labelAuthor: Label by fxid() + private val btnFollowMe: JFXButton by fxid() + private val btnReportBug: JFXButton by fxid() + private val btnDonate: JFXButton by fxid() + + init { // Window boarder primaryStage.initStyle(StageStyle.UNDECORATED) @@ -66,7 +81,7 @@ class MainView : View("GUI-YouGet") { } // Storage path - if (app.config["storagePath"] == null) { + if (app.config["storagePath"] == null || app.config["storagePath"] == "") { labelStoragePath.text = Paths.get(System.getProperty("user.dir")).toAbsolutePath().toString() app.config["storagePath"] = labelStoragePath.text app.config.save() @@ -92,33 +107,33 @@ class MainView : View("GUI-YouGet") { } // Load download core config - val core = app.config["core"] + val core = app.config[CoreUtils.DOWNLOAD_CORE] when (core) { CoreUtils.YOUTUBE_DL -> { cbYoutubeDL.isSelected = true - CoreUtils.current = CoreUtils.YOUTUBE_DL } CoreUtils.YOU_GET -> { cbYouGet.isSelected = true - CoreUtils.current = CoreUtils.YOU_GET } else -> { - app.config["core"] = CoreUtils.YOUTUBE_DL + app.config[CoreUtils.DOWNLOAD_CORE] = CoreUtils.YOUTUBE_DL app.config.save() cbYoutubeDL.isSelected = true - CoreUtils.current = CoreUtils.YOUTUBE_DL } } - // Load core version - labelYouGet.text = app.config["you-get-version"] as String - labelYoutubeDL.text = app.config["youtube-dl-version"] as String + // Init core version + labelYouGet.text = app.config[CoreUtils.YOU_GET_VERSION] as String + labelYoutubeDL.text = app.config[CoreUtils.YOUTUBE_DL_VERSION] as String + + // Init app version + labelVersion.text = app.config[CoreUtils.APP_VERSION] as String // Change download core cbYouGet.action { if (cbYouGet.isSelected) { cbYoutubeDL.isSelected = false - app.config["core"] = CoreUtils.YOU_GET + app.config[CoreUtils.DOWNLOAD_CORE] = CoreUtils.YOU_GET app.config.save() } } @@ -126,7 +141,7 @@ class MainView : View("GUI-YouGet") { cbYoutubeDL.action { if (cbYoutubeDL.isSelected) { cbYouGet.isSelected = false - app.config["core"] = CoreUtils.YOUTUBE_DL + app.config[CoreUtils.DOWNLOAD_CORE] = CoreUtils.YOUTUBE_DL app.config.save() } } @@ -141,6 +156,100 @@ class MainView : View("GUI-YouGet") { btnUpdate.setOnMouseClicked { controller.updateGUI() } + + // Proxy + val proxy = app.config[CoreUtils.PROXY_TYPE] + when (proxy) { + CoreUtils.PROXY_HTTP -> { + cbHTTP.isSelected = true + tfHTTPAddress.text = app.config[CoreUtils.PROXY_ADDRESS] as String + tfHTTPPort.text = app.config[CoreUtils.PROXY_PORT] as String + } + CoreUtils.PROXY_SOCKS -> { + cbSocks5.isSelected = true + tfSocksAddress.text = app.config[CoreUtils.PROXY_ADDRESS] as String + tfSocksPort.text = app.config[CoreUtils.PROXY_PORT] as String + } + else -> { + cbHTTP.isSelected = false + cbSocks5.isSelected = false + } + } + + tfSocksAddress.textProperty().addListener { _, _, newValue -> + if (app.config[CoreUtils.PROXY_TYPE] == CoreUtils.PROXY_SOCKS) { + app.config[CoreUtils.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 + app.config.save() + } + } + + tfHTTPAddress.textProperty().addListener { _, _, newValue -> + if (app.config[CoreUtils.PROXY_TYPE] == CoreUtils.PROXY_HTTP) { + app.config[CoreUtils.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 + app.config.save() + } + } + + cbSocks5.action { + val address = tfSocksAddress.text + val port = tfSocksPort.text + // Disable socks proxy + if (!cbSocks5.isSelected) { + app.config[CoreUtils.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.save() + } + } + + cbHTTP.action { + val address = tfHTTPAddress.text + val port = tfHTTPPort.text + // Disable http proxy + if (!cbHTTP.isSelected) { + app.config[CoreUtils.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.save() + } + } + + // About view + labelAboutVersion.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) } + btnFollowMe.action { hostServices.showDocument(CoreUtils.APP_AUTHOR_GITHUB) } + btnReportBug.action { hostServices.showDocument(CoreUtils.APP_REPORT_BUGS) } + btnDonate.action { hostServices.showDocument(CoreUtils.APP_DONATE) } } // 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 5dc4884..67e8b25 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/views/MediaListView.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/MediaListView.kt @@ -70,7 +70,7 @@ class MediaListView : View("GUI-YouGet") { val formatID = it.text.split(" ")[0] logger.debug("select format id is ${formatID}") ProgressView().openModal(StageStyle.UNDECORATED) - when (CoreUtils.current) { + when (app.config[CoreUtils.DOWNLOAD_CORE]) { CoreUtils.YOUTUBE_DL -> fire(DownloadingRequestWithYoutubeDL(url, formatID)) CoreUtils.YOU_GET -> fire(DownloadingRequestWithYouGet(url, formatID)) } diff --git a/src/main/kotlin/com/ingbyr/guiyouget/views/UpdatesWindow.kt b/src/main/kotlin/com/ingbyr/guiyouget/views/UpdatesWindow.kt index 2cecfad..d24df9b 100644 --- a/src/main/kotlin/com/ingbyr/guiyouget/views/UpdatesWindow.kt +++ b/src/main/kotlin/com/ingbyr/guiyouget/views/UpdatesWindow.kt @@ -2,7 +2,8 @@ package com.ingbyr.guiyouget.views import com.ingbyr.guiyouget.controllers.UpdatesController import com.ingbyr.guiyouget.events.StopDownloading -import com.ingbyr.guiyouget.events.UpdateStates +import com.ingbyr.guiyouget.events.UpdateYouGetStates +import com.ingbyr.guiyouget.events.UpdateYoutubeDLStates import javafx.scene.control.Label import javafx.scene.layout.AnchorPane import javafx.scene.layout.Pane @@ -12,7 +13,8 @@ class UpdatesWindow : View() { val controller: UpdatesController by inject() override val root: AnchorPane by fxml("/fxml/UpdatesWindow.fxml") - private val labelStatus: Label by fxid() + private val labelYouget: Label by fxid() + private val labelYoutubedl: Label by fxid() private val paneExit: Pane by fxid() init { @@ -23,8 +25,12 @@ class UpdatesWindow : View() { this.close() } - subscribe { - labelStatus.text = it.status + subscribe { + labelYouget.text = it.status + } + + subscribe { + labelYoutubedl.text = it.status } } } \ No newline at end of file diff --git a/src/main/resources/core/youtube-dl.exe.REMOVED.git-id b/src/main/resources/core/youtube-dl.exe.REMOVED.git-id deleted file mode 100644 index a733b1b..0000000 --- a/src/main/resources/core/youtube-dl.exe.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -65b7746b64a6db783a45d837fab2343da4e61a8e \ No newline at end of file diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index 99c21a7..611f4b2 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -7,6 +7,8 @@ + + @@ -60,7 +62,7 @@ -