<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"version="1.0"type="px:daisy202-to-mp3.script"name="main">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h1px:role="name">DAISY 2.02 to navigable MP3 file-set</h1><ppx:role="desc">Transforms a DAISY 2.02 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/daisy202-to-mp3/">
Online documentation
</a>
</p:documentation>
<p:optionname="source"required="true"px:type="anyFileURI"px:media-type="application/xhtml+xml text/html">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">DAISY 2.02</h2><ppx:role="desc">The NCC file of the input DAISY 2.02.</p>
</p:documentation>
</p:option><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/daisy202-utils/library.xpl">
<p:documentation>
px:daisy202-load
</p:documentation>
</p:import>
<p:importhref="http://www.daisy.org/pipeline/modules/fileset-utils/library.xpl">
<p:documentation>
px:fileset-store
px:fileset-delete
</p:documentation>
</p:import>
<p:importhref="daisy202-to-mp3.xpl">
<p:documentation>
px:daisy202-to-mp3
</p:documentation>
</p:import>
<px:daisy202-loadname="load"px:progress="1/10"px:message="Loading DAISY 2.02">
<p:documentation>Lists SMILS in reading order.</p:documentation>
<p:with-optionname="ncc"select="$source"/>
</px:daisy202-load>
<px:daisy202-to-mp3name="convert"px:progress="8/10"px:message="Rearranging audio into folder structure">
<p:inputport="source.in-memory">
<p:pipestep="load"port="in-memory.out"/>
</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:daisy202-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>