Skip to content

Commit

Permalink
feat(addons): Add qbit Enhanced edition support (VueTorrent#1718)
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsluph authored Jun 6, 2024
1 parent d26236b commit d273ab8
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Checkout the [wiki](https://github.com/VueTorrent/VueTorrent/wiki/Installation)!
- Additional backend for improved experience, [see the repo for more info](https://github.com/VueTorrent/vuetorrent-backend)
- This is a work in progress, and is not required to use VueTorrent
- Stores server-side settings
- Supports [qBittorrent Enhanced Edition](https://github.com/c0re100/qBittorrent-Enhanced-Edition) preferences

## Important Information

Expand Down
51 changes: 51 additions & 0 deletions src/components/Settings/addons/EnhancedEdition.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<script setup lang="ts">
import { usePreferenceStore } from '@/stores'
import { EnhancedAppPreferences } from '@/types/qbit/models/AppPreferences'
import { computed } from 'vue'
const preferenceStore = usePreferenceStore()
const preferences = computed({
get: () => preferenceStore.preferences as EnhancedAppPreferences,
set: v => preferenceStore.preferences = v
})
</script>

<template>
<v-list>
<v-list-item>
<v-checkbox v-model="preferences.auto_ban_bt_player_peer" hide-details :label="$t('settings.addons.enhanced_edition.auto_ban_bt_player_peer')" />
</v-list-item>

<v-list-item>
<v-checkbox v-model="preferences.auto_ban_unknown_peer" hide-details :label="$t('settings.addons.enhanced_edition.auto_ban_unknown_peer')" />
</v-list-item>

<v-list-item>
<v-checkbox v-model="preferences.auto_update_trackers_enabled" hide-details :label="$t('settings.addons.enhanced_edition.auto_update_trackers')" />
</v-list-item>

<v-list-item>
<v-text-field
v-model="preferences.customize_trackers_list_url"
:disabled="!preferences.auto_update_trackers_enabled"
hide-details
:label="$t('settings.addons.enhanced_edition.trackers_list_url')"
/>
</v-list-item>

<v-list-item>
<v-textarea
v-model="preferences.public_trackers"
disabled
auto-grow
persistent-hint
:hint="$t('settings.bittorrent.autoAddTrackersHint')"
:label="$t('settings.addons.enhanced_edition.public_trackers')" />
</v-list-item>
</v-list>
</template>

<style scoped>
</style>
12 changes: 12 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,15 @@
"title": "Search engine"
},
"settings": {
"addons": {
"enhanced_edition": {
"auto_ban_bt_player_peer": "Auto ban BT player peer",
"auto_ban_unknown_peer": "Auto ban unknown peer",
"auto_update_trackers": "Automatically update public trackers list",
"trackers_list_url": "Customize Trackers URL List",
"public_trackers": "Public trackers"
}
},
"advanced": {
"libtorrent": {
"announceAllTiers": "Always announce to all tiers",
Expand Down Expand Up @@ -928,6 +937,9 @@
"upload": "Upload"
},
"tabs": {
"addons": {
"enhanced_edition": "Enhanced edition"
},
"advanced": "Advanced",
"behavior": "Behavior",
"bittorrent": "BitTorrent",
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Settings.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import EnhancedEdition from '@/components/Settings/addons/EnhancedEdition.vue'
import Advanced from '@/components/Settings/Advanced.vue'
import Behavior from '@/components/Settings/Behavior.vue'
import BitTorrent from '@/components/Settings/BitTorrent.vue'
Expand All @@ -14,7 +15,7 @@ import VTorrentCardTable from '@/components/Settings/VueTorrent/TorrentCard/Tabl
import WebUI from '@/components/Settings/WebUI.vue'
import { backend } from '@/services/backend'
import { useDialogStore, usePreferenceStore, useVueTorrentStore } from '@/stores'
import { onBeforeUnmount, onMounted, ref, watchEffect } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, watchEffect } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import { toast } from 'vue3-toastify'
Expand Down Expand Up @@ -48,6 +49,8 @@ const tabsV = [
const tab = ref('vuetorrent')
const innerTabV = ref('general')
const isEnhancedEdition = computed(() => preferenceStore.preferences && Object.keys(preferenceStore.preferences).includes('public_trackers'))
const saveSettings = async () => {
await preferenceStore.setPreferences()
toast.success(t('settings.saveSuccess'))
Expand Down Expand Up @@ -132,11 +135,16 @@ onBeforeUnmount(() => {

<v-row class="ma-0 pa-0">
<v-tabs v-model="tab" bg-color="primary" grow show-arrows>
<v-tab v-if="isEnhancedEdition" value="enhancedEdition" href="#/settings/enhancedEdition" :text="$t('settings.tabs.addons.enhanced_edition')" />
<v-tab v-for="{ text, value } in tabs" :key="value" :value="value" :href="`#/settings/${value}`" :text="text" />
</v-tabs>
</v-row>

<v-window v-model="tab" :touch="false">
<v-window-item value="enhancedEdition">
<EnhancedEdition />
</v-window-item>

<v-window-item value="vuetorrent">
<v-tabs v-model="innerTabV" grow color="accent" show-arrows>
<v-tab v-for="{ text, value } in tabsV" :value="value" :text="text" :href="`#/settings/vuetorrent/${value}`" :class="{ 'text-accent': innerTabV === value }" />
Expand Down
10 changes: 9 additions & 1 deletion src/services/qbit/MockProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ export default class MockProvider implements IProvider {
async getPreferences(): Promise<AppPreferences> {
return this.generateResponse({
result: {
// Enhanced edition
// auto_ban_bt_player_peer: true,
// auto_ban_unknown_peer: true,
// auto_update_trackers_enabled: true,
// customize_trackers_list_url: 'http://example.com/',
// public_trackers: 'http://example.com/\nhttp://example.com/',

add_to_top_of_queue: false,
add_trackers: '',
add_trackers_enabled: false,
alt_dl_limit: 10240,
alt_up_limit: 10240,
alternative_webui_enabled: false,
alternative_webui_enabled: true,
alternative_webui_path: '/vuetorrent',
announce_ip: '',
announce_to_all_tiers: true,
Expand Down Expand Up @@ -266,6 +273,7 @@ export default class MockProvider implements IProvider {
}

async setPreferences(_: AppPreferencesPayload): Promise<void> {
console.log(_)
return this.generateResponse({ shouldResolve: true })
}

Expand Down
9 changes: 9 additions & 0 deletions src/types/qbit/models/AppPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,12 @@ export default interface AppPreferences {
/** WebUI username */
web_ui_username: string
}

/** Preferences extension from Enhanced qBittorrent edition */
export interface EnhancedAppPreferences extends AppPreferences {
auto_ban_bt_player_peer: boolean
auto_ban_unknown_peer: boolean
auto_update_trackers_enabled: boolean
customize_trackers_list_url: string
readonly public_trackers: string
}

0 comments on commit d273ab8

Please sign in to comment.