-
Notifications
You must be signed in to change notification settings - Fork 231
usercmd
Click Here for all output options (Return to ToC)
get_iplayer NO LONGER SUPPORTS CONVERTING FILES TO CUSTOM FORMATS
THE EXAMPLES GIVEN BELOW ARE NOT SUPPORTED IN ANY WAY
DO NOT ASK FOR HELP IF YOU DO NOT UNDERSTAND THEM
YOU ARE RESPONSIBLE FOR YOUR OWN FILE CONVERSIONS AND OTHER USER COMMANDS
Use --command
to run a custom user command using substitution parameters after a successful recording of a TV or radio programme. Use --command-tv
or --command-radio
(which override --command
) for TV or radio programmes, respectively
- Only one
--command{-tv,-radio}
option may be specified, but it can execute multiple commands though the use of command separators and conditional operators appropriate to your command shell. You can also use shell scripts or batch files. - User commands may be added to preferences, presets and pvr jobs for ease of reuse.
- You will find it helpful to first work out the syntax of your user commands at a command prompt before using
--command{-tv,-radio}
.
Important: On Windows, substitution parameters (e.g., <filename>
) must not be located within quotes.
Examples of user commands to convert radio programmes to MP3 can be found here.
Ignore --get 123
in the following examples. It is merely a placeholder for whatever options you may be using to download programmes.
Unix/macOS:
get_iplayer --get 123 --command-tv='ffmpeg -i "<filename>" -c:v copy -c:a copy -y "<dir>/<fileprefix>.mkv"'
Windows:
get_iplayer --get 123 --command-tv="ffmpeg -i \""<filename>"\" -c:v copy -c:a copy -y \""<dir>\<fileprefix>".mkv\""
You can remux to an AVI file by changing .mkv
to .avi
in the commands above.
Create a preset named mp4tomkv
that can be used to remux TV programmes into MKV files by setting --command-tv
in preset:
Unix/macOS:
get_iplayer --prefs-add --preset=mp4tomkv --command-tv='ffmpeg -i "<filename>" -c:v copy -c:a copy -y "<dir>/<fileprefix>.mkv"'
Windows:
get_iplayer --prefs-add --preset=mp4tomkv --command-tv="ffmpeg -i \""<filename>"\" -c:v copy -c:a copy -y \""<dir>\<fileprefix>".mkv\""
Use the preset with recording commands. Examples:
get_iplayer --get 123 --preset=mp4tomkv
get_iplayer --pvr-add myshow --preset=mp4tomkv "^My Show$"
Unix/macOS:
get_iplayer --prefs-add --command-tv='ffmpeg -i "<filename>" -c:v copy -c:a copy -y "<dir>/<fileprefix>.mkv"'
Windows:
get_iplayer --prefs-add --command-tv="ffmpeg -i \""<filename>"\" -c:v copy -c:a copy -y \""<dir>\<fileprefix>".mkv\""
Remember to override --command-tv
on the command line if you want to do something different with your TV programmes.
NOTE: When you set --command-tv
in preferences, it will also be applied to downloads in the Web PVR Manager.
Use the instructions above for MKV and change mkv
to avi
.
Raw MPEG-DASH TV downloads consist of two files (one for audio, one for video), so a slightly different ffmpeg command is required to combine the two files during remuxing.
Unix/macOS:
get_iplayer --get 123 --exclude-format=hls --raw --command-tv='ffmpeg -i "<rawvideo>" -i "<rawaudio>" -c:v copy -c:a copy -y "<dir>/<fileprefix>.mkv"'
Windows:
get_iplayer --get 123 --exclude-format=hls --raw --command-tv="ffmpeg -i \""<rawvideo>"\" -i \""<rawaudio>"\" -c:v copy -c:a copy -y \""<dir>\<fileprefix>".mkv\""
The "h264_mp4toannexb" video filter must be used when remuxing a raw MPEG-DASH TV download to an AVI file.
Unix/macOS:
get_iplayer --get 123 --exclude-format=hls --raw --command-tv='ffmpeg -i "<rawvideo>" -i "<rawaudio>" -c:v copy -c:a copy -bsf:v h264_mp4toannexb -y "<dir>/<fileprefix>.avi"'
Windows:
get_iplayer --get 123 --exclude-format=hls --raw --command-tv="ffmpeg -i \""<rawvideo>"\" -i \""<rawaudio>"\" -c:v copy -c:a copy -bsf:v h264_mp4toannexb -y \""<dir>\<fileprefix>".avi\""
You can use XSLT to transform the XML metadata file for a programme into a .nfo
file.
Unix/macOS (with xsltproc):
get_iplayer --get 123 --metadata --command='xsltproc --output "<dir>/<fileprefix>.nfo" "/path/to/nfo.xsl" "<dir>/<fileprefix>.xml"'
Windows (with xsltproc):
get_iplayer --get 123 --metadata --command="xsltproc --output \""<dir>\<fileprefix>".nfo\" \"c:\path\to\nfo.xsl\" \""<dir>\<fileprefix>".xml\""
Windows (with xmlstarlet):
get_iplayer --get 123 --metadata --command="xml tr \"c:\path\to\nfo.xsl\" \""<dir>\<fileprefix>".xml\" > \""<dir>\<fileprefix>".nfo\""
where nfo.xsl
contains:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gip="http://linuxcentre.net/xmlstuff/get_iplayer"
exclude-result-prefixes="gip">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="gip:program_meta_data">
<episodedetails>
<aired><xsl:value-of select="gip:firstbcastdate"/></aired>
<episode><xsl:value-of select="gip:episodenum"/></episode>
<genre><xsl:value-of select="gip:category"/></genre>
<id><xsl:value-of select="gip:pid"/></id>
<plot><xsl:value-of select="gip:desclong"/></plot>
<season><xsl:value-of select="gip:seriesnum"/></season>
<studio><xsl:value-of select="gip:channel"/></studio>
<thumb><xsl:value-of select="gip:thumbnail"/></thumb>
<title><xsl:value-of select="gip:episodeshort"/></title>
</episodedetails>
</xsl:template>
</xsl:stylesheet>
You can use jq to transform the JSON metadata file for a programme into a .nfo
file.
Unix/macOS:
get_iplayer --get 123 --metadata=json --command='jq -f "/path/to/nfo.jq" -n -r -S --slurpfile meta "<dir>/<fileprefix>.json" > "<dir>/<fileprefix>.nfo"'
Windows:
get_iplayer --get 123 --metadata=json --command="jq -f \"c:\path\to\nfo.jq\" -n -r -S --slurpfile meta \""<dir>\<fileprefix>.json"\" > \""<dir>\<fileprefix>".nfo\""
where nfo.jq
contains:
"<?xml version=\"1.0\"?>
<episodedetails>
<aired>\($meta[0].firstbcastdate)</aired>
<episode>\($meta[0].episodenum)</episode>
<genre>\($meta[0].category)</genre>
<id>\($meta[0].pid)</id>
<plot>\($meta[0].desclong)</plot>
<season>\($meta[0].seriesnum)</season>
<studio>\($meta[0].channel)</studio>
<thumb>\($meta[0].thumbnail)</thumb>
<title>\($meta[0].episodeshort)</title>
</episodedetails>"