Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Former-commit-id: d819e160587ce5b76d1c12703bec745b97dd65c2 [formerly 6fd3fdd]
Former-commit-id: 1d1949fead95325a0f09ed13e5a4a43439822482
  • Loading branch information
ingbyr committed Sep 26, 2017
2 parents e1b77c9 + 824bbc8 commit d12bea8
Show file tree
Hide file tree
Showing 27 changed files with 454 additions and 107 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ conf/
gradle/
gradlew
gradlew.bat
log/
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
==============================================
This is a copy of the MIT license.
==============================================
Copyright (C) 2016 InG_byr <zwkv587@gmail.com>
Copyright (C) 2016-2017 ingbyr <ingbyr@outlook.com>
Copyright (C) 2012, 2013, 2014, 2015, 2016 Mort Yao <mort.yao@gmail.com>
Copyright (C) 2012 Boyu Guo <iambus@gmail.com>

Expand Down
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 9 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.ingbyr.guiyouget'
version '1.0-SNAPSHOT'
version '0.2'

buildscript {
ext.kotlin_version = '1.1.50'
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions core/youtube-dl.exe.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
772ac2cc9a9eabd17bcb3d0c14d787d48dd5c941
Binary file added screenshot/download.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot/medias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +36,6 @@ class MainController : Controller() {


fun updateGUI() {

hostServices.showDocument(CoreUtils.APP_UPDATE_URL)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<DownloadingRequestWithYoutubeDL> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
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<RequestCheckUpdatesYouGet> {
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
}
}

subscribe<RequestCheckUpdatesYoutubeDL> {
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
Expand All @@ -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")
}
}
}

}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/ingbyr/guiyouget/core/CoreArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>()
private val logger = LoggerFactory.getLogger(CoreArgs::class.java)
private val argsMap = mutableMapOf<String, String>()


fun add(key: String, value: String) {
Expand Down
40 changes: 32 additions & 8 deletions src/main/kotlin/com/ingbyr/guiyouget/core/OkHttpController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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()
Expand All @@ -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())
}

Expand All @@ -74,13 +85,26 @@ 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) {
logger.error(e.toString())

}

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()
}
}
}
28 changes: 25 additions & 3 deletions src/main/kotlin/com/ingbyr/guiyouget/core/YouGet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand All @@ -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
}
Expand All @@ -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)
Expand Down
Loading

0 comments on commit d12bea8

Please sign in to comment.