fixed double ext and playlist title detection (#106)
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
|||||||
FC,
|
FC,
|
||||||
Suspense,
|
Suspense,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
@@ -92,6 +93,10 @@ const DownloadDialog: FC<Props> = ({ open, onClose, onDownloadStart }) => {
|
|||||||
|
|
||||||
const [isPending, startTransition] = useTransition()
|
const [isPending, startTransition] = useTransition()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCustomArgs('')
|
||||||
|
}, [open])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrive url from input, cli-arguments from checkboxes and emits via WebSocket
|
* Retrive url from input, cli-arguments from checkboxes and emits via WebSocket
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/marcopeocchi/yt-dlp-web-ui/server/cli"
|
"github.com/marcopeocchi/yt-dlp-web-ui/server/cli"
|
||||||
@@ -12,9 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type metadata struct {
|
type metadata struct {
|
||||||
Entries []DownloadInfo `json:"entries"`
|
Entries []DownloadInfo `json:"entries"`
|
||||||
Count int `json:"playlist_count"`
|
Count int `json:"playlist_count"`
|
||||||
Type string `json:"_type"`
|
PlaylistTitle string `json:"title"`
|
||||||
|
Type string `json:"_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
|
func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
|
||||||
@@ -57,6 +59,15 @@ func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
|
|||||||
for i, meta := range m.Entries {
|
for i, meta := range m.Entries {
|
||||||
delta := time.Second.Microseconds() * int64(i+1)
|
delta := time.Second.Microseconds() * int64(i+1)
|
||||||
|
|
||||||
|
// detect playlist title from metadata since each playlist entry will be
|
||||||
|
// treated as an individual download
|
||||||
|
req.Rename = strings.Replace(
|
||||||
|
req.Rename,
|
||||||
|
"%(playlist_title)s",
|
||||||
|
m.PlaylistTitle,
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
proc := &Process{
|
proc := &Process{
|
||||||
Url: meta.OriginalURL,
|
Url: meta.OriginalURL,
|
||||||
Progress: DownloadProgress{},
|
Progress: DownloadProgress{},
|
||||||
|
|||||||
@@ -84,9 +84,11 @@ func (p *Process) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.Output.Filename != "" {
|
if p.Output.Filename != "" {
|
||||||
out.Filename = p.Output.Filename + ".%(ext)s"
|
out.Filename = p.Output.Filename
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildFilename(&p.Output)
|
||||||
|
|
||||||
params := append([]string{
|
params := append([]string{
|
||||||
strings.Split(p.Url, "?list")[0], //no playlist
|
strings.Split(p.Url, "?list")[0], //no playlist
|
||||||
"--newline",
|
"--newline",
|
||||||
@@ -298,3 +300,16 @@ func (p *Process) SetMetadata() error {
|
|||||||
func (p *Process) getShortId() string {
|
func (p *Process) getShortId() string {
|
||||||
return strings.Split(p.Id, "-")[0]
|
return strings.Split(p.Id, "-")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func buildFilename(o *DownloadOutput) {
|
||||||
|
if o.Filename != "" && strings.Contains(o.Filename, ".%(ext)s") {
|
||||||
|
o.Filename += ".%(ext)s"
|
||||||
|
}
|
||||||
|
|
||||||
|
o.Filename = strings.Replace(
|
||||||
|
o.Filename,
|
||||||
|
".%(ext)s.%(ext)s",
|
||||||
|
".%(ext)s",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user