Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Related Tools

Notices

Reply
 
Thread Tools Search this Thread
Old 12-30-2014, 02:19 AM   #1
jammer699669
Junior Member
jammer699669 began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Dec 2014
Device: android
Syntax using ebook-Covert in PHP

syntax either will make or break the routine

I set up the 1.48 version on a headless server because the server doesn't have the correct libs for the new version
regular call with nothing extra and hoping that the converter will do everything fine
exec("ebook-convert ".$INepub." ". $OutMobi." 2>&1 ",$output);

exec("ebook-convert ".$INepub." ". $OutMobi." --authors \"$Taname\" --publisher \"$pub\" --comments \"$comments\" --tags \"$tags\" --pubdate \"$pubdate\" --isbn \"$spidout\" --title \"$Ttitle\" 2>&1 ",$output);
Spoiler:

The important part about this routine is that if you have any spaces in a string , you must escape the var or it will crash

AS well it does not handle UTF8 coding when sending so you have to strip any of that out from the var ahead of time

I use a function like this to do that
function ITSconvertchars( $str )
{
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'A', $str );
$str = str_replace( '', 'C', $str );
$str = str_replace( '', 'E', $str );
$str = str_replace( '', 'E', $str );
$str = str_replace( '', 'E', $str );
$str = str_replace( '', 'E', $str );
$str = str_replace( '', 'I', $str );
$str = str_replace( '', 'I', $str );
$str = str_replace( '', 'I', $str );
$str = str_replace( '', 'I', $str );
$str = str_replace( '', 'D', $str );
$str = str_replace( '', 'N', $str );
$str = str_replace( '', 'O', $str );
$str = str_replace( '', 'O', $str );
$str = str_replace( '', 'O', $str );
$str = str_replace( '', 'O', $str );
$str = str_replace( '', 'O', $str );
$str = str_replace( '', 'x', $str );
$str = str_replace( '', 'O', $str );
$str = str_replace( '', 'U', $str );
$str = str_replace( '', 'U', $str );
$str = str_replace( '', 'U', $str );
$str = str_replace( '', 'U', $str );
$str = str_replace( '', 'Y', $str );
$str = str_replace( '', 'p', $str );
$str = str_replace( '', 'b', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'a', $str );
$str = str_replace( '', 'c', $str );
$str = str_replace( '', 'e', $str );
$str = str_replace( '', 'e', $str );
$str = str_replace( '', 'e', $str );
$str = str_replace( '', 'e', $str );
$str = str_replace( '', 'i', $str );
$str = str_replace( '', 'i', $str );
$str = str_replace( '', 'i', $str );
$str = str_replace( '', 'i', $str );
$str = str_replace( '', 'o', $str );
$str = str_replace( '', 'n', $str );
$str = str_replace( '', 'o', $str );
$str = str_replace( '', 'o', $str );
$str = str_replace( '', 'o', $str );
$str = str_replace( '', 'o', $str );
$str = str_replace( '', 'o', $str );
$str = str_replace( '', '', $str );
$str = str_replace( '', 'o;', $str );
$str = str_replace( '', 'u', $str );
$str = str_replace( '', 'u', $str );
$str = str_replace( '', 'u', $str );
$str = str_replace( '', 'u', $str );
$str = str_replace( '', 'y', $str );
$str = str_replace( '', ';', $str );
// ms word replacements
$str = str_replace( '‚', ",", $str ); // 130 or ‚ or chr(130) = ‚
$str = str_replace( 'ƒ', 'NLG', $str ); //131 or ƒ or chr(131) = ƒ

$str = str_replace( '„', '"', $str ); //132 or „ or chr(132) = „
$str = str_replace( '…', '...', $str ); //133 or … or chr(133) = …
$str = str_replace( '†', '**', $str ); //134 or † or chr(134) = †
$str = str_replace( '‡', '***', $str ); //135 or ‡ or chr(135) = ‡
$str = str_replace( 'ˆ', '^', $str ); //136 or ˆ or chr(136) = ˆ
$str = str_replace( '‰', 'o/oo', $str ); //137 or ‰ or chr(137) = ‰
$str = str_replace( 'Š', 'Sh', $str ); //138 or Š or chr(138) = Š
$str = str_replace( '‹', '<', $str ); //139 or ‹ or chr(139) = ‹
$str = str_replace( 'Œ', 'OE', $str ); //140 or Œ or chr(140) = Œ
$str = str_replace( '‘', "'", $str ); //145 or ‘ or chr(145) = ‘
$str = str_replace( '’', "'", $str );// 146 or ’ or chr(146) = ’
$str = str_replace( '“', '"', $str ); // 147 or “ or chr(147) = “
$str = str_replace( '”', '"', $str ); // 148 or ” or chr(148) = ”
$str = str_replace( '•', '-', $str ); // 149 or • or chr(149) = •
$str = str_replace( '–', '--', $str ); // 150 or – or chr(150) = –
$str = str_replace( '—', '-', $str ); // 151 or — or chr(151) = —
$str = str_replace( '˜', '~', $str ); // 152 or ˜ or chr(152) = ˜
$str = str_replace( '™', '(TM)', $str ); // 153 or ™ or chr(153) = ™
$str = str_replace( 'š', 'sh', $str ); // 154 or š or chr(154) = š
$str = str_replace( '›', '>', $str ); // 155 or › or chr(155) = ›
$str = str_replace( 'œ', 'oe', $str ); // 156 or œ or chr(156) = œ
$str = str_replace( 'Ÿ', 'Y', $str ); // 159 or Ÿ or chr(159) = Ÿ

}


Hope this helps someone

Last edited by theducks; 12-30-2014 at 10:38 AM. Reason: Wrapped long paste in Spoiler
jammer699669 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ebook covert Recipe to .mobi in cmd error coslada Conversion 2 01-13-2013 06:16 AM
Call ebook-convert from PHP using exec/shell_exec techsp123 Conversion 1 07-13-2012 11:47 AM
ebook-convert syntax breakdown lordvetinari2 Calibre 0 06-18-2010 07:35 PM
Running ebook-convert from php conryf Calibre 7 05-24-2010 06:24 AM


All times are GMT -4. The time now is 02:17 PM.


MobileRead.com is a privately owned, operated and funded community.