From 7cda82b68a095d92a5e7d192305f2628601ba79a Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Wed, 26 Oct 2022 01:36:05 -0500 Subject: [PATCH] Added TYTD Support --- .../download-settings/download-settings.js | 15 +++++-- .../download-settings/download-settings.vue | 14 +++++++ .../watch-video-info/watch-video-info.js | 42 +++++++++++++++---- src/renderer/store/modules/settings.js | 1 + static/locales/en-US.yaml | 1 + 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/renderer/components/download-settings/download-settings.js b/src/renderer/components/download-settings/download-settings.js index 9e4faabc..b759db43 100644 --- a/src/renderer/components/download-settings/download-settings.js +++ b/src/renderer/components/download-settings/download-settings.js @@ -24,7 +24,8 @@ export default Vue.extend({ askForDownloadPath: false, downloadBehaviorValues: [ 'download', - 'open' + 'open', + 'add' ] } }, @@ -32,10 +33,17 @@ export default Vue.extend({ downloadPath: function() { return this.$store.getters.getDownloadFolderPath }, + serverUrlPlaceholder: function() { + return this.$t('Settings.Download Settings.Server Url') + }, + serverUrl: function() { + return this.$store.getters.getServerUrl + }, downloadBehaviorNames: function () { return [ this.$t('Settings.Download Settings.Download in app'), - this.$t('Settings.Download Settings.Open in web browser') + this.$t('Settings.Download Settings.Open in web browser'), + this.$t('Settings.Download Settings.Add To TYTD') ] }, downloadBehavior: function () { @@ -63,7 +71,8 @@ export default Vue.extend({ }, ...mapActions([ 'updateDownloadFolderPath', - 'updateDownloadBehavior' + 'updateDownloadBehavior', + 'updateServerUrl' ]) } diff --git a/src/renderer/components/download-settings/download-settings.vue b/src/renderer/components/download-settings/download-settings.vue index 1620a213..d86e9fe7 100644 --- a/src/renderer/components/download-settings/download-settings.vue +++ b/src/renderer/components/download-settings/download-settings.vue @@ -11,6 +11,20 @@ @change="updateDownloadBehavior" /> + + + { - return { - label: download.label, - value: download.url - } - }) + if (this.downloadBehavior === 'add') { + return [ + { + label: 'SD', + value: new URL(`api/AddVideoRes/1/${this.id}`, this.getServerUrl).toString() + }, + { + label: 'HD', + value: new URL(`api/AddVideoRes/0/${this.id}`, this.getServerUrl).toString() + }, + { + label: 'Audio Only', + value: new URL(`api/AddVideoRes/2/${this.id}`, this.getServerUrl).toString() + }, + { + label: 'Video Only', + value: new URL(`api/AddVideoRes/1/${this.id}`, this.getServerUrl).toString() + } + ] + } else { + return this.downloadLinks.map((download) => { + return { + label: download.label, + value: download.url + } + }) + } }, downloadBehavior: function () { return this.$store.getters.getDownloadBehavior }, + getServerUrl: function() { + return this.$store.getters.getServerUrl + }, formatTypeOptions: function () { return [ @@ -427,11 +452,12 @@ export default Vue.extend({ const selectedDownloadLinkOption = this.downloadLinkOptions[index] const url = selectedDownloadLinkOption.value const linkName = selectedDownloadLinkOption.label - const extension = this.grabExtensionFromUrl(linkName) - if (this.downloadBehavior === 'open') { openExternalLink(url) + } else if (this.downloadBehavior === 'add') { + fetch(url).then(e => e.text()).then(new Notification('Added to downloader')) } else { + const extension = this.grabExtensionFromUrl(linkName) this.downloadMedia({ url: url, title: this.title, diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 565035d6..d3337b48 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -264,6 +264,7 @@ const state = { videoPlaybackRateMouseScroll: false, videoPlaybackRateInterval: 0.25, downloadFolderPath: '', + serverUrl: 'http://127.0.0.1:3252/', downloadBehavior: 'download', enableScreenshot: false, screenshotFormat: 'png', diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 89ee7e2e..ea852989 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -406,6 +406,7 @@ Settings: Download Behavior: Download Behavior Download in app: Download in app Open in web browser: Open in web browser + Add To TYTD: Add To TYTD Experimental Settings: Experimental Settings: Experimental Settings Warning: These settings are experimental, they make cause crashes while enabled. Making backups is highly recommended. Use at your own risk!