Fix file upload, cleanup
This commit is contained in:
parent
0f9b01568e
commit
ae829d07d3
@ -113,7 +113,7 @@ type YoutubeDlBackgroundService(requirements: StartYoutubeDlServiceArgs) =
|
||||
savePath = job.savePath
|
||||
}
|
||||
let attachExternalId (id: Guid, job: YoutubeDlJobWithoutId): YoutubeDlCurrentJob =
|
||||
Awaiting { internalId = job.internalId; state = job.state; url = job.state; externalId = id; savePath = job.savePath }
|
||||
Awaiting { internalId = job.internalId; state = job.state; url = job.url; externalId = id; savePath = job.savePath }
|
||||
|
||||
let tryAssignNewJob() = async {
|
||||
let (result, job) = jobPool.TryDequeue()
|
||||
@ -147,6 +147,7 @@ type YoutubeDlBackgroundService(requirements: StartYoutubeDlServiceArgs) =
|
||||
}
|
||||
|
||||
let cleanUp(job: YoutubeDlJobWithId) = async {
|
||||
File.Delete <| job.savePath
|
||||
match! ytClient.CleanJob <| job.externalId with
|
||||
| Ok _ -> currentJob <- None ()
|
||||
| Error _ -> currentJob <- None ()
|
||||
@ -171,6 +172,6 @@ type YoutubeDlBackgroundService(requirements: StartYoutubeDlServiceArgs) =
|
||||
member public this.StartYoutubeDlService() = loop() |> Async.Start
|
||||
member public this.EnqueueJob(url: string) = lock <!> async {
|
||||
let id = Guid.NewGuid()
|
||||
jobPool.Enqueue({ internalId = id; externalId = (); state = "new"; url = url; savePath = Path.GetTempFileName() })
|
||||
jobPool.Enqueue({ internalId = id; externalId = (); state = "new"; url = url; savePath = $"{Path.GetTempFileName()}.mp4" })
|
||||
return id
|
||||
}
|
@ -21,7 +21,9 @@ def report_state(id: str):
|
||||
|
||||
def load_video(url: str, file_path: str, id: str):
|
||||
opts = {
|
||||
"forcefilename": file_path,
|
||||
"format": 'mp4',
|
||||
"quiet": True,
|
||||
"outtmpl": file_path,
|
||||
"progress_hooks": [report_state(id)]
|
||||
}
|
||||
with YoutubeDL(opts) as ydl:
|
||||
|
Loading…
Reference in New Issue
Block a user