Skip to content

Commit 3773e02

Browse files
committed
Merge branch 'dev' of https://github.com/LumePart/Explo into dev
2 parents a0bd01a + d5e94ab commit 3773e02

File tree

3 files changed

+56
-54
lines changed

3 files changed

+56
-54
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
goosarch:
4040
- 'linux/amd64'
4141
- 'linux/386'
42+
- 'linux/arm64'
43+
- 'linux/arm'
4244
steps:
4345
- name: Checkout code
4446
uses: actions/checkout@v4
@@ -110,7 +112,7 @@ jobs:
110112
ghcr.io/${{ env.REPO_LC }}:${{ github.ref_name }}
111113
cache-from: type=gha
112114
cache-to: type=gha,mode=max
113-
platforms: linux/amd64,linux/386
115+
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
114116
build-args: |
115117
TARGETARCH
116118
@@ -153,6 +155,6 @@ jobs:
153155
tags: ghcr.io/${{ env.REPO_LC }}:dev
154156
cache-from: type=gha
155157
cache-to: type=gha,mode=max
156-
platforms: linux/amd64,linux/386
158+
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
157159
build-args: |
158160
TARGETARCH

src/downloader/downloader.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package downloader
22

33
import (
4+
"fmt"
5+
"io"
6+
"log"
47
"os"
58
"path"
6-
"log"
7-
"strings"
8-
"regexp"
9-
"fmt"
109
"path/filepath"
11-
"io"
10+
"regexp"
11+
"strings"
12+
1213
"golang.org/x/sync/errgroup"
1314

1415
cfg "explo/src/config"
@@ -17,7 +18,7 @@ import (
1718
)
1819

1920
type DownloadClient struct {
20-
Cfg *cfg.DownloadConfig
21+
Cfg *cfg.DownloadConfig
2122
Downloaders []Downloader
2223
}
2324

@@ -27,7 +28,6 @@ type Downloader interface {
2728
Monitor
2829
}
2930

30-
3131
func NewDownloader(cfg *cfg.DownloadConfig, httpClient *util.HttpClient) *DownloadClient { // get download services from config and append them to DownloadClient
3232
var downloader []Downloader
3333
for _, service := range cfg.Services {
@@ -44,32 +44,32 @@ func NewDownloader(cfg *cfg.DownloadConfig, httpClient *util.HttpClient) *Downlo
4444
}
4545

4646
return &DownloadClient{
47-
Cfg: cfg,
47+
Cfg: cfg,
4848
Downloaders: downloader}
4949
}
5050

51-
func (c *DownloadClient) StartDownload(tracks *[]*models.Track) {
52-
for _, d := range c.Downloaders {
53-
var g errgroup.Group
54-
g.SetLimit(5)
55-
56-
for _, track := range *tracks {
57-
if track.Present {
58-
continue
51+
func (c *DownloadClient) StartDownload(tracks *[]*models.Track) {
52+
for _, d := range c.Downloaders {
53+
var g errgroup.Group
54+
g.SetLimit(5)
55+
56+
for _, track := range *tracks {
57+
if track.Present {
58+
continue
59+
}
60+
61+
g.Go(func() error {
62+
63+
if err := d.QueryTrack(track); err != nil {
64+
log.Println(err.Error())
65+
return nil
5966
}
60-
61-
g.Go(func() error {
62-
63-
if err := d.QueryTrack(track); err != nil {
64-
log.Println(err.Error())
65-
return nil
66-
}
67-
if err := d.GetTrack(track); err != nil {
68-
log.Println(err.Error())
69-
return nil
70-
}
67+
if err := d.GetTrack(track); err != nil {
68+
log.Println(err.Error())
7169
return nil
72-
})
70+
}
71+
return nil
72+
})
7373
}
7474
if err := g.Wait(); err != nil {
7575
return
@@ -93,7 +93,7 @@ func (c *DownloadClient) DeleteSongs() {
9393
for _, entry := range entries {
9494
if !(entry.IsDir()) {
9595
err = os.Remove(path.Join(c.Cfg.DownloadDir, entry.Name()))
96-
96+
9797
if err != nil {
9898
log.Printf("failed to remove file: %s", err.Error())
9999
}
@@ -115,9 +115,9 @@ func filterTracks(tracks *[]*models.Track) { // only keep tracks that were downl
115115
func containsLower(str string, substr string) bool {
116116

117117
return strings.Contains(
118-
strings.ToLower(str),
119-
strings.ToLower(substr),
120-
)
118+
strings.ToLower(str),
119+
strings.ToLower(substr),
120+
)
121121
}
122122

123123
func sanitizeName(s string) string { // return string with only letters and digits
@@ -132,7 +132,7 @@ func getFilename(title, artist string) string {
132132
t := re.ReplaceAllString(title, "_")
133133
a := re.ReplaceAllString(artist, "_")
134134

135-
return fmt.Sprintf("%s-%s",t,a)
135+
return fmt.Sprintf("%s-%s", t, a)
136136
}
137137

138138
func moveDownload(srcDir, destDir, trackPath, file string) error { // Move download from the source dir to the dest dir (download dir)
@@ -189,4 +189,4 @@ func moveDownload(srcDir, destDir, trackPath, file string) error { // Move downl
189189
}
190190

191191
return nil
192-
}
192+
}

src/downloader/slskd.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package downloader
22

33
import (
44
"bytes" // Could be moved to util for all clients
5+
"encoding/json"
56
"explo/src/config"
67
"explo/src/debug"
78
"explo/src/models"
89
"explo/src/util"
9-
"encoding/json"
1010
"fmt"
1111
"log"
1212
"path/filepath"
@@ -40,15 +40,15 @@ type SearchResults []struct {
4040
Username string `json:"username"`
4141
}
4242
type File struct {
43-
BitRate int `json:"bitRate"`
44-
BitDepth int `json:"bitDepth"`
45-
Code int `json:"code"`
46-
Extension string `json:"extension"`
47-
Name string `json:"filename"`
48-
Length int `json:"length"`
49-
Size int `json:"size"`
50-
IsLocked bool `json:"isLocked"`
51-
Username string // Save user from SearchResults to here during collection
43+
BitRate int `json:"bitRate"`
44+
BitDepth int `json:"bitDepth"`
45+
Code int `json:"code"`
46+
Extension string `json:"extension"`
47+
Name string `json:"filename"`
48+
Length int `json:"length"`
49+
Size int `json:"size"`
50+
IsLocked bool `json:"isLocked"`
51+
Username string // Save user from SearchResults to here during collection
5252
}
5353

5454
type DownloadPayload struct {
@@ -94,16 +94,16 @@ type DownloadMonitor struct {
9494
}
9595

9696
type Slskd struct {
97-
Headers map[string]string
98-
HttpClient *util.HttpClient
97+
Headers map[string]string
98+
HttpClient *util.HttpClient
9999
DownloadDir string
100-
Cfg config.Slskd
100+
Cfg config.Slskd
101101
}
102102

103103
func NewSlskd(cfg config.Slskd, downloadDir string) *Slskd {
104104
return &Slskd{Cfg: cfg,
105-
HttpClient: util.NewHttp(util.HttpClientConfig{Timeout: cfg.Timeout}),
106-
DownloadDir: downloadDir,}
105+
HttpClient: util.NewHttp(util.HttpClientConfig{Timeout: cfg.Timeout}),
106+
DownloadDir: downloadDir}
107107
}
108108

109109
func (c *Slskd) AddHeader() {
@@ -315,7 +315,7 @@ func (c Slskd) queueDownload(files []File, track *models.Track) error {
315315
payload := []DownloadPayload{
316316
{
317317
Filename: file.Name,
318-
Size: file.Size,
318+
Size: file.Size,
319319
},
320320
}
321321

@@ -332,7 +332,7 @@ func (c Slskd) queueDownload(files []File, track *models.Track) error {
332332
return nil
333333
}
334334

335-
log.Printf("[%d/%d] failed to queue download for '%s - %s': %s", i + 1, len(files), track.CleanTitle, track.Artist, err.Error())
335+
log.Printf("[%d/%d] failed to queue download for '%s - %s': %s", i+1, len(files), track.CleanTitle, track.Artist, err.Error())
336336
continue
337337
}
338338
if err := c.deleteSearch(track.ID); err != nil {
@@ -412,4 +412,4 @@ func parsePath(p string) (string, string) { // parse filepath to downloaded form
412412
p = strings.ReplaceAll(p, `\`, `/`)
413413
return filepath.Base(p), filepath.Base(filepath.Dir(p))
414414

415-
}
415+
}

0 commit comments

Comments
 (0)