Create m3u playlist by selecting files.
This commit is contained in:
parent
793d044004
commit
f2bee540c3
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@ _old
|
||||
rice-box.go
|
||||
.idea/
|
||||
filebrowser
|
||||
filebrowser.exe
|
||||
dist/
|
||||
|
||||
.DS_Store
|
||||
|
||||
5
frontend/package-lock.json
generated
5
frontend/package-lock.json
generated
@ -6524,6 +6524,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"file-saver": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
|
||||
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
|
||||
},
|
||||
"filesize": {
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz",
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"ace-builds": "^1.4.7",
|
||||
"clipboard": "^2.0.4",
|
||||
"file-saver": "^2.0.5",
|
||||
"js-base64": "^2.5.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lodash.throttle": "^4.1.1",
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
<!-- Menu that shows on listing AND mobile when there are files selected -->
|
||||
<div id="file-selection" v-if="isMobile && isListing && !isSharing">
|
||||
<span v-if="selectedCount > 0">{{ selectedCount }} selected</span>
|
||||
<playlist-button v-show="showPlaylistButton"></playlist-button>
|
||||
<share-button v-show="showShareButton"></share-button>
|
||||
<rename-button v-show="showRenameButton"></rename-button>
|
||||
<copy-button v-show="showCopyButton"></copy-button>
|
||||
@ -30,6 +31,7 @@
|
||||
<!-- This buttons are shown on a dropdown on mobile phones -->
|
||||
<div id="dropdown" :class="{ active: showMore }">
|
||||
<div v-if="!isListing || !isMobile">
|
||||
<playlist-button v-show="showPlaylistButton"></playlist-button>
|
||||
<share-button v-show="showShareButton"></share-button>
|
||||
<rename-button v-show="showRenameButton"></rename-button>
|
||||
<copy-button v-show="showCopyButton"></copy-button>
|
||||
@ -67,6 +69,8 @@ import MoveButton from './buttons/Move'
|
||||
import CopyButton from './buttons/Copy'
|
||||
import ShareButton from './buttons/Share'
|
||||
import ShellButton from './buttons/Shell'
|
||||
import PlaylistButton from './buttons/Playlist'
|
||||
|
||||
import {mapGetters, mapState} from 'vuex'
|
||||
import { logoURL, enableExec } from '@/utils/constants'
|
||||
import * as api from '@/api'
|
||||
@ -85,7 +89,8 @@ export default {
|
||||
UploadButton,
|
||||
SwitchButton,
|
||||
MoveButton,
|
||||
ShellButton
|
||||
ShellButton,
|
||||
PlaylistButton
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
@ -151,6 +156,9 @@ export default {
|
||||
? (this.selectedCount > 0 && this.user.perm.rename)
|
||||
: this.user.perm.rename)
|
||||
},
|
||||
showPlaylistButton () {
|
||||
return this.selectedCount > 0
|
||||
},
|
||||
showCopyButton () {
|
||||
return this.isFiles && (this.isListing
|
||||
? (this.selectedCount > 0 && this.user.perm.create)
|
||||
|
||||
41
frontend/src/components/buttons/Playlist.vue
Normal file
41
frontend/src/components/buttons/Playlist.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<button @click="getPlaylist" :aria-label="$t('buttons.playlist')" :title="$t('buttons.playlist')" class="action">
|
||||
<i class="material-icons">playlist_play</i>
|
||||
<span>{{ $t('buttons.playlist') }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { saveAs } from 'file-saver'
|
||||
import { mapState } from 'vuex'
|
||||
import { baseURL } from '@/utils/constants'
|
||||
import url from '@/utils/url'
|
||||
|
||||
export default {
|
||||
name: 'playlist-button',
|
||||
computed: {
|
||||
...mapState([ 'req', 'selected', 'selectedCount', 'jwt', ]),
|
||||
},
|
||||
methods: {
|
||||
raw (fileUrl) {
|
||||
return `${baseURL}/api/raw${url.encodePath(fileUrl)}?auth=${this.jwt}&inline=true`
|
||||
},
|
||||
getPlaylist () {
|
||||
const { protocol, hostname, port } = window.location
|
||||
let host = `${protocol}//${hostname}`
|
||||
if (port) host = `${host}:${port}`
|
||||
|
||||
const validTypes = ['video', 'audio']
|
||||
console.log(this.req.items)
|
||||
// constraint to video & audio files remove any folders
|
||||
const files = this.selected.map((i) => this.req.items[i]).filter((v) => validTypes.indexOf(v.type) !== -1 && !v.isDir)
|
||||
console.log(files)
|
||||
if (files.length === 0) return
|
||||
|
||||
const urls = files.map((v) => `${host}${this.raw(v.path)}\n`)
|
||||
var blob = new Blob(["#EXTM3U\n", ...urls], {type: "text/plain;charset=utf-8"})
|
||||
saveAs(blob, "playlist.m3u")
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -108,14 +108,17 @@ export default {
|
||||
hasNext () {
|
||||
return (this.nextLink !== '')
|
||||
},
|
||||
authPath () {
|
||||
return `${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||
},
|
||||
download () {
|
||||
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||
return `${baseURL}/api/raw${this.authPath}`
|
||||
},
|
||||
previewUrl () {
|
||||
if (this.req.type === 'image' && !this.fullSize) {
|
||||
return `${baseURL}/api/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||
return `${baseURL}/api/preview/big${this.authPath}`
|
||||
}
|
||||
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
|
||||
return `${baseURL}/api/raw${this.authPath}`
|
||||
},
|
||||
raw () {
|
||||
return `${this.previewUrl}&inline=true`
|
||||
|
||||
@ -32,7 +32,8 @@
|
||||
"switchView": "Switch view",
|
||||
"toggleSidebar": "Toggle sidebar",
|
||||
"update": "Update",
|
||||
"upload": "Upload"
|
||||
"upload": "Upload",
|
||||
"playlist": "Playlist"
|
||||
},
|
||||
"download": {
|
||||
"downloadFile": "Download File",
|
||||
|
||||
@ -32,7 +32,8 @@
|
||||
"switchView": "Changer le mode d'affichage",
|
||||
"toggleSidebar": "Afficher/Masquer la barre latérale",
|
||||
"update": "Mettre à jour",
|
||||
"upload": "Importer"
|
||||
"upload": "Importer",
|
||||
"playlist": "Liste de lecture"
|
||||
},
|
||||
"download": {
|
||||
"downloadFile": "Download File",
|
||||
|
||||
145
get.sh
145
get.sh
@ -1,145 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# File Browser Installer Script
|
||||
#
|
||||
# GitHub: https://github.com/filebrowser/filebrowser
|
||||
# Issues: https://github.com/filebrowser/filebrowser/issues
|
||||
# Requires: bash, mv, rm, tr, type, grep, sed, curl/wget, tar (or unzip on OSX and Windows)
|
||||
#
|
||||
# This script installs File Browser to your path.
|
||||
# Usage:
|
||||
#
|
||||
# $ curl -fsSL https://filebrowser.xyz/get.sh | bash
|
||||
# or
|
||||
# $ wget -qO- https://filebrowser.xyz/get.sh | bash
|
||||
#
|
||||
# In automated environments, you may want to run as root.
|
||||
# If using curl, we recommend using the -fsSL flags.
|
||||
#
|
||||
# This should work on Mac, Linux, and BSD systems, and
|
||||
# hopefully Windows with Cygwin. Please open an issue if
|
||||
# you notice any bugs.
|
||||
#
|
||||
|
||||
install_filemanager()
|
||||
{
|
||||
trap 'echo -e "Aborted, error $? in command: $BASH_COMMAND"; trap ERR; return 1' ERR
|
||||
filemanager_os="unsupported"
|
||||
filemanager_arch="unknown"
|
||||
install_path="/usr/local/bin"
|
||||
repo_name="g45t345rt"
|
||||
|
||||
# Termux on Android has $PREFIX set which already ends with /usr
|
||||
if [[ -n "$ANDROID_ROOT" && -n "$PREFIX" ]]; then
|
||||
install_path="$PREFIX/bin"
|
||||
fi
|
||||
|
||||
# Fall back to /usr/bin if necessary
|
||||
if [[ ! -d $install_path ]]; then
|
||||
install_path="/usr/bin"
|
||||
fi
|
||||
|
||||
# Not every platform has or needs sudo (https://termux.com/linux.html)
|
||||
((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo"
|
||||
|
||||
#########################
|
||||
# Which OS and version? #
|
||||
#########################
|
||||
|
||||
filemanager_bin="filebrowser"
|
||||
filemanager_dl_ext=".tar.gz"
|
||||
|
||||
# NOTE: `uname -m` is more accurate and universal than `arch`
|
||||
# See https://en.wikipedia.org/wiki/Uname
|
||||
unamem="$(uname -m)"
|
||||
case $unamem in
|
||||
*aarch64*)
|
||||
filemanager_arch="arm64";;
|
||||
*64*)
|
||||
filemanager_arch="amd64";;
|
||||
*86*)
|
||||
filemanager_arch="386";;
|
||||
*armv5*)
|
||||
filemanager_arch="armv5";;
|
||||
*armv6*)
|
||||
filemanager_arch="armv6";;
|
||||
*armv7*)
|
||||
filemanager_arch="armv7";;
|
||||
*)
|
||||
echo "Aborted, unsupported or unknown architecture: $unamem"
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
|
||||
unameu="$(tr '[:lower:]' '[:upper:]' <<<$(uname))"
|
||||
if [[ $unameu == *DARWIN* ]]; then
|
||||
filemanager_os="darwin"
|
||||
elif [[ $unameu == *LINUX* ]]; then
|
||||
filemanager_os="linux"
|
||||
elif [[ $unameu == *FREEBSD* ]]; then
|
||||
filemanager_os="freebsd"
|
||||
elif [[ $unameu == *NETBSD* ]]; then
|
||||
filemanager_os="netbsd"
|
||||
elif [[ $unameu == *OPENBSD* ]]; then
|
||||
filemanager_os="openbsd"
|
||||
elif [[ $unameu == *WIN* || $unameu == MSYS* ]]; then
|
||||
# Should catch cygwin
|
||||
sudo_cmd=""
|
||||
filemanager_os="windows"
|
||||
filemanager_bin="filebrowser.exe"
|
||||
filemanager_dl_ext=".zip"
|
||||
else
|
||||
echo "Aborted, unsupported or unknown OS: $uname"
|
||||
return 6
|
||||
fi
|
||||
|
||||
########################
|
||||
# Download and extract #
|
||||
########################
|
||||
|
||||
echo "Downloading File Browser for $filemanager_os/$filemanager_arch..."
|
||||
if type -p curl >/dev/null 2>&1; then
|
||||
net_getter="curl -fsSL"
|
||||
elif type -p wget >/dev/null 2>&1; then
|
||||
net_getter="wget -qO-"
|
||||
else
|
||||
echo "Aborted, could not find curl or wget"
|
||||
return 7
|
||||
fi
|
||||
|
||||
filemanager_file="${filemanager_os}-$filemanager_arch-filebrowser$filemanager_dl_ext"
|
||||
filemanager_tag="$(${net_getter} https://api.github.com/repos/$repo_name/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g')"
|
||||
filemanager_url="https://github.com/$repo_name/filebrowser/releases/download/$filemanager_tag/$filemanager_file"
|
||||
echo "$filemanager_url"
|
||||
|
||||
# Use $PREFIX for compatibility with Termux on Android
|
||||
rm -rf "$PREFIX/tmp/$filemanager_file"
|
||||
|
||||
${net_getter} "$filemanager_url" > "$PREFIX/tmp/$filemanager_file"
|
||||
|
||||
echo "Extracting..."
|
||||
case "$filemanager_file" in
|
||||
*.zip) unzip -o "$PREFIX/tmp/$filemanager_file" "$filemanager_bin" -d "$PREFIX/tmp/" ;;
|
||||
*.tar.gz) tar -xzf "$PREFIX/tmp/$filemanager_file" -C "$PREFIX/tmp/" "$filemanager_bin" ;;
|
||||
esac
|
||||
chmod +x "$PREFIX/tmp/$filemanager_bin"
|
||||
|
||||
echo "Putting filemanager in $install_path (may require password)"
|
||||
$sudo_cmd mv "$PREFIX/tmp/$filemanager_bin" "$install_path/$filemanager_bin"
|
||||
if setcap_cmd=$(PATH+=$PATH:/sbin type -p setcap); then
|
||||
$sudo_cmd $setcap_cmd cap_net_bind_service=+ep "$install_path/$filemanager_bin"
|
||||
fi
|
||||
$sudo_cmd rm -- "$PREFIX/tmp/$filemanager_file"
|
||||
|
||||
if type -p $filemanager_bin >/dev/null 2>&1; then
|
||||
echo "Successfully installed"
|
||||
trap ERR
|
||||
return 0
|
||||
else
|
||||
echo "Something went wrong, File Browser is not in your path"
|
||||
trap ERR
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_filemanager
|
||||
Loading…
Reference in New Issue
Block a user