Skip to content

Commit bf50660

Browse files
committed
Take links to videos as gallery submissions, resolved with yt-dlp
Any https URL in a submission issue that is not a GitHub attachment is handed to yt-dlp, and the file it resolves to goes through the same sniffing, ffmpeg and duplicate checks as an attachment does. Every bound is a flag: no configuration or cache, one video even for a playlist link, no live streams, five minutes at most, and a size budget expressed as format filters so that an oversized 1080p rendition falls back to 720p instead of aborting the download thirty megabytes in. H.264 is preferred because a gallery is played in a video tag on whatever phone is to hand, and AV1, which is what YouTube otherwise serves as its best mp4, does not decode on most of them yet. The output path is yt-dlp's to report and ours to check. The workflow installs the latest yt-dlp release, since an old one is one that no longer works, and Deno for YouTube. The Nix shell gains both, and the submit button's guidance says that a link is welcome.
1 parent 6efca51 commit bf50660

5 files changed

Lines changed: 396 additions & 62 deletions

File tree

‎.github/workflows/submission.yaml‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#
33
# Two kinds of issue arrive through the site: a comment, written into the
44
# compose box on a page, and a gallery submission, pictures dropped into the
5-
# issue. Both are handled here, in one workflow rather than one each, because
6-
# GitHub records a run for every workflow that listens to an event whether its
7-
# job ran or not — with two workflows, every comment produced a skipped gallery
8-
# run and every gallery submission a skipped comment run, and the list of runs
9-
# was half noise. `route` reads the issue once and says which kind it is; the
10-
# other job is skipped inside the same run.
5+
# issue or links to videos pasted in. Both are handled here, in one workflow
6+
# rather than one each, because GitHub records a run for every workflow that
7+
# listens to an event whether its job ran or not — with two workflows, every
8+
# comment produced a skipped gallery run and every gallery submission a skipped
9+
# comment run, and the list of runs was half noise. `route` reads the issue
10+
# once and says which kind it is; the other job is skipped inside the same run.
1111
#
1212
# Either way the shape is the same: a job checks out the default branch, runs
1313
# the one `site` subcommand that does the whole of the validation, checks the
@@ -237,8 +237,9 @@ jobs:
237237
needs: route
238238
if: needs.route.outputs.kind == 'gallery'
239239
runs-on: ubuntu-latest
240-
# A ceiling on the whole job: as many as twenty downloads from GitHub, and
241-
# a re-encode of each, should never come near this.
240+
# A ceiling on the whole job, because a link a stranger pasted is a download
241+
# from wherever they like at whatever speed it answers. yt-dlp is given its
242+
# own limits; this is the one behind them.
242243
timeout-minutes: 30
243244
permissions:
244245
contents: write
@@ -267,6 +268,24 @@ jobs:
267268
sudo apt-get update
268269
sudo apt-get install --no-install-recommends --yes ffmpeg
269270
271+
# yt-dlp resolves a pasted link to the video behind it. The release
272+
# binary rather than a pinned package, because sites change how they
273+
# serve video every few weeks and an old yt-dlp is one that no longer
274+
# works; the project's own release is the one source with nothing between
275+
# it and us. Deno is the JavaScript runtime it needs for YouTube, which
276+
# is where most of these links will point.
277+
- name: Install yt-dlp
278+
run: |
279+
set -euo pipefail
280+
curl -sS --fail --location --proto '=https' --proto-redir '=https' \
281+
--output /usr/local/bin/yt-dlp \
282+
https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
283+
sudo chmod a+rx /usr/local/bin/yt-dlp
284+
yt-dlp --version
285+
- uses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5
286+
with:
287+
deno-version: v2.x
288+
270289
# Built with default features on, unlike the comment job: re-encoding the
271290
# stills is the whole point of the exercise, and that is the `photos`
272291
# feature.

‎flake.nix‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
# `site normalize-gallery` remuxes a video to take the metadata out
3232
# of it, which is the one thing it cannot do for itself.
3333
ffmpeg
34+
# `site gallery-from-issue` resolves a pasted link with yt-dlp, which
35+
# needs a JavaScript runtime for YouTube.
36+
yt-dlp
37+
deno
3438
git
3539
gcc
3640
gnugrep

‎tools/site/src/main.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ Commands:
201201
check-comment-changes CI-only: refuse a pull request that touches
202202
somebody else's comment
203203
gallery-from-issue CI-only: add the files attached to a submission
204-
issue to the gallery it names
204+
issue, and the videos it links to, to the gallery
205+
it names
205206
check run Rust, TypeScript, and lint checks
206207
check-links [DIR] check that every local link in public/ resolves
207208
update run dependency updates and linters

0 commit comments

Comments
 (0)