<p:declare-stepxmlns:p="http://www.w3.org/ns/xproc"xmlns:px="http://www.daisy.org/ns/pipeline/xproc"xmlns:cx="http://xmlcalabash.com/ns/extensions"xmlns:xs="http://www.w3.org/2001/XMLSchema"version="1.0"type="px:daisy3-to-mp3.script"name="main"px:input-filesets="daisy3"px:output-filesets="mp3">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h1px:role="name">DAISY 3 to navigable MP3 file-set</h1><ppx:role="desc">Transforms a DAISY 3 publication into a folder structure with MP3 files suitable for playback on MegaVoice Envoy devices.</p>
<apx:role="homepage"href="http://daisy.github.io/pipeline/Get-Help/User-Guide/Scripts/daisy3-to-mp3/">
Online documentation
</a>
</p:documentation>
<p:inputport="source"px:media-type="application/oebps-package+xml">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">DAISY 3</h2><ppx:role="desc">The package file (OPF) of the input DAISY 3.</p>
</p:documentation>
</p:input><p:optionname="folder-depth"select="'1'"><p:pipeinfo><px:type>
<choicexmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<value>1</value>
<a:documentationxml:lang="en"xml:space="preserve">1
Produces a folder structure that is one level deep. At the top level there is 1 folder, that
contains entire book. This folder can have up to 999 MP3 files. Each MP3 file corresponds with a
top-level section of the book. This setting is suited for simple devices of type Envoy Connect/Vine
C2.</a:documentation>
<value>2</value>
<a:documentationxml:lang="en"xml:space="preserve">2
Produces a folder structure that is two levels deep. At the top level there is 1 folder that
contains entire book. This folder can have up to 999 sub-folders, each of which can contain up to
999 MP3 files. Each MP3 file corresponds with a level-two section, a top-level section without
sub-sections, or the content within a top-level section before the first
sub-section.</a:documentation>
<value>3</value>
<a:documentationxml:lang="en"xml:space="preserve">3
Produces a folder structure that is three levels deep. At the top level there is 1 folder that
contains entire book. This folder can have up to 999 sub-folders. The sub-folders can have up to 999
sub-sub-folders, each of which can contain up to 999 MP3 files. Each MP3 file corresponds with a
level-three section, a top-level or level-two section without sub-sections, or the content within a
top-level or level-two section before the first sub-section.</a:documentation>
</choice>
</px:type></p:pipeinfo><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Folder depth</h2><ppx:role="desc"xml:space="preserve">The number of folder levels in the produced folder structure.
The book is always, if possible, contained in a single top-level folder with MP3 files or
sub-folders (files for folder depth 1, sub-folders for folder depths greater than 1) that correspond
with top-level sections of the book.
If there are more top-level sections than the maximum number of files/folders that a top-level
folder can contain, the book is divided over multiple top-level folders. Similarly, if the number of
level-two sections within a top-level section exceeds the maximum number of files/folders that a
level-two folder can contain, the top-level section is divided over multiple level-two folders.</p>
</p:documentation>
</p:option><p:optionname="result"required="true"px:output="result"px:type="anyDirURI"px:media-type="text">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">MP3 files</h2><ppx:role="desc">The produced folder structure with MP3 files.</p>
</p:documentation>
</p:option>
<p:importhref="http://www.daisy.org/pipeline/modules/daisy3-utils/library.xpl">
<p:documentation>
px:daisy3-load
</p:documentation>
</p:import>
<p:importhref="http://www.daisy.org/pipeline/modules/fileset-utils/library.xpl">
<p:documentation>
px:fileset-create
px:fileset-add-entry
px:fileset-store
px:fileset-delete
</p:documentation>
</p:import>
<p:importhref="daisy3-to-mp3.xpl">
<p:documentation>
px:daisy3-to-mp3
</p:documentation>
</p:import>
<px:fileset-create>
<p:with-optionname="base"select="resolve-uri('./',base-uri(/*))"/>
</px:fileset-create>
<px:fileset-add-entrymedia-type="application/oebps-package+xml">
<p:inputport="entry">
<p:pipestep="main"port="source"/>
</p:input>
</px:fileset-add-entry>
<px:daisy3-loadname="load"px:progress="1/10"px:message="Loading DAISY 3">
<p:documentation>Lists SMILS in spine order.</p:documentation>
</px:daisy3-load>
<px:daisy3-to-mp3name="convert"px:progress="8/10"px:message="Rearranging audio into folder structure">
<p:inputport="source.in-memory">
<p:pipestep="load"port="result.in-memory"/>
</p:input>
<p:with-optionname="file-limit"select=" if ($folder-depth='1') then [ 1,999] else if ($folder-depth='2') then [ 1,999,999] else (: $folder-depth='3' :) [1,999,999,999]"/>
<p:with-optionname="level-offset"select="1"/>
<p:with-optionname="output-dir"select="$result"/>
<p:with-optionname="temp-dir"select="$temp-dir"/>
</px:daisy3-to-mp3>
<px:fileset-storepx:progress="1/10"name="store"px:message="Storing MP3 files"/>
<px:fileset-deletecx:depends-on="store">
<p:inputport="source">
<p:pipestep="convert"port="temp-files"/>
</p:input>
</px:fileset-delete>
</p:declare-step>