[Media UI] Download Audio support.

This commit is contained in:
Fabio Manganiello 2024-07-16 03:48:45 +02:00
parent 5ebdb381f1
commit b44bd0be32
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
11 changed files with 40 additions and 9 deletions

View file

@ -28,6 +28,7 @@
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@back="back" @back="back"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@path-change="$emit('path-change', $event)" @path-change="$emit('path-change', $event)"
@play="$emit('play', $event)" @play="$emit('play', $event)"
/> />
@ -50,6 +51,7 @@ export default {
'back', 'back',
'create-playlist', 'create-playlist',
'download', 'download',
'download-audio',
'path-change', 'path-change',
'play', 'play',
'remove-from-playlist', 'remove-from-playlist',

View file

@ -60,6 +60,7 @@
@play="play" @play="play"
@view="view" @view="view"
@download="download" @download="download"
@download-audio="downloadAudio"
v-if="selectedView === 'search'" v-if="selectedView === 'search'"
/> />
@ -82,6 +83,7 @@
@add-to-playlist="addToPlaylistItem = $event" @add-to-playlist="addToPlaylistItem = $event"
@back="selectedResult = null" @back="selectedResult = null"
@download="download" @download="download"
@download-audio="downloadAudio"
@path-change="browserFilter = ''" @path-change="browserFilter = ''"
@play="play($event)" @play="play($event)"
v-else-if="selectedView === 'browser'" v-else-if="selectedView === 'browser'"
@ -344,15 +346,19 @@ export default {
window.open(ret.url, '_blank') window.open(ret.url, '_blank')
}, },
async download(item) { async download(item, args) {
switch (item.type) { switch (item.type) {
case 'torrent': case 'torrent':
return await this.downloadTorrent(item) return await this.downloadTorrent(item, args)
case 'youtube': case 'youtube':
return await this.downloadYoutube(item) return await this.downloadYoutube(item, args)
} }
}, },
async downloadAudio(item) {
await this.download(item, {onlyAudio: true})
},
async refresh() { async refresh() {
this.selectedPlayer.status = await this.selectedPlayer.component.status(this.selectedPlayer) this.selectedPlayer.status = await this.selectedPlayer.component.status(this.selectedPlayer)
}, },
@ -454,7 +460,7 @@ export default {
return await this.request(`${torrentPlugin}.download`, {torrent: item.url || item}) return await this.request(`${torrentPlugin}.download`, {torrent: item.url || item})
}, },
async downloadYoutube(item) { async downloadYoutube(item, args) {
if (!item?.url) { if (!item?.url) {
this.notify({ this.notify({
text: 'No YouTube URL available', text: 'No YouTube URL available',
@ -464,10 +470,13 @@ export default {
return return
} }
await this.request( const requestArgs = {url: item.url}
`${this.pluginName}.download`, const onlyAudio = !!args?.onlyAudio
{url: item.url}, if (onlyAudio) {
) requestArgs.only_audio = true
}
await this.request(`${this.pluginName}.download`, requestArgs)
}, },
async selectSubtitles(item) { async selectSubtitles(item) {

View file

@ -17,6 +17,8 @@
v-if="item.type !== 'torrent'" /> v-if="item.type !== 'torrent'" />
<DropdownItem icon-class="fa fa-download" text="Download" @click="$emit('download')" <DropdownItem icon-class="fa fa-download" text="Download" @click="$emit('download')"
v-if="(item.type === 'torrent' || item.type === 'youtube') && item.item_type !== 'channel' && item.item_type !== 'playlist'" /> v-if="(item.type === 'torrent' || item.type === 'youtube') && item.item_type !== 'channel' && item.item_type !== 'playlist'" />
<DropdownItem icon-class="fa fa-volume-high" text="Download Audio" @click="$emit('download-audio')"
v-if="item.type === 'youtube' && item.item_type !== 'channel' && item.item_type !== 'playlist'" />
<DropdownItem icon-class="fa fa-list" text="Add to playlist" @click="$emit('add-to-playlist')" <DropdownItem icon-class="fa fa-list" text="Add to playlist" @click="$emit('add-to-playlist')"
v-if="item.type === 'youtube'" /> v-if="item.type === 'youtube'" />
<DropdownItem icon-class="fa fa-trash" text="Remove from playlist" @click="$emit('remove-from-playlist')" <DropdownItem icon-class="fa fa-trash" text="Remove from playlist" @click="$emit('remove-from-playlist')"
@ -55,6 +57,7 @@ export default {
emits: [ emits: [
'add-to-playlist', 'add-to-playlist',
'download', 'download',
'download-audio',
'open-channel', 'open-channel',
'play', 'play',
'remove-from-playlist', 'remove-from-playlist',

View file

@ -8,6 +8,7 @@ export default {
'back', 'back',
'create-playlist', 'create-playlist',
'download', 'download',
'download-audio',
'path-change', 'path-change',
'play', 'play',
'remove-from-playlist', 'remove-from-playlist',

View file

@ -10,6 +10,7 @@
<Feed :filter="filter" <Feed :filter="filter"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@open-channel="selectChannelFromItem" @open-channel="selectChannelFromItem"
@play="$emit('play', $event)" @play="$emit('play', $event)"
v-if="selectedView === 'feed'" v-if="selectedView === 'feed'"
@ -19,6 +20,7 @@
:selected-playlist="selectedPlaylist_" :selected-playlist="selectedPlaylist_"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@open-channel="selectChannelFromItem" @open-channel="selectChannelFromItem"
@play="$emit('play', $event)" @play="$emit('play', $event)"
@remove-from-playlist="removeFromPlaylist" @remove-from-playlist="removeFromPlaylist"
@ -30,6 +32,7 @@
:selected-channel="selectedChannel_" :selected-channel="selectedChannel_"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@play="$emit('play', $event)" @play="$emit('play', $event)"
@select="onChannelSelected" @select="onChannelSelected"
v-else-if="selectedView === 'subscriptions'" v-else-if="selectedView === 'subscriptions'"

View file

@ -48,6 +48,7 @@
ref="results" ref="results"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@open-channel="$emit('open-channel', $event)" @open-channel="$emit('open-channel', $event)"
@play="$emit('play', $event)" @play="$emit('play', $event)"
@scroll-end="loadNextPage" @scroll-end="loadNextPage"
@ -67,6 +68,7 @@ export default {
emits: [ emits: [
'add-to-playlist', 'add-to-playlist',
'download', 'download',
'download-audio',
'open-channel', 'open-channel',
'play', 'play',
], ],

View file

@ -11,6 +11,7 @@
:selected-result="selectedResult" :selected-result="selectedResult"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@open-channel="$emit('open-channel', $event)" @open-channel="$emit('open-channel', $event)"
@select="selectedResult = $event" @select="selectedResult = $event"
@play="$emit('play', $event)" @play="$emit('play', $event)"
@ -29,6 +30,7 @@ export default {
emits: [ emits: [
'add-to-playlist', 'add-to-playlist',
'download', 'download',
'download-audio',
'open-channel', 'open-channel',
'play', 'play',
], ],

View file

@ -51,6 +51,7 @@
:selected-result="selectedResult" :selected-result="selectedResult"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@open-channel="$emit('open-channel', $event)" @open-channel="$emit('open-channel', $event)"
@play="$emit('play', $event)" @play="$emit('play', $event)"
@remove-from-playlist="$emit('remove-from-playlist', $event)" @remove-from-playlist="$emit('remove-from-playlist', $event)"
@ -71,6 +72,7 @@ export default {
emits: [ emits: [
'add-to-playlist', 'add-to-playlist',
'download', 'download',
'download-audio',
'open-channel', 'open-channel',
'play', 'play',
'remove-from-playlist', 'remove-from-playlist',

View file

@ -32,6 +32,7 @@
:metadata="playlistsById[selectedPlaylist.id] || selectedPlaylist" :metadata="playlistsById[selectedPlaylist.id] || selectedPlaylist"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@open-channel="$emit('open-channel', $event)" @open-channel="$emit('open-channel', $event)"
@remove-from-playlist="$emit('remove-from-playlist', {item: $event, playlist_id: selectedPlaylist.id})" @remove-from-playlist="$emit('remove-from-playlist', {item: $event, playlist_id: selectedPlaylist.id})"
@play="$emit('play', $event)" @play="$emit('play', $event)"
@ -113,6 +114,7 @@ export default {
'add-to-playlist', 'add-to-playlist',
'create-playlist', 'create-playlist',
'download', 'download',
'download-audio',
'open-channel', 'open-channel',
'play', 'play',
'remove-from-playlist', 'remove-from-playlist',

View file

@ -25,6 +25,7 @@
:filter="filter" :filter="filter"
@add-to-playlist="$emit('add-to-playlist', $event)" @add-to-playlist="$emit('add-to-playlist', $event)"
@download="$emit('download', $event)" @download="$emit('download', $event)"
@download-audio="$emit('download-audio', $event)"
@play="$emit('play', $event)" @play="$emit('play', $event)"
/> />
</div> </div>
@ -42,6 +43,7 @@ export default {
emits: [ emits: [
'add-to-playlist', 'add-to-playlist',
'download', 'download',
'download-audio',
'play', 'play',
'select', 'select',
], ],

View file

@ -14,7 +14,9 @@
@select="$emit('select', i)" @select="$emit('select', i)"
@play="$emit('play', item)" @play="$emit('play', item)"
@view="$emit('view', item)" @view="$emit('view', item)"
@download="$emit('download', item)" /> @download="$emit('download', item)"
@download-audio="$emit('download-audio', item)"
/>
</div> </div>
<Modal ref="infoModal" title="Media info" @close="$emit('select', null)"> <Modal ref="infoModal" title="Media info" @close="$emit('select', null)">
@ -37,6 +39,7 @@ export default {
emits: [ emits: [
'add-to-playlist', 'add-to-playlist',
'download', 'download',
'download-audio',
'open-channel', 'open-channel',
'play', 'play',
'remove-from-playlist', 'remove-from-playlist',