Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3dec93c4f4 | |||
| 3353d3d923 | |||
| 7b326d72b1 | |||
| bef753d7ee | |||
| a66ab08431 | |||
| b0048a5764 | |||
| 73833a1a14 | |||
| aa64e000ee | |||
| 5121438ffc | |||
| 46dbf2d64f | |||
| 6b13e54fb5 | |||
| 9a2497c244 | |||
| bb8193b504 |
@@ -12,6 +12,7 @@ before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
- go test ./...
|
||||
|
||||
builds:
|
||||
- env:
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [v1.1.1] - 2023-12-08
|
||||
|
||||
- Fix bug where a brand-new config was created with an out-of-date version
|
||||
- Fix for portable mode and using executable in the current working directory
|
||||
|
||||
## [v1.1.0] - 2023-11-25
|
||||
|
||||
- Add feature to bulk add URL's for downloading
|
||||
|
||||
@@ -164,6 +164,14 @@ Note that this also means that `yt-dlp` can resume partially downloaded files, a
|
||||
also automatically 'backfill', downloading only files that have not been
|
||||
downloaded yet from that playlist.
|
||||
|
||||
## Downloading a list of URL's in bulk
|
||||
|
||||
From main index page you can click the "Bulk" link in the menu to bring up the
|
||||
bulk queue page.
|
||||
|
||||
In all respects this acts the same as the usual bookmarklet, but it has a
|
||||
textbox for pasting many URLs at once. All downloads will be queued immediately.
|
||||
|
||||
## Portable mode
|
||||
|
||||
If you'd like to use gropple from a USB stick or similar, copy the config file
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
open my $fh, "<", "main.go" || die $!;
|
||||
|
||||
my $version;
|
||||
while (<$fh>) {
|
||||
# CurrentVersion: "v0.04"
|
||||
$version = $1 if /CurrentVersion:\s*"(v.*?)"/;
|
||||
}
|
||||
close $fh;
|
||||
|
||||
die "no version?" unless defined $version;
|
||||
|
||||
# quit if tests fail
|
||||
system("go test ./...") && die "not building release with failing tests";
|
||||
|
||||
# so lazy
|
||||
system "rm", "-rf", "release", "dist";
|
||||
system "mkdir", "release";
|
||||
system "mkdir", "dist";
|
||||
|
||||
my %build = (
|
||||
win => { env => { GOOS => 'windows', GOARCH => 'amd64' }, filename => 'gropple.exe' },
|
||||
linux => { env => { GOOS => 'linux', GOARCH => 'amd64' }, filename => 'gropple' },
|
||||
mac => { env => { GOOS => 'darwin', GOARCH => 'amd64' }, filename => 'gropple' },
|
||||
);
|
||||
|
||||
foreach my $type (keys %build) {
|
||||
mkdir "release/$type";
|
||||
}
|
||||
|
||||
foreach my $type (keys %build) {
|
||||
local $ENV{GOOS} = $build{$type}->{env}->{GOOS};
|
||||
local $ENV{GOARCH} = $build{$type}->{env}->{GOARCH};
|
||||
system "go", "build", "-o", "release/$type/" . $build{$type}->{filename};
|
||||
system "zip", "-j", "dist/gropple-$type-$version.zip", ( glob "release/$type/*" );
|
||||
}
|
||||
|
||||
# now docker
|
||||
exit 0;
|
||||
$ENV{VERSION}="$version";
|
||||
system "docker-compose", "-f", "docker-compose.build.yml", "build";
|
||||
system "docker", "tag", "tardisx/gropple:$version", "tardisx/gropple:latest";
|
||||
system "docker", "push", "tardisx/gropple:$version";
|
||||
system "docker", "push", "tardisx/gropple:latest";
|
||||
|
||||
@@ -65,7 +65,7 @@ type ConfigService struct {
|
||||
func (cs *ConfigService) LoadTestConfig() {
|
||||
cs.LoadDefaultConfig()
|
||||
cs.Config.Server.DownloadPath = "/tmp"
|
||||
cs.Config.DownloadProfiles = []DownloadProfile{{Name: "test profile", Command: "sleep", Args: []string{"5"}}}
|
||||
cs.Config.DownloadProfiles = []DownloadProfile{{Name: "test profile", Command: "/bin/sleep", Args: []string{"5"}}}
|
||||
}
|
||||
|
||||
func (cs *ConfigService) LoadDefaultConfig() {
|
||||
@@ -98,7 +98,7 @@ func (cs *ConfigService) LoadDefaultConfig() {
|
||||
defaultConfig.Destinations = nil
|
||||
defaultConfig.DownloadOptions = make([]DownloadOption, 0)
|
||||
|
||||
defaultConfig.ConfigVersion = 3
|
||||
defaultConfig.ConfigVersion = 4
|
||||
|
||||
cs.Config = &defaultConfig
|
||||
|
||||
@@ -189,9 +189,10 @@ func (c *Config) UpdateFromJSON(j []byte) error {
|
||||
}
|
||||
|
||||
// check the command exists
|
||||
_, err := exec.LookPath(newConfig.DownloadProfiles[i].Command)
|
||||
|
||||
_, err := AbsPathToExecutable(newConfig.DownloadProfiles[i].Command)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not find %s on the path", newConfig.DownloadProfiles[i].Command)
|
||||
return fmt.Errorf("problem with command '%s': %s", newConfig.DownloadProfiles[i].Command, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,3 +338,28 @@ func (cs *ConfigService) WriteConfig() {
|
||||
}
|
||||
file.Close()
|
||||
}
|
||||
|
||||
// AbsPathToExecutable takes a command name, which may or may not be path-qualified,
|
||||
// and returns the fully qualified path to it, or an error if could not be found, or
|
||||
// if it does not appear to be a file.
|
||||
func AbsPathToExecutable(cmd string) (string, error) {
|
||||
|
||||
pathCmd, err := exec.LookPath(cmd)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not LookPath '%s': %w", cmd, err)
|
||||
}
|
||||
|
||||
execAbsolutePath, err := filepath.Abs(pathCmd)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get absolute path to '%s': %w", cmd, err)
|
||||
}
|
||||
fi, err := os.Stat(execAbsolutePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get stat '%s': %w", cmd, err)
|
||||
}
|
||||
if !fi.Mode().IsRegular() {
|
||||
return "", fmt.Errorf("'%s' is not a regular file: %w", cmd, err)
|
||||
}
|
||||
|
||||
return execAbsolutePath, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -172,3 +174,41 @@ func configServiceFromString(configString string) *ConfigService {
|
||||
}
|
||||
return &cs
|
||||
}
|
||||
|
||||
func TestLookForExecutable(t *testing.T) {
|
||||
cmdPath, err := exec.LookPath("sleep")
|
||||
if err != nil {
|
||||
t.Errorf("cannot run this test without knowing about sleep: %s", err)
|
||||
t.FailNow()
|
||||
}
|
||||
cmdDir := filepath.Dir(cmdPath)
|
||||
|
||||
cmd := "sleep"
|
||||
path, err := AbsPathToExecutable(cmd)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, cmdPath, path)
|
||||
}
|
||||
|
||||
cmd = cmdPath
|
||||
path, err = AbsPathToExecutable(cmd)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, cmdPath, path)
|
||||
}
|
||||
|
||||
cmd = "../../../../../../../../.." + cmdPath
|
||||
path, err = AbsPathToExecutable(cmd)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, cmdPath, path)
|
||||
}
|
||||
cmd = "./sleep"
|
||||
_, err = AbsPathToExecutable(cmd)
|
||||
assert.Error(t, err)
|
||||
|
||||
os.Chdir(cmdDir)
|
||||
cmd = "./sleep"
|
||||
path, err = AbsPathToExecutable(cmd)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, cmdPath, path)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -281,9 +281,21 @@ func (dl *Download) Begin() {
|
||||
cmdSlice = append(cmdSlice, dl.Url)
|
||||
}
|
||||
|
||||
dl.Log = append(dl.Log, fmt.Sprintf("executing: %s with args: %s", dl.DownloadProfile.Command, strings.Join(cmdSlice, " ")))
|
||||
cmd := exec.Command(dl.DownloadProfile.Command, cmdSlice...)
|
||||
cmdPath, err := config.AbsPathToExecutable(dl.DownloadProfile.Command)
|
||||
if err != nil {
|
||||
dl.State = STATE_FAILED
|
||||
dl.Finished = true
|
||||
dl.FinishedTS = time.Now()
|
||||
dl.Log = append(dl.Log, fmt.Sprintf("error finding executable for downloader: %s", err.Error()))
|
||||
dl.Lock.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
dl.Log = append(dl.Log, fmt.Sprintf("executing: %s (%s) with args: %s", dl.DownloadProfile.Command, cmdPath, strings.Join(cmdSlice, " ")))
|
||||
|
||||
cmd := exec.Command(cmdPath, cmdSlice...)
|
||||
cmd.Dir = dl.Config.Server.DownloadPath
|
||||
log.Printf("Executing command executable: %s) in %s", cmdPath, dl.Config.Server.DownloadPath)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
@@ -292,7 +304,6 @@ func (dl *Download) Begin() {
|
||||
dl.FinishedTS = time.Now()
|
||||
dl.Log = append(dl.Log, fmt.Sprintf("error setting up stdout pipe: %v", err))
|
||||
dl.Lock.Unlock()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -307,9 +318,10 @@ func (dl *Download) Begin() {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Executing command: %v", cmd)
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
log.Printf("Executing command failed: %s", err.Error())
|
||||
|
||||
dl.State = STATE_FAILED
|
||||
dl.Finished = true
|
||||
dl.FinishedTS = time.Now()
|
||||
@@ -363,7 +375,6 @@ func (dl *Download) Begin() {
|
||||
}
|
||||
}
|
||||
dl.Lock.Unlock()
|
||||
|
||||
}
|
||||
|
||||
// updateDownload updates the download based on data from the reader. Expects the
|
||||
|
||||
2
main.go
2
main.go
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func main() {
|
||||
versionInfo := &version.Manager{
|
||||
VersionInfo: version.Info{CurrentVersion: "v1.1.0"},
|
||||
VersionInfo: version.Info{CurrentVersion: "v1.1.1"},
|
||||
}
|
||||
log.Printf("Starting gropple %s - https://github.com/tardisx/gropple", versionInfo.GetInfo().CurrentVersion)
|
||||
|
||||
|
||||
@@ -84,7 +84,10 @@
|
||||
|
||||
<label x-bind:for="'config-profiles-'+i+'-command'">Command to run</label>
|
||||
<input type="text" x-bind:id="'config-profiles-'+i+'-command'" class="input-long" placeholder="name" x-model="profile.command" />
|
||||
<span class="pure-form-message">Which command to run. Your path will be searched, or you can specify the full path here.</span>
|
||||
<span class="pure-form-message">Which command to run. Your path will be searched, or you can specify the full path here.
|
||||
If you are using gropple in portable mode and store the executables with the gropple executable, use a prefix of
|
||||
<tt>./</tt>, for instance <tt>yt-dlp.exe</tt>.
|
||||
</span>
|
||||
|
||||
|
||||
<label>Arguments</label>
|
||||
|
||||
Reference in New Issue
Block a user