Added TYTD Support

This commit is contained in:
Mike Nolan 2022-10-26 01:36:05 -05:00
parent 64679ca1ce
commit 7cda82b68a
5 changed files with 62 additions and 11 deletions

View File

@ -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'
])
}

View File

@ -11,6 +11,20 @@
@change="updateDownloadBehavior"
/>
</ft-flex-box>
<ft-flex-box
v-if="downloadBehavior === 'add'"
class="settingsFlexStart500px"
>
<ft-input
class="folderDisplay"
:placeholder="serverUrlPlaceholder"
:show-action-button="false"
:show-label="false"
:disabled="false"
:value="serverUrl"
@change="updateServerUrl"
/>
</ft-flex-box>
<ft-flex-box
v-if="downloadBehavior === 'download'"
class="settingsFlexStart500px"

View File

@ -8,6 +8,7 @@ import FtShareButton from '../ft-share-button/ft-share-button.vue'
import { MAIN_PROFILE_ID } from '../../../constants'
import i18n from '../../i18n/index'
import { openExternalLink, showToast } from '../../helpers/utils'
import { Notification } from 'electron'
export default Vue.extend({
name: 'WatchVideoInfo',
@ -179,17 +180,41 @@ export default Vue.extend({
},
downloadLinkOptions: function () {
return this.downloadLinks.map((download) => {
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,

View File

@ -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',

View File

@ -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!