Add cookie support in docker image
This commit is contained in:
parent
dfa24f0f64
commit
82945d1a0c
@ -8,6 +8,7 @@ RUN wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /us
|
||||
chmod 755 /usr/local/bin/yt-dlp
|
||||
RUN apk update && apk upgrade && apk add --no-cache ffmpeg
|
||||
COPY --from=builder /app/yt-dlp-telegram-bot /app/yt-dlp-telegram-bot
|
||||
COPY --from=builder /app/yt-dlp.conf /root/yt-dlp.conf
|
||||
|
||||
ENTRYPOINT ["/app/yt-dlp-telegram-bot"]
|
||||
ENV API_ID= API_HASH= BOT_TOKEN= ALLOWED_USERIDS= ADMIN_USERIDS= ALLOWED_GROUPIDS=
|
||||
ENV API_ID= API_HASH= BOT_TOKEN= ALLOWED_USERIDS= ADMIN_USERIDS= ALLOWED_GROUPIDS= YTDLP_COOKIES=
|
||||
|
||||
@ -77,6 +77,12 @@ variable. Available OS environment variables are:
|
||||
- `ALLOWED_USERIDS`
|
||||
- `ADMIN_USERIDS`
|
||||
- `ALLOWED_GROUPIDS`
|
||||
- `YTDLP_COOKIES`
|
||||
|
||||
The contents of the `YTDLP_COOKIES` environment variable will be written to the
|
||||
file `/tmp/ytdlp-cookies.txt`. This will be used by `yt-dlp` if it is running
|
||||
in a docker container, as the `yt-dlp.conf` file in the container points to this
|
||||
cookie file.
|
||||
|
||||
## Supported commands
|
||||
|
||||
|
||||
14
params.go
14
params.go
@ -127,5 +127,19 @@ func (p *paramsType) Init() error {
|
||||
p.AllowedGroupIDs = append(p.AllowedUserIDs, id)
|
||||
}
|
||||
|
||||
// Writing env. var YTDLP_COOKIES contents to a file.
|
||||
// In case a docker container is used, the yt-dlp.conf points yt-dlp to this cookie file.
|
||||
if cookies := os.Getenv("YTDLP_COOKIES"); cookies != "" {
|
||||
f, err := os.Create("/tmp/ytdlp-cookies.txt")
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't create cookies file: %w", err)
|
||||
}
|
||||
_, err = f.WriteString(cookies)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't write cookies file: %w", err)
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
1
yt-dlp.conf
Normal file
1
yt-dlp.conf
Normal file
@ -0,0 +1 @@
|
||||
--cookies=/tmp/ytdlp-cookies.txt
|
||||
Loading…
Reference in New Issue
Block a user