code refactoring, fixed playlist downloads sorting
This commit is contained in:
@@ -31,7 +31,7 @@ import {
|
||||
useState,
|
||||
useTransition
|
||||
} from 'react'
|
||||
import { useRecoilValue } from 'recoil'
|
||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||
import { settingsState } from '../atoms/settings'
|
||||
import { availableDownloadPathsState, connectedState } from '../atoms/status'
|
||||
import FormatsGrid from '../components/FormatsGrid'
|
||||
@@ -40,6 +40,7 @@ import { useRPC } from '../hooks/useRPC'
|
||||
import { CliArguments } from '../lib/argsParser'
|
||||
import type { DLMetadata } from '../types'
|
||||
import { isValidURL, toFormatArgs } from '../utils'
|
||||
import { downloadTemplateState } from '../atoms/downloadTemplate'
|
||||
|
||||
const Transition = forwardRef(function Transition(
|
||||
props: TransitionProps & {
|
||||
@@ -72,7 +73,7 @@ export default function DownloadDialog({
|
||||
const [pickedAudioFormat, setPickedAudioFormat] = useState('')
|
||||
const [pickedBestFormat, setPickedBestFormat] = useState('')
|
||||
|
||||
const [customArgs, setCustomArgs] = useState(localStorage.getItem("last-input-args")||'')
|
||||
const [customArgs, setCustomArgs] = useRecoilState(downloadTemplateState)
|
||||
const [downloadPath, setDownloadPath] = useState(0)
|
||||
|
||||
const [fileNameOverride, setFilenameOverride] = useState('')
|
||||
|
||||
@@ -24,9 +24,12 @@ func Login(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cfg := config.Instance().GetConfig()
|
||||
var (
|
||||
username = config.Instance().GetConfig().Username
|
||||
password = config.Instance().GetConfig().Password
|
||||
)
|
||||
|
||||
if cfg.Username != req.Username || cfg.Password != req.Password {
|
||||
if username != req.Username || password != req.Password {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ type metadata struct {
|
||||
}
|
||||
|
||||
func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
|
||||
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, req.URL, "-J")
|
||||
var (
|
||||
downloader = config.Instance().GetConfig().DownloaderPath
|
||||
cmd = exec.Command(downloader, req.URL, "-J")
|
||||
)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
@@ -51,7 +54,9 @@ func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
|
||||
cli.BgGreen, "Playlist detected", cli.Reset, m.Count, "entries",
|
||||
)
|
||||
|
||||
for _, meta := range m.Entries {
|
||||
for i, meta := range m.Entries {
|
||||
delta := time.Second.Microseconds() * int64(i+1)
|
||||
|
||||
proc := &Process{
|
||||
Url: meta.OriginalURL,
|
||||
Progress: DownloadProgress{},
|
||||
@@ -61,7 +66,7 @@ func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
|
||||
}
|
||||
|
||||
proc.Info.URL = meta.OriginalURL
|
||||
proc.Info.CreatedAt = time.Now().Add(time.Second)
|
||||
proc.Info.CreatedAt = time.Now().Add(time.Duration(delta))
|
||||
|
||||
db.Set(proc)
|
||||
proc.SetPending()
|
||||
|
||||
Reference in New Issue
Block a user