1. Download all works instantly

2. Display queue status
pull/24/head
Akhil Gupta 4 years ago
parent 421d7ed407
commit ebb323819d

@ -1,3 +1,3 @@
CONFIG=.
DATA=./assets
CHECK_FREQUENCY = 240
CHECK_FREQUENCY = 10

@ -67,11 +67,21 @@
<p class="useMore">{{ .Summary }}</p>
<div class="row">
<div class="columns three">
<div class="columns four">
Last Ep : {{ latestEpisodeDate .PodcastItems}}
</div>
<div class="columns three">{{ len .PodcastItems }} episodes</div>
<div class="columns six" style="text-align: right">
{{$downloading:=downloadingEpisodes .PodcastItems}}
<div
class="columns five"
title="{{downloadedEpisodes .PodcastItems}} episodes downloaded out of total {{ len .PodcastItems}} episodes.
{{if gt $downloading 0}} {{$downloading}} episodes in queue {{end}}
"
>
{{if gt $downloading 0}} ({{$downloading}})/{{end}}{{downloadedEpisodes .PodcastItems}}/{{ len .PodcastItems }} episodes
</div>
<div class="columns three" style="">
<button
class="button button-delete"
onclick="deletePodcast('{{.ID}}')"

@ -101,6 +101,7 @@ func DownloadAllEpisodesByPodcastId(c *gin.Context) {
err := db.SetAllEpisodesToDownload(searchByIdQuery.Id)
fmt.Println(err)
go service.RefreshEpisodes()
c.JSON(200, gin.H{})
} else {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})

@ -2,6 +2,7 @@ package db
import (
"errors"
"fmt"
"time"
"gorm.io/gorm"
@ -165,17 +166,21 @@ func Unlock(name string) {
}
func UnlockMissedJobs() {
var jobLocks *[]JobLock
var jobLocks []JobLock
result := DB.Where("date != ", time.Time{}).Find(&jobLocks)
result := DB.Debug().Find(&jobLocks)
if result.Error != nil {
return
}
for _, job := range *jobLocks {
for _, job := range jobLocks {
if (job.Date == time.Time{}) {
continue
}
var duration time.Duration
duration = time.Duration(job.Duration)
d := job.Date.Add(time.Minute * duration)
if d.Before(time.Now()) {
fmt.Println(job.Name + " is unlocked")
Unlock(job.Name)
}
}

@ -50,6 +50,24 @@ func main() {
}
return latest.Format("Jan 2 2006")
},
"downloadedEpisodes": func(podcastItems []db.PodcastItem) int {
count := 0
for _, item := range podcastItems {
if item.DownloadStatus == db.Downloaded {
count++
}
}
return count
},
"downloadingEpisodes": func(podcastItems []db.PodcastItem) int {
count := 0
for _, item := range podcastItems {
if item.DownloadStatus == db.NotDownloaded {
count++
}
}
return count
},
"formatDuration": func(total int) string {
if total <= 0 {
return ""
@ -120,9 +138,11 @@ func intiCron() {
checkFrequency = 30
log.Print(err)
}
service.UnlockMissedJobs()
//gocron.Every(uint64(checkFrequency)).Minutes().Do(service.DownloadMissingEpisodes)
gocron.Every(uint64(checkFrequency)).Minutes().Do(service.RefreshEpisodes)
gocron.Every(uint64(checkFrequency)).Minutes().Do(service.CheckMissingFiles)
gocron.Every(uint64(checkFrequency) * 2).Minutes().Do(service.UnlockMissedJobs)
gocron.Every(2).Days().Do(service.CreateBackup)
<-gocron.Start()
}

@ -431,3 +431,7 @@ func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload b
return db.UpdateSettings(setting)
}
func UnlockMissedJobs() {
db.UnlockMissedJobs()
}

Loading…
Cancel
Save