copyparty/bin/hooks/README.md
Soap e85e09360d
add reference to yt-dlp hook
Signed-off-by: Soap <soaibkhan38@gmail.com>
2025-10-09 14:57:29 +05:30

3.8 KiB

standalone programs which are executed by copyparty when an event happens (upload, file rename, delete, ...)

these programs either take zero arguments, or a filepath (the affected file), or a json message with filepath + additional info

run copyparty with --help-hooks for usage details / hook type explanations (xm/xbu/xau/xiu/xbc/xac/xbr/xar/xbd/xad/xban)

note: in addition to event hooks (the stuff described here), copyparty has another api to run your programs/scripts while providing way more information such as audio tags / video codecs / etc and optionally daisychaining data between scripts in a processing pipeline; if that's what you want then see mtp plugins instead

after upload

upload batches

these are --xiu hooks; unlike xbu and xau (which get executed on every single file), xiu hooks are given a list of recent uploads on STDIN after the server has gone idle for N seconds, reducing server load + providing more context

  • xiu.py is a "minimal" example showing a list of filenames + total filesize
  • xiu-sha.py produces a sha512 checksum list in the volume root

before upload

  • reject-extension.py rejects uploads if they match a list of file extensions
  • reloc-by-ext.py redirects an upload to another destination based on the file extension
  • reject-and-explain.py shows a custom error-message when it rejects an upload
  • reject-ramdisk.py rejects the upload if the destination is a ramdisk
    • this hook uses the I flag which makes it 140x faster, but if the plugin has a bug it may crash copyparty

on message

  • wget.py lets you download files by POSTing URLs to copyparty
    • wget-i.py is an import-safe modification of this hook (starts 140x faster, but higher chance of bugs)
  • qbittorrent-magnet.py starts downloading a torrent if you post a magnet url
  • usb-eject.py adds web-UI buttons to safe-remove usb flashdrives shared through copyparty
  • msg-log.py is a guestbook; logs messages to a doc in the same folder
  • ytdlp-i.py is an import-safe hook, based on wget.py, adds yt-dlp and aria2 support
    • allows downloading file via URLs, yt-dlp supported links, any link downloadable with aria2 (including magnets)

general concept demos

  • import-me.py shows how the I flag makes the hook 140x faster (but you need to be Very Careful when writing the plugin)