Add transcoding status to videos
This commit is contained in:
@@ -19,6 +19,7 @@ const (
|
||||
Downloading OriginalStatus = "downloading"
|
||||
DownloadCompleted OriginalStatus = "download completed"
|
||||
Transcoding OriginalStatus = "transcoding"
|
||||
Completed OriginalStatus = "completed"
|
||||
Failed OriginalStatus = "failed"
|
||||
)
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
{{range .videos}}
|
||||
<div class="video-card">
|
||||
<div class="video-title">
|
||||
{{if eq .Status "completed"}}
|
||||
{{if or (eq .Status "download completed") (eq .Status "transcoding") (eq .Status "completed")}}
|
||||
<a href="/video/{{.ID}}">{{.Title}}</a>
|
||||
{{else}}
|
||||
{{.Title}}
|
||||
|
28
workers.go
28
workers.go
@@ -215,6 +215,34 @@ func transcodePending() {
|
||||
|
||||
// loop until no more pending jobs
|
||||
for {
|
||||
|
||||
var originalsToUpdate []uint
|
||||
|
||||
// find any originals with a transcode job and mark them as transcoding
|
||||
db.Debug().Model(&Original{}).
|
||||
Select("id").
|
||||
Where("id IN (?)",
|
||||
db.Model(&Transcode{}).
|
||||
Select("original_id"),
|
||||
).
|
||||
Find(&originalsToUpdate)
|
||||
db.Debug().Model(&Original{}).
|
||||
Where("id IN ?", originalsToUpdate).
|
||||
Update("status", Transcoding)
|
||||
|
||||
// originals marked transcoding that don't have a transcode job -> complete
|
||||
db.Debug().Model(&Original{}).
|
||||
Select("id").
|
||||
Where("status = ? AND id NOT IN (?)",
|
||||
Transcoding,
|
||||
db.Model(&Transcode{}).
|
||||
Select("original_id"),
|
||||
).
|
||||
Find(&originalsToUpdate)
|
||||
db.Debug().Model(&Original{}).
|
||||
Where("id IN ? AND status = ?", originalsToUpdate, Transcoding).
|
||||
Update("status", Completed)
|
||||
|
||||
var trans Transcode
|
||||
err := db.Where("status = ?", "pending").
|
||||
Order("CASE " +
|
||||
|
Reference in New Issue
Block a user