Skip to content

Instantly share code, notes, and snippets.

@velnias75
Last active April 15, 2017 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velnias75/95d58bade5a435b562e13b0c95cbca6c to your computer and use it in GitHub Desktop.
Save velnias75/95d58bade5a435b562e13b0c95cbca6c to your computer and use it in GitHub Desktop.
XSLT-template to output a VLC playlist suitable to convert to MP4 files
<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:strings="http://exslt.org/strings"
xmlns:xspf="http://xspf.org/ns/0/">
<output method="text" encoding="utf-8"/>
<variable name="apos">'</variable>
<param name="outdir" select="'/data1/var/tmp'"/>
<param name="pre" select="'avconv -ec guess_mvs -i '"/>
<param name="mid1" select="' -preset veryslow -tune film -acodec libfdk_aac -metadata title='"/>
<param name="mid2" select="' -metadata:s:a language=ger -threads auto -f mp4 -y '"/>
<param name="post" select="'&#xa;&#xa;'"/>
<template match="/">
<text>&#xa;</text>
<apply-templates select="xspf:playlist/xspf:trackList/xspf:track"/>
</template>
<template match="xspf:track">
<apply-templates select="xspf:location"/>
</template>
<template match="*">
<param name="input" select="normalize-space(strings:replace(strings:decode-uri(.), 'file://', ''))"/>
<param name="output" select="concat($outdir, '/', strings:split(strings:replace(strings:replace(strings:replace(strings:replace(strings:replace(strings:replace(strings:replace(strings:replace(strings:replace($input, ':', ' -'), '?', ''), 'ß', 'ss'), 'ä', 'ae'), 'ö', 'oe'), 'ü', 'ue'), '. ', 'te '), ',', ''), '&amp;', 'and'), '/')[last()])"/>
<param name="title" select="strings:replace(strings:split($input, '/')[last()], '.mpg', '')"/>
<value-of select="concat($pre, $apos, $input, $apos, $mid1, $apos, $title, $apos, $mid2, $apos, strings:replace($output, '.mpg', '.mp4'), $apos, $post)"/>
</template>
</stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment