Skip to content

Commit ff1a461

Browse files
cpanatoalexellis
authored andcommitted
Add youtube-dl to the store
Signed-off-by: Carlos Panato <[email protected]> Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 94b6fa0 commit ff1a461

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
template
22
build
3+
4+
.secrets

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ curl http://127.0.0.1:8080 -d "-c 5 -n 1000 https://your-service.com/"
5959
* `sleep` - debug timeouts or async by sleeping for a set duration
6060
* `sentimentanalysis` - use Python's textblob library to find out if a statement is positive or negative
6161
* `shasum` - generate a SHA for a given input
62+
* `youtubedl` - downloads a youtube video
6263

6364
Other functions: `imagemagick`, `ffmpeg`.
6465

stack.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ functions:
5757
handler: ./ffmpeg
5858
image: ghcr.io/${OWNER:-openfaas}/ffmpeg:${TAG:-latest}
5959

60+
youtube-dl:
61+
lang: dockerfile
62+
handler: ./youtube-dl
63+
image: ghcr.io/${OWNER:-openfaas}/youtube-dl:${TAG:-latest}
64+
environment:
65+
read_timeout: 5m5s
66+
write_timeout: 5m5s
67+
exec_timeout: 5m
68+
labels:
69+
com.openfaas.ui.ext: "mp4"
6070

6171
sentimentanalysis:
6272
lang: dockerfile

youtube-dl/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.2.2 as watchdog
2+
3+
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.3 as ship
4+
5+
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
6+
RUN chmod +x /usr/bin/fwatchdog
7+
8+
RUN apk add --no-cache py-pip bash ca-certificates
9+
10+
# youtube-dl appears to be broken
11+
# https://github.com/ytdl-org/youtube-dl/issues/31530
12+
# Switching to yt-dlp
13+
RUN pip install --upgrade yt-dlp
14+
15+
# Add non root user
16+
RUN mkdir -p /home/app
17+
RUN addgroup -S app && adduser app -S -G app
18+
RUN chown app /home/app
19+
20+
WORKDIR /home/app
21+
22+
USER app
23+
24+
COPY entry.sh .
25+
ENV fprocess="/bin/sh ./entry.sh"
26+
27+
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1
28+
29+
EXPOSE 8080
30+
31+
CMD ["fwatchdog"]

youtube-dl/entry.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
youtubeID=""
4+
if [ -n "$1" ] ; then
5+
youtubeID=$1
6+
else
7+
youtubeID=$(cat /dev/stdin)
8+
fi
9+
10+
trimmedYoutubeID=$(echo "$youtubeID" | tr -d '\n')
11+
12+
# youtube-dl appears to be broken
13+
# https://github.com/ytdl-org/youtube-dl/issues/31530
14+
# Switching to yt-dlp
15+
16+
yt-dlp "$trimmedYoutubeID" --no-warnings --quiet -o -

0 commit comments

Comments
 (0)