Change save path for YTDL service
This commit is contained in:
parent
172dcf9d79
commit
350943aa85
@ -17,6 +17,7 @@ type public BotConfig = {
|
|||||||
chanelId: int64
|
chanelId: int64
|
||||||
adminChatId: int64
|
adminChatId: int64
|
||||||
youtubeDlUrl: string
|
youtubeDlUrl: string
|
||||||
|
tmpYtdlSavePath: string Option
|
||||||
}
|
}
|
||||||
|
|
||||||
let private readConfig =
|
let private readConfig =
|
||||||
|
@ -28,7 +28,7 @@ let tgService =
|
|||||||
}
|
}
|
||||||
|
|
||||||
let youtubeDlService =
|
let youtubeDlService =
|
||||||
YoutubeDlService.createService youtubeDlClient tgService
|
YoutubeDlService.createService youtubeDlClient tgService (config.tmpYtdlSavePath |> Option.defaultValue "/tmp")
|
||||||
|
|
||||||
let isObsoleteUpdate =
|
let isObsoleteUpdate =
|
||||||
let startDate = DateTime.UtcNow
|
let startDate = DateTime.UtcNow
|
||||||
|
@ -163,7 +163,7 @@ module YoutubeDlClient =
|
|||||||
[<RequireQualifiedAccess>]
|
[<RequireQualifiedAccess>]
|
||||||
module YoutubeDlService =
|
module YoutubeDlService =
|
||||||
type private Msg =
|
type private Msg =
|
||||||
| AddJob of url: string * TaskCompletionSource<Guid>
|
| AddJob of url: string * savePath: string * TaskCompletionSource<Guid>
|
||||||
| CheckJob
|
| CheckJob
|
||||||
|
|
||||||
type private JobState =
|
type private JobState =
|
||||||
@ -235,14 +235,15 @@ module YoutubeDlService =
|
|||||||
(current: YoutubeDlJob option) =
|
(current: YoutubeDlJob option) =
|
||||||
async {
|
async {
|
||||||
match! inbox.Receive() with
|
match! inbox.Receive() with
|
||||||
| AddJob (url, tcs) ->
|
| AddJob (url, savePath, tcs) ->
|
||||||
Logging.logger.Information("Adding new url = {url}", url)
|
Logging.logger.Information("Adding new url = {url}", url)
|
||||||
let id = Guid.NewGuid()
|
let id = Guid.NewGuid()
|
||||||
|
let fullSavePath = $"{Path.Combine(savePath, Path.GetRandomFileName())}.mp4"
|
||||||
let job = {
|
let job = {
|
||||||
InternalId = id
|
InternalId = id
|
||||||
State = Created
|
State = Created
|
||||||
Url = url
|
Url = url
|
||||||
SavePath = $"{Path.GetTempFileName()}.mp4"
|
SavePath = fullSavePath
|
||||||
}
|
}
|
||||||
tcs.SetResult(id)
|
tcs.SetResult(id)
|
||||||
jobQueue.Enqueue(job)
|
jobQueue.Enqueue(job)
|
||||||
@ -315,10 +316,10 @@ module YoutubeDlService =
|
|||||||
loop (Queue()) None
|
loop (Queue()) None
|
||||||
)
|
)
|
||||||
|
|
||||||
let createService youtubeDlClient tgService =
|
let createService youtubeDlClient tgService (savePath: string) =
|
||||||
let inbox = createServiceInbox youtubeDlClient tgService
|
let inbox = createServiceInbox youtubeDlClient tgService
|
||||||
{ new IYoutubeDlService with
|
{ new IYoutubeDlService with
|
||||||
member this.AddJob(url) =
|
member this.AddJob(url) =
|
||||||
let tcs = TaskCompletionSource<_>()
|
let tcs = TaskCompletionSource<_>()
|
||||||
inbox.Post(AddJob(url, tcs))
|
inbox.Post(AddJob(url, savePath, tcs))
|
||||||
tcs.Task |> Async.AwaitTask }
|
tcs.Task |> Async.AwaitTask }
|
@ -3,5 +3,6 @@
|
|||||||
"chanelId": "123123123",
|
"chanelId": "123123123",
|
||||||
"adminChatId": "123123123",
|
"adminChatId": "123123123",
|
||||||
"relayUrl": "https://t.me/pokupkabitka_bot",
|
"relayUrl": "https://t.me/pokupkabitka_bot",
|
||||||
"youtubeDlUrl": "http://localhost:8000/"
|
"youtubeDlUrl": "http://localhost:8000/",
|
||||||
|
"tmpYtdlSavePath": "/tmp"
|
||||||
}
|
}
|
@ -30,7 +30,8 @@ cd PublishHelperBot && dotnet restore
|
|||||||
"chanelId": "123123123", // Канал куда постить
|
"chanelId": "123123123", // Канал куда постить
|
||||||
"adminChatId": "123123123", // Чат откуда будут слушаться команды
|
"adminChatId": "123123123", // Чат откуда будут слушаться команды
|
||||||
"relayUrl": "https://t.me/pokupkabitka_bot", // ссылка на бота предложки (Нужно команде /post)
|
"relayUrl": "https://t.me/pokupkabitka_bot", // ссылка на бота предложки (Нужно команде /post)
|
||||||
"youtubeDlUrl": "http://localhost:8000/" // апишка для скачивания видосиков
|
"youtubeDlUrl": "http://localhost:8000/", // апишка для скачивания видосиков
|
||||||
|
"tmpYtdlSavePath": "/tmp" // Промежуточное хранилище для YTDL
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user