Merge from trunk

This commit is contained in:
Charles Haley 2012-09-16 19:55:26 +02:00
commit 2981ddf0a5
65 changed files with 7905 additions and 1363 deletions

View File

@ -19,6 +19,50 @@
# new recipes: # new recipes:
# - title: # - title:
- version: 0.8.69
date: 2012-09-14
new features:
- title: "E-book viewer: Add a button to the toolbar to switch themes easily"
tickets: [1047992]
- title: "When downloading metadata for many books, if some of them fail, add an option to the downloaded message to show the failed books in the main book list, so that they can be individually processed easily"
- title: "Remember last used window size of the conversion dialogs."
tickets: [1049265]
- title: "Kindle driver: Turn on sending of azw3 files to kindles by default, since the KK now has azw3 support"
- title: "Conversion: Add support for CSS pseudo classes :hover, :link, :visited, :first-line, :focus, :active, :first-letter"
- title: "Wireless device driver: Make the default save template not use folders"
bug fixes:
- title: "Fix a regression in th previous release that broke sending of books to the second SD card in SONY readers"
tickets: [1047992]
- title: "Fix a memory leak when scanning for devices in windows"
- title: "Ebook-viewer: When displaying mathematics, reflow equations that dont fit on a single line"
- title: "Catalogs: Do not mark the AZW3 catalog as a periodical, as most Kindle devices cannot handle AZW3 periodicals"
- title: "Content server: When using a custom IP address to listen on via Preferences->Tweaks advertise that IP address via BonJour."
- title: "Fix ebook catalog generation on linux systems where the encoding is not UTF-8."
tickets: [1048404]
improved recipes:
- De Volksrant
- Metro UK
- Countryfile
- Die Zeit (subscription)
- Birmingham post
new recipes:
- title: History Today
author: Rick Shang
- version: 0.8.68 - version: 0.8.68
date: 2012-09-07 date: 2012-09-07

View File

@ -9,7 +9,7 @@ the file are big-endian.
Layout Layout
------ ------
bytes content comments bytes content comments
4 00010001 Format identifier. Value of 65537 little-endian. 4 00010001 Format identifier. Value of 65537 little-endian.
4 start of next The offset after ending location of the first header. 4 start of next The offset after ending location of the first header.
@ -25,7 +25,7 @@ Starts next sequence
2 unknown Always 32 2 unknown Always 32
N second header String containing the page mapping header N second header String containing the page mapping header
4*N padding The first number given in the page mapping header indicates the number of 0 bytes. 4*N padding The first number given in the page mapping header indicates the number of 0 bytes.
4*N page list 4*N page list
Content Header Content Header
@ -44,6 +44,14 @@ Example:
{"contentGuid":"d8c14b0","asin":"B000JML5VM","cdeType":"EBOK","fileRevisionId":"1296874359405"} {"contentGuid":"d8c14b0","asin":"B000JML5VM","cdeType":"EBOK","fileRevisionId":"1296874359405"}
In devices with KF8 support, we're seeing an extended content header (which seems to be required by some FW versions for KF8 files, like FW 3.4):
format Mobi version. MOBI_8 for KF8, MOBI_7 for legacy mobi files.
acr Palm DB name
Example:
{"contentGuid":"f2fc7597","asin":"B003M68YKM","cdeType":"EBOK","format":"MOBI_8","fileRevisionId":"1342776186889","acr":"CR!1F5WDHWWVN4Y78MA87Z13H9K6RKE"}
Page Mapping Header Page Mapping Header
------------------- -------------------

BIN
icons/install.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

237
imgsrc/mimetypes/azw2.svg Normal file
View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="128"
height="128"
id="svg2606"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="azw2.svg"
inkscape:export-filename="/home/niluje/Patchland/calibre/imgsrc/mimetypes/azw2.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1025"
id="namedview45"
showgrid="false"
inkscape:zoom="1.84375"
inkscape:cx="-11.118644"
inkscape:cy="42.305085"
inkscape:window-x="-2"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg2606" />
<defs
id="defs2608">
<linearGradient
id="linearGradient10207">
<stop
id="stop10209"
style="stop-color:#a2a2a2;stop-opacity:1"
offset="0" />
<stop
id="stop10211"
style="stop-color:#ffffff;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
x1="96"
y1="104"
x2="88.000198"
y2="96.000198"
id="XMLID_12_"
gradientUnits="userSpaceOnUse">
<stop
id="stop83"
style="stop-color:#888a85;stop-opacity:1"
offset="0" />
<stop
id="stop85"
style="stop-color:#8c8e89;stop-opacity:1"
offset="0.0072" />
<stop
id="stop87"
style="stop-color:#abaca9;stop-opacity:1"
offset="0.0673" />
<stop
id="stop89"
style="stop-color:#c5c6c4;stop-opacity:1"
offset="0.1347" />
<stop
id="stop91"
style="stop-color:#dbdbda;stop-opacity:1"
offset="0.2652576" />
<stop
id="stop93"
style="stop-color:#ebebeb;stop-opacity:1"
offset="0.37646064" />
<stop
id="stop95"
style="stop-color:#f7f7f6;stop-opacity:1"
offset="0.48740286" />
<stop
id="stop97"
style="stop-color:#fdfdfd;stop-opacity:1"
offset="0.6324091" />
<stop
id="stop99"
style="stop-color:#ffffff;stop-opacity:1"
offset="1" />
</linearGradient>
<radialGradient
cx="102"
cy="112.3047"
r="139.55859"
id="XMLID_8_"
gradientUnits="userSpaceOnUse">
<stop
id="stop41"
style="stop-color:#b7b8b9;stop-opacity:1"
offset="0" />
<stop
id="stop47"
style="stop-color:#ececec;stop-opacity:1"
offset="0.18851049" />
<stop
id="stop49"
style="stop-color:#fafafa;stop-opacity:1"
offset="0.25718147" />
<stop
id="stop51"
style="stop-color:#ffffff;stop-opacity:1"
offset="0.30111277" />
<stop
id="stop53"
style="stop-color:#fafafa;stop-opacity:1"
offset="0.53130001" />
<stop
id="stop55"
style="stop-color:#ebecec;stop-opacity:1"
offset="0.84490001" />
<stop
id="stop57"
style="stop-color:#e1e2e3;stop-opacity:1"
offset="1" />
</radialGradient>
<filter
x="-0.19200002"
y="-0.19199999"
width="1.3839999"
height="1.3839999"
color-interpolation-filters="sRGB"
id="filter6697">
<feGaussianBlur
id="feGaussianBlur6699"
stdDeviation="1.9447689" />
</filter>
<clipPath
id="clipPath7084">
<path
d="m 72,88 -32,32 -8,0 0,-40 40,0 0,8 z"
id="path7086"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" />
</clipPath>
<radialGradient
cx="102"
cy="112.3047"
r="139.55859"
id="radialGradient9437"
xlink:href="#XMLID_8_"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.9996653,2e-6,0.00301608)" />
<linearGradient
x1="98.617439"
y1="106.41443"
x2="91.228737"
y2="99.254974"
id="linearGradient10213"
xlink:href="#linearGradient10207"
gradientUnits="userSpaceOnUse" />
<filter
color-interpolation-filters="sRGB"
id="filter2770">
<feGaussianBlur
id="feGaussianBlur2772"
stdDeviation="2.0786429" />
</filter>
</defs>
<metadata
id="metadata2611">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
d="m 16,8 0,112 c 0,0 63.15625,0 63.15625,0 l 0.03125,0 c 3e-6,0 11.90625,-9.90625 17.40625,-15.40625 C 102.09375,99.09375 112,87.1875 112,87.1875 L 112,87.15625 112,8 16,8 z"
transform="matrix(1.0416667,0,0,1.0267857,-2.6666667,-1.2142891)"
id="path7865"
style="opacity:0.5;fill:#000000;fill-opacity:1;filter:url(#filter2770)" />
<path
d="M 16.000001,8 16,120 c 0,0 63.146418,0 63.146418,0 L 112,87.14642 112,8 16.000001,8 z"
id="path34"
style="fill:#ffffff;fill-opacity:1" />
<path
d="m 18.000002,9.0000034 c -0.551,0 -1,0.44885 -1,0.999665 l 0,107.9638516 c 0,0.55181 0.449,0.99966 1,0.99966 l 59.171997,0 c 0.263,0 2.76268,0.11813 2.948681,-0.0688 L 110.707,88.094202 C 110.894,87.907264 111,85.40942 111,85.146508 l 0,-75.1468396 c 0,-0.550815 -0.448,-0.999665 -1,-0.999665 l -91.999998,0 z"
id="path59"
style="fill:url(#radialGradient9437);fill-opacity:1" />
<path
d="m 41.879531,115.98249 c 0,0 24.309609,-24.309614 24.309609,-24.309614 0,0 -9.35314,2.913124 -19.60314,2.913124 0,10.25 -4.706469,21.39649 -4.706469,21.39649 z"
transform="translate(40,0)"
clip-path="url(#clipPath7084)"
id="path5540"
style="opacity:0.4;fill:#000000;fill-opacity:1;filter:url(#filter6697)" />
<path
d="m 79.172,120 c 0,0 11.914,-9.914 17.414,-15.414 5.5,-5.5 15.414,-17.414 15.414,-17.414 0,0 -13.75,8.828 -24,8.828 0,10.25 -8.828,24 -8.828,24 z"
id="path14523"
style="fill:url(#linearGradient10213);fill-opacity:1" />
<text
x="63.980469"
y="32.160156"
id="text3772"
xml:space="preserve"
style="font-size:24px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3021"
x="63.980469"
y="32.160156">Kindlet</tspan></text>
<path
d="m 68.227,60.477999 c 0,2.157 0.052,3.954 -1.035,5.874 -0.88,1.561 -2.279,2.517 -3.833,2.517 -2.121,0 -3.366,-1.62 -3.366,-4.015 C 59.993,60.14 64.225,59.283 68.226,59.283 v 1.194999 z m 5.579,13.496 c -0.365,0.332 -0.896,0.352 -1.307,0.132 -1.838,-1.528 -2.167,-2.231 -3.174,-3.69 -3.035,3.094 -5.188,4.023 -9.123,4.023 -4.663,0 -8.284,-2.876 -8.284,-8.629 0,-4.49 2.433,-7.543999 5.899,-9.044999 3.005,-1.317 7.202,-1.556 10.41,-1.914 v -0.723 c 0,-1.313 0.104,-2.875 -0.671,-4.012 -0.674,-1.021 -1.968,-1.437 -3.106,-1.437 -2.111,0 -3.99,1.078 -4.45,3.321 -0.097,0.498 -0.46,0.991 -0.962,1.017 l -5.364,-0.581 c -0.456,-0.102 -0.958,-0.463 -0.828,-1.155 1.233,-6.511 7.109,-8.475 12.378,-8.475 2.693,0 6.215,0.719 8.335,2.757 2.692997,2.515 2.431997,5.869 2.431997,9.524 v 8.622999 c 0,2.596 1.081,3.732 2.091,5.128 0.354,0.503 0.434,1.103 -0.018,1.473 -1.131,0.949 -3.138997,2.693 -4.243997,3.676 l -0.014,-0.013 z"
id="path4047"
style="fill-rule:evenodd" />
<path
d="m 99.325111,79.885297 c -8.716894,6.432161 -21.357191,9.853809 -32.243032,9.853809 -15.251419,0 -28.989193,-5.636741 -39.38419,-15.021522 -0.815557,-0.738364 -0.08726,-1.746902 0.89191,-1.173831 C 39.807066,80.071565 53.675732,84 68,84 c 9.664184,0 20.284886,-2.004491 30.058986,-6.151079 1.474215,-0.623415 2.709284,0.97246 1.266125,2.036376 z"
id="path3858"
style="fill:#ff9201;fill-rule:evenodd" />
<path
d="m 104,76 c -1.11342,-1.426386 -7.371903,-0.676274 -10.179364,-0.337298 -0.853315,0.09817 -0.984206,-0.641874 -0.217315,-1.184739 4.990671,-3.505554 13.168059,-2.491141 14.119539,-1.318987 0.95736,1.187256 -0.25087,9.384779 -4.92858,13.293915 -0.71907,0.604117 -1.40373,0.286117 -1.08573,-0.510142 C 102.75988,83.311486 105.11761,77.427225 104,76 z"
id="path3860"
style="fill:#ff9201;fill-rule:evenodd" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.1 KiB

237
imgsrc/mimetypes/azw3.svg Normal file
View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="128"
height="128"
id="svg2606"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="azw3.svg"
inkscape:export-filename="/home/niluje/Patchland/calibre/imgsrc/mimetypes/azw3.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1025"
id="namedview45"
showgrid="false"
inkscape:zoom="1.84375"
inkscape:cx="-11.118644"
inkscape:cy="42.305085"
inkscape:window-x="-2"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg2606" />
<defs
id="defs2608">
<linearGradient
id="linearGradient10207">
<stop
id="stop10209"
style="stop-color:#a2a2a2;stop-opacity:1"
offset="0" />
<stop
id="stop10211"
style="stop-color:#ffffff;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
x1="96"
y1="104"
x2="88.000198"
y2="96.000198"
id="XMLID_12_"
gradientUnits="userSpaceOnUse">
<stop
id="stop83"
style="stop-color:#888a85;stop-opacity:1"
offset="0" />
<stop
id="stop85"
style="stop-color:#8c8e89;stop-opacity:1"
offset="0.0072" />
<stop
id="stop87"
style="stop-color:#abaca9;stop-opacity:1"
offset="0.0673" />
<stop
id="stop89"
style="stop-color:#c5c6c4;stop-opacity:1"
offset="0.1347" />
<stop
id="stop91"
style="stop-color:#dbdbda;stop-opacity:1"
offset="0.2652576" />
<stop
id="stop93"
style="stop-color:#ebebeb;stop-opacity:1"
offset="0.37646064" />
<stop
id="stop95"
style="stop-color:#f7f7f6;stop-opacity:1"
offset="0.48740286" />
<stop
id="stop97"
style="stop-color:#fdfdfd;stop-opacity:1"
offset="0.6324091" />
<stop
id="stop99"
style="stop-color:#ffffff;stop-opacity:1"
offset="1" />
</linearGradient>
<radialGradient
cx="102"
cy="112.3047"
r="139.55859"
id="XMLID_8_"
gradientUnits="userSpaceOnUse">
<stop
id="stop41"
style="stop-color:#b7b8b9;stop-opacity:1"
offset="0" />
<stop
id="stop47"
style="stop-color:#ececec;stop-opacity:1"
offset="0.18851049" />
<stop
id="stop49"
style="stop-color:#fafafa;stop-opacity:1"
offset="0.25718147" />
<stop
id="stop51"
style="stop-color:#ffffff;stop-opacity:1"
offset="0.30111277" />
<stop
id="stop53"
style="stop-color:#fafafa;stop-opacity:1"
offset="0.53130001" />
<stop
id="stop55"
style="stop-color:#ebecec;stop-opacity:1"
offset="0.84490001" />
<stop
id="stop57"
style="stop-color:#e1e2e3;stop-opacity:1"
offset="1" />
</radialGradient>
<filter
x="-0.19200002"
y="-0.19199999"
width="1.3839999"
height="1.3839999"
color-interpolation-filters="sRGB"
id="filter6697">
<feGaussianBlur
id="feGaussianBlur6699"
stdDeviation="1.9447689" />
</filter>
<clipPath
id="clipPath7084">
<path
d="m 72,88 -32,32 -8,0 0,-40 40,0 0,8 z"
id="path7086"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" />
</clipPath>
<radialGradient
cx="102"
cy="112.3047"
r="139.55859"
id="radialGradient9437"
xlink:href="#XMLID_8_"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.9996653,2e-6,0.00301608)" />
<linearGradient
x1="98.617439"
y1="106.41443"
x2="91.228737"
y2="99.254974"
id="linearGradient10213"
xlink:href="#linearGradient10207"
gradientUnits="userSpaceOnUse" />
<filter
color-interpolation-filters="sRGB"
id="filter2770">
<feGaussianBlur
id="feGaussianBlur2772"
stdDeviation="2.0786429" />
</filter>
</defs>
<metadata
id="metadata2611">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
d="m 16,8 0,112 c 0,0 63.15625,0 63.15625,0 l 0.03125,0 c 3e-6,0 11.90625,-9.90625 17.40625,-15.40625 C 102.09375,99.09375 112,87.1875 112,87.1875 L 112,87.15625 112,8 16,8 z"
transform="matrix(1.0416667,0,0,1.0267857,-2.6666667,-1.2142891)"
id="path7865"
style="opacity:0.5;fill:#000000;fill-opacity:1;filter:url(#filter2770)" />
<path
d="M 16.000001,8 16,120 c 0,0 63.146418,0 63.146418,0 L 112,87.14642 112,8 16.000001,8 z"
id="path34"
style="fill:#ffffff;fill-opacity:1" />
<path
d="m 18.000002,9.0000034 c -0.551,0 -1,0.44885 -1,0.999665 l 0,107.9638516 c 0,0.55181 0.449,0.99966 1,0.99966 l 59.171997,0 c 0.263,0 2.76268,0.11813 2.948681,-0.0688 L 110.707,88.094202 C 110.894,87.907264 111,85.40942 111,85.146508 l 0,-75.1468396 c 0,-0.550815 -0.448,-0.999665 -1,-0.999665 l -91.999998,0 z"
id="path59"
style="fill:url(#radialGradient9437);fill-opacity:1" />
<path
d="m 41.879531,115.98249 c 0,0 24.309609,-24.309614 24.309609,-24.309614 0,0 -9.35314,2.913124 -19.60314,2.913124 0,10.25 -4.706469,21.39649 -4.706469,21.39649 z"
transform="translate(40,0)"
clip-path="url(#clipPath7084)"
id="path5540"
style="opacity:0.4;fill:#000000;fill-opacity:1;filter:url(#filter6697)" />
<path
d="m 79.172,120 c 0,0 11.914,-9.914 17.414,-15.414 5.5,-5.5 15.414,-17.414 15.414,-17.414 0,0 -13.75,8.828 -24,8.828 0,10.25 -8.828,24 -8.828,24 z"
id="path14523"
style="fill:url(#linearGradient10213);fill-opacity:1" />
<text
x="64.392578"
y="32.103516"
id="text3772"
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3026"
x="64.392578"
y="32.103516">KF8</tspan></text>
<path
d="m 68.227,60.477999 c 0,2.157 0.052,3.954 -1.035,5.874 -0.88,1.561 -2.279,2.517 -3.833,2.517 -2.121,0 -3.366,-1.62 -3.366,-4.015 C 59.993,60.14 64.225,59.283 68.226,59.283 v 1.194999 z m 5.579,13.496 c -0.365,0.332 -0.896,0.352 -1.307,0.132 -1.838,-1.528 -2.167,-2.231 -3.174,-3.69 -3.035,3.094 -5.188,4.023 -9.123,4.023 -4.663,0 -8.284,-2.876 -8.284,-8.629 0,-4.49 2.433,-7.543999 5.899,-9.044999 3.005,-1.317 7.202,-1.556 10.41,-1.914 v -0.723 c 0,-1.313 0.104,-2.875 -0.671,-4.012 -0.674,-1.021 -1.968,-1.437 -3.106,-1.437 -2.111,0 -3.99,1.078 -4.45,3.321 -0.097,0.498 -0.46,0.991 -0.962,1.017 l -5.364,-0.581 c -0.456,-0.102 -0.958,-0.463 -0.828,-1.155 1.233,-6.511 7.109,-8.475 12.378,-8.475 2.693,0 6.215,0.719 8.335,2.757 2.692997,2.515 2.431997,5.869 2.431997,9.524 v 8.622999 c 0,2.596 1.081,3.732 2.091,5.128 0.354,0.503 0.434,1.103 -0.018,1.473 -1.131,0.949 -3.138997,2.693 -4.243997,3.676 l -0.014,-0.013 z"
id="path4047"
style="fill-rule:evenodd" />
<path
d="m 99.325111,79.885297 c -8.716894,6.432161 -21.357191,9.853809 -32.243032,9.853809 -15.251419,0 -28.989193,-5.636741 -39.38419,-15.021522 -0.815557,-0.738364 -0.08726,-1.746902 0.89191,-1.173831 C 39.807066,80.071565 53.675732,84 68,84 c 9.664184,0 20.284886,-2.004491 30.058986,-6.151079 1.474215,-0.623415 2.709284,0.97246 1.266125,2.036376 z"
id="path3858"
style="fill:#ff9201;fill-rule:evenodd" />
<path
d="m 104,76 c -1.11342,-1.426386 -7.371903,-0.676274 -10.179364,-0.337298 -0.853315,0.09817 -0.984206,-0.641874 -0.217315,-1.184739 4.990671,-3.505554 13.168059,-2.491141 14.119539,-1.318987 0.95736,1.187256 -0.25087,9.384779 -4.92858,13.293915 -0.71907,0.604117 -1.40373,0.286117 -1.08573,-0.510142 C 102.75988,83.311486 105.11761,77.427225 104,76 z"
id="path3860"
style="fill:#ff9201;fill-rule:evenodd" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -8,10 +8,37 @@
xmlns:svg="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0" version="1.0"
width="128" width="128"
height="128" height="128"
id="svg2606"> id="svg2606"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="mobi.svg"
inkscape:export-filename="/home/niluje/Patchland/calibre/imgsrc/mimetypes/mobi.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1025"
id="namedview45"
showgrid="false"
inkscape:zoom="1.84375"
inkscape:cx="64"
inkscape:cy="64"
inkscape:window-x="-2"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg2606" />
<defs <defs
id="defs2608"> id="defs2608">
<linearGradient <linearGradient
@ -184,15 +211,16 @@
id="path14523" id="path14523"
style="fill:url(#linearGradient10213);fill-opacity:1" /> style="fill:url(#linearGradient10213);fill-opacity:1" />
<text <text
x="32" x="64.902344"
y="32" y="32.103516"
id="text3772" id="text3772"
xml:space="preserve" xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans"><tspan style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
x="32" sodipodi:linespacing="125%"><tspan
y="32" x="64.902344"
y="32.103516"
id="tspan3774" id="tspan3774"
style="font-size:28px;fill:#000000;fill-opacity:1">mobi</tspan></text> style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans">mobi</tspan></text>
<path <path
d="m 68.227,60.477999 c 0,2.157 0.052,3.954 -1.035,5.874 -0.88,1.561 -2.279,2.517 -3.833,2.517 -2.121,0 -3.366,-1.62 -3.366,-4.015 C 59.993,60.14 64.225,59.283 68.226,59.283 v 1.194999 z m 5.579,13.496 c -0.365,0.332 -0.896,0.352 -1.307,0.132 -1.838,-1.528 -2.167,-2.231 -3.174,-3.69 -3.035,3.094 -5.188,4.023 -9.123,4.023 -4.663,0 -8.284,-2.876 -8.284,-8.629 0,-4.49 2.433,-7.543999 5.899,-9.044999 3.005,-1.317 7.202,-1.556 10.41,-1.914 v -0.723 c 0,-1.313 0.104,-2.875 -0.671,-4.012 -0.674,-1.021 -1.968,-1.437 -3.106,-1.437 -2.111,0 -3.99,1.078 -4.45,3.321 -0.097,0.498 -0.46,0.991 -0.962,1.017 l -5.364,-0.581 c -0.456,-0.102 -0.958,-0.463 -0.828,-1.155 1.233,-6.511 7.109,-8.475 12.378,-8.475 2.693,0 6.215,0.719 8.335,2.757 2.692997,2.515 2.431997,5.869 2.431997,9.524 v 8.622999 c 0,2.596 1.081,3.732 2.091,5.128 0.354,0.503 0.434,1.103 -0.018,1.473 -1.131,0.949 -3.138997,2.693 -4.243997,3.676 l -0.014,-0.013 z" d="m 68.227,60.477999 c 0,2.157 0.052,3.954 -1.035,5.874 -0.88,1.561 -2.279,2.517 -3.833,2.517 -2.121,0 -3.366,-1.62 -3.366,-4.015 C 59.993,60.14 64.225,59.283 68.226,59.283 v 1.194999 z m 5.579,13.496 c -0.365,0.332 -0.896,0.352 -1.307,0.132 -1.838,-1.528 -2.167,-2.231 -3.174,-3.69 -3.035,3.094 -5.188,4.023 -9.123,4.023 -4.663,0 -8.284,-2.876 -8.284,-8.629 0,-4.49 2.433,-7.543999 5.899,-9.044999 3.005,-1.317 7.202,-1.556 10.41,-1.914 v -0.723 c 0,-1.313 0.104,-2.875 -0.671,-4.012 -0.674,-1.021 -1.968,-1.437 -3.106,-1.437 -2.111,0 -3.99,1.078 -4.45,3.321 -0.097,0.498 -0.46,0.991 -0.962,1.017 l -5.364,-0.581 c -0.456,-0.102 -0.958,-0.463 -0.828,-1.155 1.233,-6.511 7.109,-8.475 12.378,-8.475 2.693,0 6.215,0.719 8.335,2.757 2.692997,2.515 2.431997,5.869 2.431997,9.524 v 8.622999 c 0,2.596 1.081,3.732 2.091,5.128 0.354,0.503 0.434,1.103 -0.018,1.473 -1.131,0.949 -3.138997,2.693 -4.243997,3.676 l -0.014,-0.013 z"
id="path4047" id="path4047"

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

237
imgsrc/mimetypes/tpz.svg Normal file
View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="128"
height="128"
id="svg2606"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="tpz.svg"
inkscape:export-filename="/home/niluje/Patchland/calibre/imgsrc/mimetypes/tpz.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1025"
id="namedview45"
showgrid="false"
inkscape:zoom="1.84375"
inkscape:cx="-11.118644"
inkscape:cy="42.305085"
inkscape:window-x="-2"
inkscape:window-y="-3"
inkscape:window-maximized="1"
inkscape:current-layer="svg2606" />
<defs
id="defs2608">
<linearGradient
id="linearGradient10207">
<stop
id="stop10209"
style="stop-color:#a2a2a2;stop-opacity:1"
offset="0" />
<stop
id="stop10211"
style="stop-color:#ffffff;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
x1="96"
y1="104"
x2="88.000198"
y2="96.000198"
id="XMLID_12_"
gradientUnits="userSpaceOnUse">
<stop
id="stop83"
style="stop-color:#888a85;stop-opacity:1"
offset="0" />
<stop
id="stop85"
style="stop-color:#8c8e89;stop-opacity:1"
offset="0.0072" />
<stop
id="stop87"
style="stop-color:#abaca9;stop-opacity:1"
offset="0.0673" />
<stop
id="stop89"
style="stop-color:#c5c6c4;stop-opacity:1"
offset="0.1347" />
<stop
id="stop91"
style="stop-color:#dbdbda;stop-opacity:1"
offset="0.2652576" />
<stop
id="stop93"
style="stop-color:#ebebeb;stop-opacity:1"
offset="0.37646064" />
<stop
id="stop95"
style="stop-color:#f7f7f6;stop-opacity:1"
offset="0.48740286" />
<stop
id="stop97"
style="stop-color:#fdfdfd;stop-opacity:1"
offset="0.6324091" />
<stop
id="stop99"
style="stop-color:#ffffff;stop-opacity:1"
offset="1" />
</linearGradient>
<radialGradient
cx="102"
cy="112.3047"
r="139.55859"
id="XMLID_8_"
gradientUnits="userSpaceOnUse">
<stop
id="stop41"
style="stop-color:#b7b8b9;stop-opacity:1"
offset="0" />
<stop
id="stop47"
style="stop-color:#ececec;stop-opacity:1"
offset="0.18851049" />
<stop
id="stop49"
style="stop-color:#fafafa;stop-opacity:1"
offset="0.25718147" />
<stop
id="stop51"
style="stop-color:#ffffff;stop-opacity:1"
offset="0.30111277" />
<stop
id="stop53"
style="stop-color:#fafafa;stop-opacity:1"
offset="0.53130001" />
<stop
id="stop55"
style="stop-color:#ebecec;stop-opacity:1"
offset="0.84490001" />
<stop
id="stop57"
style="stop-color:#e1e2e3;stop-opacity:1"
offset="1" />
</radialGradient>
<filter
x="-0.19200002"
y="-0.19199999"
width="1.3839999"
height="1.3839999"
color-interpolation-filters="sRGB"
id="filter6697">
<feGaussianBlur
id="feGaussianBlur6699"
stdDeviation="1.9447689" />
</filter>
<clipPath
id="clipPath7084">
<path
d="m 72,88 -32,32 -8,0 0,-40 40,0 0,8 z"
id="path7086"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" />
</clipPath>
<radialGradient
cx="102"
cy="112.3047"
r="139.55859"
id="radialGradient9437"
xlink:href="#XMLID_8_"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.9996653,2e-6,0.00301608)" />
<linearGradient
x1="98.617439"
y1="106.41443"
x2="91.228737"
y2="99.254974"
id="linearGradient10213"
xlink:href="#linearGradient10207"
gradientUnits="userSpaceOnUse" />
<filter
color-interpolation-filters="sRGB"
id="filter2770">
<feGaussianBlur
id="feGaussianBlur2772"
stdDeviation="2.0786429" />
</filter>
</defs>
<metadata
id="metadata2611">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
d="m 16,8 0,112 c 0,0 63.15625,0 63.15625,0 l 0.03125,0 c 3e-6,0 11.90625,-9.90625 17.40625,-15.40625 C 102.09375,99.09375 112,87.1875 112,87.1875 L 112,87.15625 112,8 16,8 z"
transform="matrix(1.0416667,0,0,1.0267857,-2.6666667,-1.2142891)"
id="path7865"
style="opacity:0.5;fill:#000000;fill-opacity:1;filter:url(#filter2770)" />
<path
d="M 16.000001,8 16,120 c 0,0 63.146418,0 63.146418,0 L 112,87.14642 112,8 16.000001,8 z"
id="path34"
style="fill:#ffffff;fill-opacity:1" />
<path
d="m 18.000002,9.0000034 c -0.551,0 -1,0.44885 -1,0.999665 l 0,107.9638516 c 0,0.55181 0.449,0.99966 1,0.99966 l 59.171997,0 c 0.263,0 2.76268,0.11813 2.948681,-0.0688 L 110.707,88.094202 C 110.894,87.907264 111,85.40942 111,85.146508 l 0,-75.1468396 c 0,-0.550815 -0.448,-0.999665 -1,-0.999665 l -91.999998,0 z"
id="path59"
style="fill:url(#radialGradient9437);fill-opacity:1" />
<path
d="m 41.879531,115.98249 c 0,0 24.309609,-24.309614 24.309609,-24.309614 0,0 -9.35314,2.913124 -19.60314,2.913124 0,10.25 -4.706469,21.39649 -4.706469,21.39649 z"
transform="translate(40,0)"
clip-path="url(#clipPath7084)"
id="path5540"
style="opacity:0.4;fill:#000000;fill-opacity:1;filter:url(#filter6697)" />
<path
d="m 79.172,120 c 0,0 11.914,-9.914 17.414,-15.414 5.5,-5.5 15.414,-17.414 15.414,-17.414 0,0 -13.75,8.828 -24,8.828 0,10.25 -8.828,24 -8.828,24 z"
id="path14523"
style="fill:url(#linearGradient10213);fill-opacity:1" />
<text
x="64.703125"
y="32.175781"
id="text3772"
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3021"
x="64.703125"
y="32.175781">Topaz</tspan></text>
<path
d="m 68.227,60.477999 c 0,2.157 0.052,3.954 -1.035,5.874 -0.88,1.561 -2.279,2.517 -3.833,2.517 -2.121,0 -3.366,-1.62 -3.366,-4.015 C 59.993,60.14 64.225,59.283 68.226,59.283 v 1.194999 z m 5.579,13.496 c -0.365,0.332 -0.896,0.352 -1.307,0.132 -1.838,-1.528 -2.167,-2.231 -3.174,-3.69 -3.035,3.094 -5.188,4.023 -9.123,4.023 -4.663,0 -8.284,-2.876 -8.284,-8.629 0,-4.49 2.433,-7.543999 5.899,-9.044999 3.005,-1.317 7.202,-1.556 10.41,-1.914 v -0.723 c 0,-1.313 0.104,-2.875 -0.671,-4.012 -0.674,-1.021 -1.968,-1.437 -3.106,-1.437 -2.111,0 -3.99,1.078 -4.45,3.321 -0.097,0.498 -0.46,0.991 -0.962,1.017 l -5.364,-0.581 c -0.456,-0.102 -0.958,-0.463 -0.828,-1.155 1.233,-6.511 7.109,-8.475 12.378,-8.475 2.693,0 6.215,0.719 8.335,2.757 2.692997,2.515 2.431997,5.869 2.431997,9.524 v 8.622999 c 0,2.596 1.081,3.732 2.091,5.128 0.354,0.503 0.434,1.103 -0.018,1.473 -1.131,0.949 -3.138997,2.693 -4.243997,3.676 l -0.014,-0.013 z"
id="path4047"
style="fill-rule:evenodd" />
<path
d="m 99.325111,79.885297 c -8.716894,6.432161 -21.357191,9.853809 -32.243032,9.853809 -15.251419,0 -28.989193,-5.636741 -39.38419,-15.021522 -0.815557,-0.738364 -0.08726,-1.746902 0.89191,-1.173831 C 39.807066,80.071565 53.675732,84 68,84 c 9.664184,0 20.284886,-2.004491 30.058986,-6.151079 1.474215,-0.623415 2.709284,0.97246 1.266125,2.036376 z"
id="path3858"
style="fill:#ff9201;fill-rule:evenodd" />
<path
d="m 104,76 c -1.11342,-1.426386 -7.371903,-0.676274 -10.179364,-0.337298 -0.853315,0.09817 -0.984206,-0.641874 -0.217315,-1.184739 4.990671,-3.505554 13.168059,-2.491141 14.119539,-1.318987 0.95736,1.187256 -0.25087,9.384779 -4.92858,13.293915 -0.71907,0.604117 -1.40373,0.286117 -1.08573,-0.510142 C 102.75988,83.311486 105.11761,77.427225 104,76 z"
id="path3860"
style="fill:#ff9201;fill-rule:evenodd" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -0,0 +1,52 @@
__license__ = 'GPL v3'
__copyright__ = '2010-2012, NiLuJe <niluje at ak-team.com>'
'''
Fetch DoghouseDiaries.
'''
import re
from calibre.web.feeds.news import BasicNewsRecipe
class DoghouseDiaries(BasicNewsRecipe):
title = 'Doghouse Diaries'
description = 'A webcomic.'
__author__ = 'NiLuJe'
language = 'en'
use_embedded_content = False
# 14 comics per fetch (not really days... but we can't easily get the date of individual comics, short of parsing each one...)
oldest_article = 14
cover_url = 'http://www.thedoghousediaries.com/logos/logo3.png'
masthead_url = 'http://www.thedoghousediaries.com/logos/logo3.png'
keep_only_tags = [dict(name='img', attrs={'class': re.compile("comic-item*")}), dict(name='h1'), dict(name='div', attrs={'class':'entry'}), dict(name='p', id='alttext')]
remove_tags = [dict(name='div', attrs={'class':'pin-it-btn-wrapper'}), dict(name='span'), dict(name='div', id='wp_fb_like_button')]
remove_attributes = ['width', 'height']
no_stylesheets = True
# Turn image bubblehelp into a paragraph (NOTE: We run before the remove_tags cleanup, so we need to make sure we only parse the comic-item img, not the pinterest one pulled by the entry div)
preprocess_regexps = [
(re.compile(r'(<img.*src="http://thedoghousediaries.com/comics/.*title=")([^"]+)(".*>)'),
lambda m: '%s%s<p id="alttext"><strong>%s</strong></p>' % (m.group(1), m.group(3), m.group(2)))
]
def parse_index(self):
INDEX = 'http://www.thedoghousediaries.com/'
soup = self.index_to_soup(INDEX)
articles = []
# Since the feed sucks, and there's no real archive, we use the 'Quick Archive' thingie, but we can't get the date from here, so stop after 14 comics...
for item in soup.findAll('option', {}, True, None, self.oldest_article+1):
# Skip the quick archive itself
if ( item['value'] != '0' ):
articles.append({
'title': self.tag_to_string(item).encode('UTF-8'),
'url': item['value'],
'description': '',
'content': '',
})
return [('Doghouse Diaries', articles)]

19
recipes/fc_knudde.recipe Normal file
View File

@ -0,0 +1,19 @@
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1347706704(BasicNewsRecipe):
title = u'FC Knudde'
__author__ = u'DrMerry'
description = u'FC Knudde de populaire sport strip van Toon van Driel (http://www.toonvandriel.nl)'
language = u'nl'
oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = False
cover_url = 'http://a1.mzstatic.com/us/r1000/035/Purple/be/33/70/mzl.qkvshinq.320x480-75.jpg'
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
remove_tags_before = dict(id='title')
remove_tags_after = dict(attrs={'class':'entry-content rich-content'})
use_embedded_content = True
feeds = [(u'FC Knudde', u'http://www.nusport.nl/feeds/rss/fc-knudde.rss')]

BIN
recipes/icons/fc_knudde.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

View File

@ -7,20 +7,29 @@ class LiveMint(BasicNewsRecipe):
#encoding = 'cp1252' #encoding = 'cp1252'
oldest_article = 1 #days oldest_article = 1 #days
max_articles_per_feed = 25 max_articles_per_feed = 25
use_embedded_content = True use_embedded_content = False
no_stylesheets = True no_stylesheets = True
auto_cleanup = True auto_cleanup = True
feeds = [ feeds = [
('Latest News', ('Companies',
'http://www.livemint.com/StoryRss.aspx?LN=Latestnews'), 'http://www.livemint.com/rss/companies'),
('Gallery', ('Consumer',
'http://www.livemint.com/GalleryRssfeed.aspx'), 'http://www.livemint.com/rss/consumer'),
('Top Stories', ('Top Stories',
'http://www.livemint.com/StoryRss.aspx?ts=Topstories'), 'http://www.livemint.com/rss/homepage'),
('Banking', ('Opinion',
'http://www.livemint.com/StoryRss.aspx?Id=104'), 'http://www.livemint.com/rss/opinion'),
('Money',
'http://www.livemint.com/rss/money'),
('Industry',
'http://www.livemint.com/rss/industry'),
('Economy Politics',
'http://www.livemint.com/rss/economy_politics'),
('Lounge',
'http://www.livemint.com/rss/lounge'),
] ]

16
recipes/stamgasten.recipe Normal file
View File

@ -0,0 +1,16 @@
class AdvancedUserRecipe1347706704(BasicNewsRecipe):
title = u'Stamgasten'
__author__ = u'DrMerry'
description = u'Stamgasten de populaire strip van Toon van Driel (http://www.toonvandriel.nl)'
language = u'nl'
oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = False
cover_url = 'http://shop.toonvandriel.nl/productimg.php?type=canvas&id=15&size=large'
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
remove_tags_before = dict(id='title')
remove_tags_after = dict(attrs={'class':'entry-content rich-content'})
feeds = [(u'Stamgasten', u'http://toonvandriel.nl/feed/')]

View File

@ -2,6 +2,8 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
''' '''
Changelog: Changelog:
2012-04-06
Fixed empty articles, added masthead img (NiLuJe)
2011-09-24 2011-09-24
Changed cover (drMerry) Changed cover (drMerry)
''' '''
@ -13,7 +15,8 @@ import time, re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class XkcdCom(BasicNewsRecipe): class XkcdCom(BasicNewsRecipe):
cover_url = 'http://imgs.xkcd.com/s/9be30a7.png' cover_url = 'http://imgs.xkcd.com/static/terrible_small_logo.png'
masthead_url = 'http://imgs.xkcd.com/static/terrible_small_logo.png'
title = 'xkcd' title = 'xkcd'
description = 'A webcomic of romance and math humor.' description = 'A webcomic of romance and math humor.'
__author__ = 'Martin Pitt updated by DrMerry.' __author__ = 'Martin Pitt updated by DrMerry.'
@ -21,13 +24,14 @@ class XkcdCom(BasicNewsRecipe):
use_embedded_content = False use_embedded_content = False
oldest_article = 60 oldest_article = 60
keep_only_tags = [dict(id='middleContainer')] #keep_only_tags = [dict(id='middleContainer')]
remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')] #remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')]
keep_only_tags = [dict(id='comic')]
no_stylesheets = True no_stylesheets = True
# turn image bubblehelp into a paragraph # turn image bubblehelp into a paragraph, and put alt in a heading
preprocess_regexps = [ preprocess_regexps = [
(re.compile(r'(<img.*title=")([^"]+)(".*>)'), (re.compile(r'(<img.*title=")([^"]+)(".alt=")([^"]+)(".*>)'),
lambda m: '%s%s<p>%s</p>' % (m.group(1), m.group(3), m.group(2))) lambda m: '<h1>%s</h1>%s%s%s<p>%s</p>' % (m.group(4), m.group(1), m.group(3), m.group(5), m.group(2)))
] ]
def parse_index(self): def parse_index(self):

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ class GoogleCode(Base):# {{{
# The pattern to match filenames for the files being uploaded and # The pattern to match filenames for the files being uploaded and
# extract version information from them. Must have a named group # extract version information from them. Must have a named group
# named version # named version
filename_pattern=r'{appname}-(?:portable-)?(?P<version>.+?)(?:-(?:i686|x86_64|32bit|64bit))?\.(?:zip|exe|msi|dmg|tar\.bz2|tar\.xz|txz|tbz2)' filename_pattern=r'{appname}-(?:portable-installer-)?(?P<version>.+?)(?:-(?:i686|x86_64|32bit|64bit))?\.(?:zip|exe|msi|dmg|tar\.bz2|tar\.xz|txz|tbz2)'
): ):
self.username, self.password, = username, password self.username, self.password, = username, password

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,382 @@
// XUnzip.h Version 1.3
//
// Authors: Mark Adler et al. (see below)
//
// Modified by: Lucian Wischik
// lu@wischik.com
//
// Version 1.0 - Turned C files into just a single CPP file
// - Made them compile cleanly as C++ files
// - Gave them simpler APIs
// - Added the ability to zip/unzip directly in memory without
// any intermediate files
//
// Modified by: Hans Dietrich
// hdietrich@gmail.com
//
///////////////////////////////////////////////////////////////////////////////
//
// Lucian Wischik's comments:
// --------------------------
// THIS FILE is almost entirely based upon code by info-zip.
// It has been modified by Lucian Wischik.
// The original code may be found at http://www.info-zip.org
// The original copyright text follows.
//
///////////////////////////////////////////////////////////////////////////////
//
// Original authors' comments:
// ---------------------------
// This is version 2002-Feb-16 of the Info-ZIP copyright and license. The
// definitive version of this document should be available at
// ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely.
//
// Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
//
// For the purposes of this copyright and license, "Info-ZIP" is defined as
// the following set of individuals:
//
// Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
// Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase,
// Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
// David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
// Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
// Kai Uwe Rommel, Steve Salisbury, Dave Smith, Christian Spieler,
// Antoine Verheijen, Paul von Behren, Rich Wales, Mike White
//
// This software is provided "as is", without warranty of any kind, express
// or implied. In no event shall Info-ZIP or its contributors be held liable
// for any direct, indirect, incidental, special or consequential damages
// arising out of the use of or inability to use this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. Redistributions of source code must retain the above copyright notice,
// definition, disclaimer, and this list of conditions.
//
// 2. Redistributions in binary form (compiled executables) must reproduce
// the above copyright notice, definition, disclaimer, and this list of
// conditions in documentation and/or other materials provided with the
// distribution. The sole exception to this condition is redistribution
// of a standard UnZipSFX binary as part of a self-extracting archive;
// that is permitted without inclusion of this license, as long as the
// normal UnZipSFX banner has not been removed from the binary or disabled.
//
// 3. Altered versions--including, but not limited to, ports to new
// operating systems, existing ports with new graphical interfaces, and
// dynamic, shared, or static library versions--must be plainly marked
// as such and must not be misrepresented as being the original source.
// Such altered versions also must not be misrepresented as being
// Info-ZIP releases--including, but not limited to, labeling of the
// altered versions with the names "Info-ZIP" (or any variation thereof,
// including, but not limited to, different capitalizations),
// "Pocket UnZip", "WiZ" or "MacZip" without the explicit permission of
// Info-ZIP. Such altered versions are further prohibited from
// misrepresentative use of the Zip-Bugs or Info-ZIP e-mail addresses or
// of the Info-ZIP URL(s).
//
// 4. Info-ZIP retains the right to use the names "Info-ZIP", "Zip", "UnZip",
// "UnZipSFX", "WiZ", "Pocket UnZip", "Pocket Zip", and "MacZip" for its
// own source and binary releases.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef XUNZIP_H
#define XUNZIP_H
#ifndef XZIP_H
DECLARE_HANDLE(HZIP); // An HZIP identifies a zip file that has been opened
#endif
typedef DWORD ZRESULT;
// return codes from any of the zip functions. Listed later.
#define ZIP_HANDLE 1
#define ZIP_FILENAME 2
#define ZIP_MEMORY 3
typedef struct
{ int index; // index of this file within the zip
char name[MAX_PATH]; // filename within the zip
DWORD attr; // attributes, as in GetFileAttributes.
FILETIME atime,ctime,mtime;// access, create, modify filetimes
long comp_size; // sizes of item, compressed and uncompressed. These
long unc_size; // may be -1 if not yet known (e.g. being streamed in)
} ZIPENTRY;
typedef struct
{ int index; // index of this file within the zip
TCHAR name[MAX_PATH]; // filename within the zip
DWORD attr; // attributes, as in GetFileAttributes.
FILETIME atime,ctime,mtime;// access, create, modify filetimes
long comp_size; // sizes of item, compressed and uncompressed. These
long unc_size; // may be -1 if not yet known (e.g. being streamed in)
} ZIPENTRYW;
///////////////////////////////////////////////////////////////////////////////
//
// OpenZip()
//
// Purpose: Open an existing zip archive file
//
// Parameters: z - archive file name if flags is ZIP_FILENAME; for other
// uses see below
// len - for memory (ZIP_MEMORY) should be the buffer size;
// for other uses, should be 0
// flags - indicates usage, see below; for files, this will be
// ZIP_FILENAME
//
// Returns: HZIP - non-zero if zip archive opened ok, otherwise 0
//
HZIP OpenZip(void *z, unsigned int len, DWORD flags);
// OpenZip - opens a zip file and returns a handle with which you can
// subsequently examine its contents. You can open a zip file from:
// from a pipe: OpenZip(hpipe_read,0, ZIP_HANDLE);
// from a file (by handle): OpenZip(hfile,0, ZIP_HANDLE);
// from a file (by name): OpenZip("c:\\test.zip",0, ZIP_FILENAME);
// from a memory block: OpenZip(bufstart, buflen, ZIP_MEMORY);
// If the file is opened through a pipe, then items may only be
// accessed in increasing order, and an item may only be unzipped once,
// although GetZipItem can be called immediately before and after unzipping
// it. If it's opened i n any other way, then full random access is possible.
// Note: pipe input is not yet implemented.
///////////////////////////////////////////////////////////////////////////////
//
// GetZipItem()
//
// Purpose: Get information about an item in an open zip archive
//
// Parameters: hz - handle of open zip archive
// index - index number (0 based) of item in zip
// ze - pointer to a ZIPENTRY (if ANSI) or ZIPENTRYW struct
// (if Unicode)
//
// Returns: ZRESULT - ZR_OK if success, otherwise some other value
//
#ifdef _UNICODE
#define GetZipItem GetZipItemW
#else
#define GetZipItem GetZipItemA
#endif
ZRESULT GetZipItemA(HZIP hz, int index, ZIPENTRY *ze);
ZRESULT GetZipItemW(HZIP hz, int index, ZIPENTRYW *ze);
// GetZipItem - call this to get information about an item in the zip.
// If index is -1 and the file wasn't opened through a pipe,
// then it returns information about the whole zipfile
// (and in particular ze.index returns the number of index items).
// Note: the item might be a directory (ze.attr & FILE_ATTRIBUTE_DIRECTORY)
// See below for notes on what happens when you unzip such an item.
// Note: if you are opening the zip through a pipe, then random access
// is not possible and GetZipItem(-1) fails and you can't discover the number
// of items except by calling GetZipItem on each one of them in turn,
// starting at 0, until eventually the call fails. Also, in the event that
// you are opening through a pipe and the zip was itself created into a pipe,
// then then comp_size and sometimes unc_size as well may not be known until
// after the item has been unzipped.
///////////////////////////////////////////////////////////////////////////////
//
// FindZipItem()
//
// Purpose: Find item by name and return information about it
//
// Parameters: hz - handle of open zip archive
// name - name of file to look for inside zip archive
// ic - TRUE = case insensitive
// index - pointer to index number returned, or -1
// ze - pointer to a ZIPENTRY (if ANSI) or ZIPENTRYW struct
// (if Unicode)
//
// Returns: ZRESULT - ZR_OK if success, otherwise some other value
//
#ifdef _UNICODE
#define FindZipItem FindZipItemW
#else
#define FindZipItem FindZipItemA
#endif
ZRESULT FindZipItemA(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze);
ZRESULT FindZipItemW(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRYW *ze);
// FindZipItem - finds an item by name. ic means 'insensitive to case'.
// It returns the index of the item, and returns information about it.
// If nothing was found, then index is set to -1 and the function returns
// an error code.
///////////////////////////////////////////////////////////////////////////////
//
// UnzipItem()
//
// Purpose: Find item by index and unzip it
//
// Parameters: hz - handle of open zip archive
// index - index number of file to unzip
// dst - target file name of unzipped file
// len - for memory (ZIP_MEMORY. length of buffer;
// otherwise 0
// flags - indicates usage, see below; for files, this will be
// ZIP_FILENAME
//
// Returns: ZRESULT - ZR_OK if success, otherwise some other value
//
ZRESULT UnzipItem(HZIP hz, int index, void *dst, unsigned int len, DWORD flags);
// UnzipItem - given an index to an item, unzips it. You can unzip to:
// to a pipe: UnzipItem(hz,i, hpipe_write,0,ZIP_HANDLE);
// to a file (by handle): UnzipItem(hz,i, hfile,0,ZIP_HANDLE);
// to a file (by name): UnzipItem(hz,i, ze.name,0,ZIP_FILENAME);
// to a memory block: UnzipItem(hz,i, buf,buflen,ZIP_MEMORY);
// In the final case, if the buffer isn't large enough to hold it all,
// then the return code indicates that more is yet to come. If it was
// large enough, and you want to know precisely how big, GetZipItem.
// Note: zip files are normally stored with relative pathnames. If you
// unzip with ZIP_FILENAME a relative pathname then the item gets created
// relative to the current directory - it first ensures that all necessary
// subdirectories have been created. Also, the item may itself be a directory.
// If you unzip a directory with ZIP_FILENAME, then the directory gets created.
// If you unzip it to a handle or a memory block, then nothing gets created
// and it emits 0 bytes.
///////////////////////////////////////////////////////////////////////////////
//
// CloseZip()
//
// Purpose: Close an open zip archive
//
// Parameters: hz - handle to an open zip archive
//
// Returns: ZRESULT - ZR_OK if success, otherwise some other value
//
ZRESULT CloseZip(HZIP hz);
// CloseZip - the zip handle must be closed with this function.
unsigned int FormatZipMessage(ZRESULT code, char *buf,unsigned int len);
// FormatZipMessage - given an error code, formats it as a string.
// It returns the length of the error message. If buf/len points
// to a real buffer, then it also writes as much as possible into there.
// These are the result codes:
#define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned,
#define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage.
// The following come from general system stuff (e.g. files not openable)
#define ZR_GENMASK 0x0000FF00
#define ZR_NODUPH 0x00000100 // couldn't duplicate the handle
#define ZR_NOFILE 0x00000200 // couldn't create/open the file
#define ZR_NOALLOC 0x00000300 // failed to allocate some resource
#define ZR_WRITE 0x00000400 // a general error writing to the file
#define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip
#define ZR_MORE 0x00000600 // there's still more data to be unzipped
#define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile
#define ZR_READ 0x00000800 // a general error reading the file
// The following come from mistakes on the part of the caller
#define ZR_CALLERMASK 0x00FF0000
#define ZR_ARGS 0x00010000 // general mistake with the arguments
#define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't
#define ZR_MEMSIZE 0x00030000 // the memory size is too small
#define ZR_FAILED 0x00040000 // the thing was already failed when you called this function
#define ZR_ENDED 0x00050000 // the zip creation has already been closed
#define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken
#define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped
#define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip
// The following come from bugs within the zip library itself
#define ZR_BUGMASK 0xFF000000
#define ZR_NOTINITED 0x01000000 // initialisation didn't work
#define ZR_SEEK 0x02000000 // trying to seek in an unseekable file
#define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed
#define ZR_FLATE 0x05000000 // an internal error in the de/inflation code
// e.g.
//
// SetCurrentDirectory("c:\\docs\\stuff");
// HZIP hz = OpenZip("c:\\stuff.zip",0,ZIP_FILENAME);
// ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
// for (int i=0; i<numitems; i++)
// { GetZipItem(hz,i,&ze);
// UnzipItem(hz,i,ze.name,0,ZIP_FILENAME);
// }
// CloseZip(hz);
//
//
// HRSRC hrsrc = FindResource(hInstance,MAKEINTRESOURCE(1),RT_RCDATA);
// HANDLE hglob = LoadResource(hInstance,hrsrc);
// void *zipbuf=LockResource(hglob);
// unsigned int ziplen=SizeofResource(hInstance,hrsrc);
// HZIP hz = OpenZip(zipbuf, ziplen, ZIP_MEMORY);
// - unzip to a membuffer -
// ZIPENTRY ze; int i; FindZipItem(hz,"file.dat",&i,&ze);
// char *ibuf = new char[ze.unc_size];
// UnzipItem(hz,i, ibuf, ze.unc_size,ZIP_MEMORY);
// delete[] buf;
// - unzip to a fixed membuff -
// ZIPENTRY ze; int i; FindZipItem(hz,"file.dat",&i,&ze);
// char ibuf[1024]; ZIPRESULT zr=ZR_MORE; unsigned long totsize=0;
// while (zr==ZR_MORE)
// { zr = UnzipItem(hz,i, ibuf,1024,ZIP_MEMORY);
// unsigned long bufsize=1024; if (zr==ZR_OK) bufsize=ze.unc_size-totsize;
// totsize+=bufsize;
// }
// - unzip to a pipe -
// HANDLE hthread=CreateWavReaderThread(&hread,&hwrite);
// FindZipItem(hz,"sound.wav",&i,&ze);
// UnzipItem(hz,i, hwrite,0,ZIP_HANDLE);
// CloseHandle(hwrite);
// WaitForSingleObject(hthread,INFINITE);
// CloseHandle(hread); CloseHandle(hthread);
// - finished -
// CloseZip(hz);
// // note: no need to free resources obtained through Find/Load/LockResource
//
//
// SetCurrentDirectory("c:\\docs\\pipedzipstuff");
// HANDLE hread,hwrite; CreatePipe(&hread,&hwrite);
// CreateZipWriterThread(hwrite);
// HZIP hz = OpenZip(hread,0,ZIP_HANDLE);
// for (int i=0; ; i++)
// { ZIPENTRY ze; ZRESULT res = GetZipItem(hz,i,&ze);
// if (res!=ZE_OK) break; // no more
// UnzipItem(hz,i, ze.name,0,ZIP_FILENAME);
// }
// CloseZip(hz);
//
// Now we indulge in a little skullduggery so that the code works whether
// the user has included just zip or both zip and unzip.
// Idea: if header files for both zip and unzip are present, then presumably
// the cpp files for zip and unzip are both present, so we will call
// one or the other of them based on a dynamic choice. If the header file
// for only one is present, then we will bind to that particular one.
HZIP OpenZipU(void *z,unsigned int len,DWORD flags);
ZRESULT CloseZipU(HZIP hz);
unsigned int FormatZipMessageU(ZRESULT code, char *buf,unsigned int len);
bool IsZipHandleU(HZIP hz);
#define OpenZip OpenZipU
#ifdef XZIP_H
#undef CloseZip
#define CloseZip(hz) (IsZipHandleU(hz)?CloseZipU(hz):CloseZipZ(hz))
#else
#define CloseZip CloseZipU
#define FormatZipMessage FormatZipMessageU
#endif
#endif //XUNZIP_H

View File

@ -37,7 +37,7 @@ class Win32(VMInstaller):
SHUTDOWN_CMD = ['shutdown.exe', '-s', '-f', '-t', '0'] SHUTDOWN_CMD = ['shutdown.exe', '-s', '-f', '-t', '0']
def sign_msi(self): def sign_msi(self):
print ('Signing .msi ...') print ('Signing installers ...')
raw = open(self.VM).read() raw = open(self.VM).read()
vmx = re.search(r'''launch_vmware\(['"](.+?)['"]''', raw).group(1) vmx = re.search(r'''launch_vmware\(['"](.+?)['"]''', raw).group(1)
subprocess.check_call(['vmrun', '-T', 'ws', '-gu', 'kovid', '-gp', subprocess.check_call(['vmrun', '-T', 'ws', '-gu', 'kovid', '-gp',
@ -56,7 +56,7 @@ class Win32(VMInstaller):
self.warn('Failed to freeze') self.warn('Failed to freeze')
raise SystemExit(1) raise SystemExit(1)
installer = 'dist/%s-portable-%s.zip'%(__appname__, __version__) installer = 'dist/%s-portable-installer-%s.exe'%(__appname__, __version__)
subprocess.check_call(('scp', subprocess.check_call(('scp',
'xp_build:build/%s/%s'%(__appname__, installer), 'dist')) 'xp_build:build/%s/%s'%(__appname__, installer), 'dist'))
if not os.path.exists(installer): if not os.path.exists(installer):

View File

@ -23,6 +23,7 @@ SW = r'C:\cygwin\home\kovid\sw'
IMAGEMAGICK = os.path.join(SW, 'build', 'ImageMagick-6.7.6', IMAGEMAGICK = os.path.join(SW, 'build', 'ImageMagick-6.7.6',
'VisualMagick', 'bin') 'VisualMagick', 'bin')
CRT = r'C:\Microsoft.VC90.CRT' CRT = r'C:\Microsoft.VC90.CRT'
LZMA = r'Q:\easylzma\build\easylzma-0.0.8'
VERSION = re.sub('[a-z]\d+', '', __version__) VERSION = re.sub('[a-z]\d+', '', __version__)
WINVER = VERSION+'.0' WINVER = VERSION+'.0'
@ -89,6 +90,7 @@ class Win32Freeze(Command, WixMixIn):
self.remove_CRT_from_manifests() self.remove_CRT_from_manifests()
self.create_installer() self.create_installer()
self.build_portable() self.build_portable()
self.build_portable_installer()
def remove_CRT_from_manifests(self): def remove_CRT_from_manifests(self):
''' '''
@ -311,7 +313,8 @@ class Win32Freeze(Command, WixMixIn):
subprocess.check_call([r'C:\Program Files\7-Zip\7z.exe', 'a', '-r', subprocess.check_call([r'C:\Program Files\7-Zip\7z.exe', 'a', '-r',
'-scsUTF-8', '-sfx', 'winfrozen', 'winfrozen'], cwd=self.base) '-scsUTF-8', '-sfx', 'winfrozen', 'winfrozen'], cwd=self.base)
def embed_resources(self, module, desc=None): def embed_resources(self, module, desc=None, extra_data=None,
product_description=None):
icon_base = self.j(self.src_root, 'icons') icon_base = self.j(self.src_root, 'icons')
icon_map = {'calibre':'library', 'ebook-viewer':'viewer', icon_map = {'calibre':'library', 'ebook-viewer':'viewer',
'lrfviewer':'viewer', 'calibre-portable':'library'} 'lrfviewer':'viewer', 'calibre-portable':'library'}
@ -320,6 +323,8 @@ class Win32Freeze(Command, WixMixIn):
bname = self.b(module) bname = self.b(module)
internal_name = os.path.splitext(bname)[0] internal_name = os.path.splitext(bname)[0]
icon = icon_map.get(internal_name, 'command-prompt') icon = icon_map.get(internal_name, 'command-prompt')
if internal_name.startswith('calibre-portable-'):
icon = 'install'
icon = self.j(icon_base, icon+'.ico') icon = self.j(icon_base, icon+'.ico')
if desc is None: if desc is None:
defdesc = 'A dynamic link library' if file_type == 'DLL' else \ defdesc = 'A dynamic link library' if file_type == 'DLL' else \
@ -327,6 +332,8 @@ class Win32Freeze(Command, WixMixIn):
desc = DESCRIPTIONS.get(internal_name, defdesc) desc = DESCRIPTIONS.get(internal_name, defdesc)
license = 'GNU GPL v3.0' license = 'GNU GPL v3.0'
def e(val): return val.replace('"', r'\"') def e(val): return val.replace('"', r'\"')
if product_description is None:
product_description = __appname__ + ' - E-book management'
rc = template.format( rc = template.format(
icon=icon, icon=icon,
file_type=e(file_type), file_type=e(file_type),
@ -338,11 +345,13 @@ class Win32Freeze(Command, WixMixIn):
product_version=e(WINVER.replace('.', ',')), product_version=e(WINVER.replace('.', ',')),
product_version_str=e(__version__), product_version_str=e(__version__),
product_name=e(__appname__), product_name=e(__appname__),
product_description=e(__appname__+' - E-book management'), product_description=e(product_description),
legal_copyright=e(license), legal_copyright=e(license),
legal_trademarks=e(__appname__ + \ legal_trademarks=e(__appname__ + \
' is a registered U.S. trademark number 3,666,525') ' is a registered U.S. trademark number 3,666,525')
) )
if extra_data:
rc += '\nextra extra "%s"'%extra_data
tdir = self.obj_dir tdir = self.obj_dir
rcf = self.j(tdir, bname+'.rc') rcf = self.j(tdir, bname+'.rc')
with open(rcf, 'wb') as f: with open(rcf, 'wb') as f:
@ -371,6 +380,45 @@ class Win32Freeze(Command, WixMixIn):
self.info(p.stderr.read()) self.info(p.stderr.read())
sys.exit(1) sys.exit(1)
def build_portable_installer(self):
base = self.portable_base
zf = self.a(self.j('dist', 'calibre-portable-%s.zip.lz'%VERSION))
usz = os.path.getsize(zf)
def cc(src, obj):
cflags = '/c /EHsc /MT /W4 /Ox /nologo /D_UNICODE /DUNICODE /DPSAPI_VERSION=1'.split()
cflags.append(r'/I%s\include'%LZMA)
cflags.append('/DUNCOMPRESSED_SIZE=%d'%usz)
if self.newer(obj, [src]):
self.info('Compiling', obj)
cmd = [msvc.cc] + cflags + ['/Fo'+obj, src]
self.run_builder(cmd)
src = self.j(self.src_root, 'setup', 'installer', 'windows',
'portable-installer.cpp')
obj = self.j(self.obj_dir, self.b(src)+'.obj')
xsrc = self.j(self.src_root, 'setup', 'installer', 'windows',
'XUnzip.cpp')
xobj = self.j(self.obj_dir, self.b(xsrc)+'.obj')
cc(src, obj)
cc(xsrc, xobj)
exe = self.j('dist', 'calibre-portable-installer-%s.exe'%VERSION)
if self.newer(exe, [obj, xobj]):
self.info('Linking', exe)
cmd = [msvc.linker] + ['/INCREMENTAL:NO', '/MACHINE:X86',
'/LIBPATH:'+self.obj_dir, '/SUBSYSTEM:WINDOWS',
'/LIBPATH:'+(LZMA+r'\lib\Release'),
'/RELEASE',
'/ENTRY:wWinMainCRTStartup',
'/OUT:'+exe, self.embed_resources(exe,
desc='Calibre Portable Installer', extra_data=zf,
product_description='Calibre Portable Installer'),
xobj, obj, 'User32.lib', 'Shell32.lib', 'easylzma_s.lib',
'Ole32.lib', 'Shlwapi.lib', 'Kernel32.lib', 'Psapi.lib']
self.run_builder(cmd)
os.remove(zf)
def build_portable(self): def build_portable(self):
base = self.portable_base base = self.portable_base
if os.path.exists(base): if os.path.exists(base):
@ -394,7 +442,7 @@ class Win32Freeze(Command, WixMixIn):
'/RELEASE', '/RELEASE',
'/ENTRY:wWinMainCRTStartup', '/ENTRY:wWinMainCRTStartup',
'/OUT:'+exe, self.embed_resources(exe), '/OUT:'+exe, self.embed_resources(exe),
obj, 'User32.lib'] obj, 'User32.lib', 'Shlwapi.lib']
self.run_builder(cmd) self.run_builder(cmd)
self.info('Creating portable installer') self.info('Creating portable installer')
@ -403,9 +451,12 @@ class Win32Freeze(Command, WixMixIn):
os.mkdir(self.j(base, 'Calibre Settings')) os.mkdir(self.j(base, 'Calibre Settings'))
name = '%s-portable-%s.zip'%(__appname__, __version__) name = '%s-portable-%s.zip'%(__appname__, __version__)
with zipfile.ZipFile(self.j('dist', name), 'w', zipfile.ZIP_DEFLATED) as zf: name = self.j('dist', name)
with zipfile.ZipFile(name, 'w', zipfile.ZIP_STORED) as zf:
self.add_dir_to_zip(zf, base, 'Calibre Portable') self.add_dir_to_zip(zf, base, 'Calibre Portable')
subprocess.check_call([LZMA + r'\bin\elzma.exe', '-9', '--lzip', name])
def add_dir_to_zip(self, zf, path, prefix=''): def add_dir_to_zip(self, zf, path, prefix=''):
''' '''
Add a directory recursively to the zip file with an optional prefix. Add a directory recursively to the zip file with an optional prefix.

View File

@ -11,7 +11,6 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst,
wchar_t *CmdLine, int CmdShow) { wchar_t *CmdLine, int CmdShow) {
wchar_t *stdout_redirect, *stderr_redirect, basename[50]; wchar_t *stdout_redirect, *stderr_redirect, basename[50];
int ret = 0;
set_gui_app((char)1); set_gui_app((char)1);
@ -20,7 +19,7 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst,
stdout_redirect = redirect_out_stream(basename, (char)1); stdout_redirect = redirect_out_stream(basename, (char)1);
stderr_redirect = redirect_out_stream(basename, (char)0); stderr_redirect = redirect_out_stream(basename, (char)0);
ret = execute_python_entrypoint(BASENAME, MODULE, FUNCTION, execute_python_entrypoint(BASENAME, MODULE, FUNCTION,
stdout_redirect, stderr_redirect); stdout_redirect, stderr_redirect);
if (stdout != NULL) fclose(stdout); if (stdout != NULL) fclose(stdout);
@ -29,7 +28,7 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst,
DeleteFile(stdout_redirect); DeleteFile(stdout_redirect);
DeleteFile(stderr_redirect); DeleteFile(stderr_redirect);
return ret; return 0; // This should really be returning the value set in the WM_QUIT message, but I cannot be bothered figuring out how to get that.
} }
#else #else

View File

@ -370,6 +370,14 @@ Run
Python setup.py build Python setup.py build
cp -r build/lib.win32-*/* /cygdrive/c/Python27/Lib/site-packages/ cp -r build/lib.win32-*/* /cygdrive/c/Python27/Lib/site-packages/
easylzma
----------
Get it from http://lloyd.github.com/easylzma/ (use the trunk version)
Run cmake and build the Visual Studio solution (generates CLI tools and dll and
static lib automatically)
calibre calibre
--------- ---------

View File

@ -0,0 +1,585 @@
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <Windows.h>
#include <Shlobj.h>
#include <Shlwapi.h>
#include <Shellapi.h>
#include <Psapi.h>
#include <wchar.h>
#include <stdio.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <easylzma/decompress.h>
#include "XUnzip.h"
#define BUFSIZE 4096
// Error handling {{{
static void show_error(LPCWSTR msg) {
MessageBeep(MB_ICONERROR);
MessageBox(NULL, msg, L"Error", MB_OK|MB_ICONERROR);
}
static void show_detailed_error(LPCWSTR preamble, LPCWSTR msg, int code) {
LPWSTR buf;
buf = (LPWSTR)LocalAlloc(LMEM_ZEROINIT, sizeof(WCHAR)*
(wcslen(msg) + wcslen(preamble) + 80));
_snwprintf_s(buf,
LocalSize(buf) / sizeof(WCHAR), _TRUNCATE,
L"%s\r\n %s (Error Code: %d)\r\n",
preamble, msg, code);
show_error(buf);
LocalFree(buf);
}
static void show_zip_error(LPCWSTR preamble, LPCWSTR msg, ZRESULT code) {
LPWSTR buf;
buf = (LPWSTR)LocalAlloc(LMEM_ZEROINIT, sizeof(WCHAR)*
(wcslen(preamble) + wcslen(msg) + 80));
_snwprintf_s(buf,
LocalSize(buf) / sizeof(WCHAR), _TRUNCATE,
L"%s\r\n %s %s (Error Code: %X)\r\n",
preamble, msg, code);
show_error(buf);
LocalFree(buf);
}
static void show_last_error_crt(LPCWSTR preamble) {
WCHAR buf[BUFSIZE];
int err = 0;
_get_errno(&err);
_wcserror_s(buf, BUFSIZE, err);
show_detailed_error(preamble, buf, err);
}
static void show_last_error(LPCWSTR preamble) {
WCHAR *msg = NULL;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&msg,
0, NULL );
show_detailed_error(preamble, msg, (int)dw);
}
// }}}
// Load, decompress and extract data {{{
static BOOL load_data(LPVOID *data, DWORD *sz) {
HRSRC rsrc;
HGLOBAL h;
rsrc = FindResourceW(NULL, L"extra", L"extra");
if (rsrc == NULL) { show_last_error(L"Failed to find portable data in exe"); return false; }
h = LoadResource(NULL, rsrc);
if (h == NULL) { show_last_error(L"Failed to load portable data from exe"); return false; }
*data = LockResource(h);
if (*data == NULL) { show_last_error(L"Failed to lock portable data in exe"); return false; }
*sz = SizeofResource(NULL, rsrc);
if (sz == 0) { show_last_error(L"Failed to get size of portable data in exe"); return false; }
return true;
}
static BOOL unzip(HZIP zipf, int nitems, IProgressDialog *pd) {
int i = 0;
ZRESULT res;
ZIPENTRYW ze;
for (i = 0; i < nitems; i++) {
res = GetZipItem(zipf, i, &ze);
if (res != ZR_OK) { show_zip_error(L"Failed to get zip item", L"", res); return false;}
res = UnzipItem(zipf, i, ze.name, 0, ZIP_FILENAME);
if (res != ZR_OK) { show_zip_error(L"Failed to extract zip item:", ze.name, res); return false;}
pd->SetLine(2, ze.name, true, NULL);
pd->SetProgress(i, nitems);
}
CloseZip(zipf);
return true;
}
static HANDLE temp_file(LPWSTR name) {
UINT res;
HANDLE h;
res = GetTempFileNameW(L".", L"portable_data", 0, name);
if (res == 0) { show_last_error(L"Failed to create temporary file to decompress portable data"); return INVALID_HANDLE_VALUE; }
h = CreateFile(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { show_last_error(L"Failed to open temp file t decomress portable data"); }
return h;
}
struct DataStream
{
const unsigned char *in_data;
size_t in_len;
HANDLE out;
IProgressDialog *pd;
};
static int
input_callback(void *ctx, void *buf, size_t * size)
{
size_t rd = 0;
struct DataStream * ds = (struct DataStream *) ctx;
rd = (ds->in_len < *size) ? ds->in_len : *size;
if (rd > 0) {
memcpy(buf, (void*) ds->in_data, rd);
ds->in_data += rd;
ds->in_len -= rd;
}
*size = rd;
return 0;
}
static size_t
output_callback(void *ctx, const void *buf, size_t size)
{
struct DataStream * ds = (struct DataStream *) ctx;
DWORD written = 0;
if (size > 0) {
if (!WriteFile(ds->out, buf, size, &written, NULL)) {
show_last_error(L"Failed to write uncompressed data to temp file");
return 0;
}
written = SetFilePointer(ds->out, 0, NULL, FILE_CURRENT);
ds->pd->SetProgress(written, UNCOMPRESSED_SIZE);
}
return size;
}
static BOOL decompress(LPVOID src, DWORD src_sz, HANDLE out, IProgressDialog *pd) {
elzma_decompress_handle h;
struct DataStream ds;
int rc;
h = elzma_decompress_alloc();
if (h == NULL) { show_error(L"Out of memory"); return false; }
ds.in_data = (unsigned char*)src;
ds.in_len = src_sz;
ds.out = out;
ds.pd = pd;
rc = elzma_decompress_run(h, input_callback, (void *) &ds, output_callback,
(void *) &ds, ELZMA_lzip);
if (rc != ELZMA_E_OK) {
elzma_decompress_free(&h);
show_zip_error(L"Failed to decompress portable data", L"", rc);
return false;
}
elzma_decompress_free(&h);
return true;
}
static BOOL extract(LPVOID cdata, DWORD csz) {
HANDLE h;
WCHAR tempnam[MAX_PATH+1] = {0};
BOOL ret = true;
HZIP zipf;
ZIPENTRYW ze;
ZRESULT res;
int nitems;
HRESULT hr;
IProgressDialog *pd = NULL;
hr = CoCreateInstance(CLSID_ProgressDialog, NULL,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pd));
if (FAILED(hr)) { show_error(L"Failed to create progress dialog"); return false; }
pd->SetTitle(L"Extracting Calibre Portable");
pd->SetLine(1, L"Decompressing data...", true, NULL);
h = temp_file(tempnam);
if (h == INVALID_HANDLE_VALUE) return false;
pd->StartProgressDialog(NULL, NULL, PROGDLG_NORMAL | PROGDLG_AUTOTIME | PROGDLG_NOCANCEL, NULL);
if (!decompress(cdata, csz, h, pd)) { ret = false; goto end; }
SetFilePointer(h, 0, NULL, FILE_BEGIN);
zipf = OpenZip(h, 0, ZIP_HANDLE);
if (zipf == 0) { show_last_error(L"Failed to open zipped portable data"); ret = false; goto end; }
res = GetZipItem(zipf, -1, &ze);
if (res != ZR_OK) { show_zip_error(L"Failed to get count of items in portable data", L"", res); ret = false; goto end;}
nitems = ze.index;
pd->SetLine(1, L"Copying files...", true, NULL);
if (!unzip(zipf, nitems, pd)) { ret = false; goto end; }
end:
pd->StopProgressDialog();
pd->Release();
CloseHandle(h);
DeleteFile(tempnam);
return ret;
}
// }}}
// Find calibre portable directory and install/upgrade into it {{{
static BOOL directory_exists( LPCWSTR path )
{
if( _waccess_s( path, 0 ) == 0 )
{
struct _stat status;
_wstat( path, &status );
return (status.st_mode & S_IFDIR) != 0;
}
return FALSE;
}
static BOOL file_exists( LPCWSTR path )
{
if( _waccess_s( path, 0 ) == 0 )
{
struct _stat status;
_wstat( path, &status );
return (status.st_mode & S_IFREG) != 0;
}
return FALSE;
}
static LPWSTR get_directory_from_user() {
WCHAR name[MAX_PATH+1] = {0};
LPWSTR path = NULL;
PIDLIST_ABSOLUTE ret;
path = (LPWSTR)calloc(2*MAX_PATH, sizeof(WCHAR));
if (path == NULL) { show_error(L"Out of memory"); return NULL; }
int image = 0;
BROWSEINFO bi = { NULL, NULL, name,
L"Select the folder where you want to install or update Calibre Portable",
BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN | BIF_USENEWUI,
NULL, NULL, image };
ret = SHBrowseForFolder(&bi);
if (ret == NULL) {
return NULL;
}
if (!SHGetPathFromIDList(ret, path)) {
show_detailed_error(L"The selected folder is not valid: ", name, 0);
return NULL;
}
return path;
}
static bool is_dots(LPCWSTR name) {
return wcscmp(name, L".") == 0 || wcscmp(name, L"..") == 0;
}
static bool rmtree(LPCWSTR path) {
SHFILEOPSTRUCTW op;
WCHAR buf[4*MAX_PATH + 2] = {0};
if (GetFullPathName(path, 4*MAX_PATH, buf, NULL) == 0) return false;
op.hwnd = NULL;
op.wFunc = FO_DELETE;
op.pFrom = buf;
op.pTo = NULL;
op.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMMKDIR;
op.fAnyOperationsAborted = false;
op.hNameMappings = NULL;
op.lpszProgressTitle = NULL;
return SHFileOperationW(&op) == 0;
}
static BOOL find_portable_dir(LPCWSTR base, LPWSTR *result, BOOL *existing) {
WCHAR buf[4*MAX_PATH] = {0};
_snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\calibre-portable.exe", base);
*existing = true;
if (file_exists(buf)) {
*result = _wcsdup(base);
if (*result == NULL) { show_error(L"Out of memory"); return false; }
return true;
}
WIN32_FIND_DATA fdFile;
HANDLE hFind = NULL;
_snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\*", base);
if((hFind = FindFirstFileEx(buf, FindExInfoStandard, &fdFile, FindExSearchLimitToDirectories, NULL, 0)) != INVALID_HANDLE_VALUE) {
do {
if(is_dots(fdFile.cFileName)) continue;
if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
_snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\%s\\calibre-portable.exe", base, fdFile.cFileName);
if (file_exists(buf)) {
*result = _wcsdup(buf);
if (*result == NULL) { show_error(L"Out of memory"); return false; }
PathRemoveFileSpec(*result);
FindClose(hFind);
return true;
}
}
} while(FindNextFile(hFind, &fdFile));
FindClose(hFind);
}
*existing = false;
_snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE, L"%s\\Calibre Portable", base);
if (!CreateDirectory(buf, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
show_last_error(L"Failed to create Calibre Portable folder");
return false;
}
*result = _wcsdup(buf);
if (*result == NULL) { show_error(L"Out of memory"); return false; }
return true;
}
static LPWSTR make_unpack_dir() {
WCHAR buf[4*MAX_PATH] = {0};
LPWSTR ans = NULL;
if (directory_exists(L"_unpack_calibre_portable"))
rmtree(L"_unpack_calibre_portable");
if (!CreateDirectory(L"_unpack_calibre_portable", NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
show_last_error(L"Failed to create temporary folder to unpack into");
return ans;
}
if (!GetFullPathName(L"_unpack_calibre_portable", 4*MAX_PATH, buf, NULL)) {
show_last_error(L"Failed to resolve path");
return NULL;
}
ans = _wcsdup(buf);
if (ans == NULL) show_error(L"Out of memory");
return ans;
}
static BOOL move_program() {
if (MoveFileEx(L"Calibre Portable\\calibre-portable.exe",
L"..\\calibre-portable.exe", MOVEFILE_REPLACE_EXISTING) == 0) {
show_last_error(L"Failed to move calibre-portable.exe, make sure calibre is not running");
return false;
}
if (directory_exists(L"..\\Calibre")) {
if (!rmtree(L"..\\Calibre")) {
show_error(L"Failed to delete the Calibre program folder. Make sure calibre is not running.");
return false;
}
}
if (MoveFileEx(L"Calibre Portable\\Calibre", L"..\\Calibre", 0) == 0) {
show_last_error(L"Failed to move calibre program folder");
return false;
}
if (!directory_exists(L"..\\Calibre Library")) {
MoveFileEx(L"Calibre Portable\\Calibre Library", L"..\\Calibre Library", 0);
}
if (!directory_exists(L"..\\Calibre Settings")) {
MoveFileEx(L"Calibre Portable\\Calibre Settings", L"..\\Calibre Settings", 0);
}
return true;
}
// }}}
static BOOL ensure_not_running(LPCWSTR dest) {
DWORD processes[4096], needed, num;
unsigned int i;
WCHAR name[4*MAX_PATH] = L"<unknown>";
HANDLE h;
DWORD len;
LPWSTR fname = NULL;
if ( !EnumProcesses( processes, sizeof(processes), &needed ) ) {
return true;
}
num = needed / sizeof(DWORD);
for (i = 0; i < num; i++) {
if (processes[i] == 0) continue;
h = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, processes[i] );
if (h != NULL) {
len = GetProcessImageFileNameW(h, name, 4*MAX_PATH);
CloseHandle(h);
if (len != 0) {
name[len] = 0;
fname = PathFindFileName(name);
if (wcscmp(fname, L"calibre.exe") == 0) {
show_error(L"Calibre appears to be running on your computer. Please quit it before trying to install Calibre Portable.");
return false;
}
}
}
}
return true;
}
static void launch_calibre() {
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if (CreateProcess(_wcsdup(L"calibre-portable.exe"), NULL,
NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_PROCESS_GROUP,
NULL, NULL, &si, &pi)
== 0) {
show_last_error(L"Failed to launch calibre portable");
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
LPVOID cdata = NULL;
DWORD csz = 0;
int ret = 0, argc;
HRESULT hr;
LPWSTR tgt = NULL, dest = NULL, *argv, unpack_dir = NULL;
BOOL existing = false, launch = false;
WCHAR buf[4*MAX_PATH] = {0}, mb_msg[4*MAX_PATH] = {0}, fdest[4*MAX_PATH] = {0};
if (!load_data(&cdata, &csz)) return 0;
hr = CoInitialize(NULL);
if (FAILED(hr)) { show_error(L"Failed to initialize COM"); return 0; }
// Get the target directory for installation
argv = CommandLineToArgvW(GetCommandLine(), &argc);
if (argv == NULL) { show_last_error(L"Failed to get command line"); return 0; }
if (argc > 1) {
tgt = argv[1];
} else {
tgt = get_directory_from_user();
if (tgt == NULL) goto end;
}
if (!directory_exists(tgt)) {
show_detailed_error(L"The specified directory does not exist: ",
tgt, 1);
goto end;
}
// Ensure the path to Calibre Portable is not too long
do {
if (!find_portable_dir(tgt, &dest, &existing)) goto end;
if (GetFullPathName(dest, MAX_PATH*4, fdest, NULL) == 0) {
show_last_error(L"Failed to resolve target folder");
goto end;
}
free(dest); dest = NULL;
if (wcslen(fdest) > 58) {
_snwprintf_s(buf, 4*MAX_PATH, _TRUNCATE,
L"Path to Calibre Portable (%s) too long. Must be less than 59 characters.", fdest);
if (!existing) RemoveDirectory(fdest);
show_error(buf);
tgt = get_directory_from_user();
if (tgt == NULL) goto end;
}
} while (wcslen(fdest) > 58);
// Confirm the user wants to upgrade
if (existing) {
_snwprintf_s(mb_msg, 4*MAX_PATH, _TRUNCATE,
L"An existing install of Calibre Portable was found at %s. Do you want to upgrade it?",
fdest);
if (MessageBox(NULL, mb_msg,
L"Upgrade Calibre Portable?", MB_ICONEXCLAMATION | MB_YESNO | MB_TOPMOST) != IDYES)
goto end;
}
if (existing) {
if (!ensure_not_running(fdest)) goto end;
}
// Make a temp dir to unpack into
if (!SetCurrentDirectoryW(fdest)) { show_detailed_error(L"Failed to change to unzip directory: ", fdest, 0); goto end; }
if ( (unpack_dir = make_unpack_dir()) == NULL ) goto end;
if (!SetCurrentDirectoryW(unpack_dir)) { show_detailed_error(L"Failed to change to unpack directory: ", fdest, 0); goto end; }
// Extract files
if (!extract(cdata, csz)) goto end;
// Move files from temp dir to the install dir
if (!move_program()) goto end;
SetCurrentDirectoryW(L"..");
_snwprintf_s(mb_msg, 4*MAX_PATH, _TRUNCATE,
L"Calibre Portable successfully installed to %s. Launch calibre?",
fdest);
launch = MessageBox(NULL, mb_msg,
L"Success", MB_ICONINFORMATION | MB_YESNO | MB_TOPMOST) == IDYES;
end:
if (unpack_dir != NULL) { rmtree(unpack_dir); free(unpack_dir); }
CoUninitialize();
if (launch) launch_calibre();
return 0;
}

View File

@ -8,6 +8,7 @@
#include <windows.h> #include <windows.h>
#include <Shlwapi.h>
#include <tchar.h> #include <tchar.h>
#include <wchar.h> #include <wchar.h>
#include <stdio.h> #include <stdio.h>
@ -134,6 +135,46 @@ void launch_calibre(LPCTSTR exe, LPCTSTR config_dir, LPCTSTR library_dir) {
} }
static BOOL is_dots(LPCTSTR name) {
return _tcscmp(name, _T(".")) == 0 || _tcscmp(name, _T("..")) == 0;
}
static void find_calibre_library(LPTSTR library_dir) {
TCHAR base[BUFSIZE] = {0}, buf[BUFSIZE] = {0};
WIN32_FIND_DATA fdFile;
HANDLE hFind = NULL;
_sntprintf_s(buf, BUFSIZE, _TRUNCATE, _T("%s\\metadata.db"), base);
if (PathFileExists(buf)) return; // Calibre Library/metadata.db exists, we use it
_tcscpy(base, library_dir);
PathRemoveFileSpec(base);
_sntprintf_s(buf, BUFSIZE, _TRUNCATE, _T("%s\\*"), base);
// Look for some other folder that contains a metadata.db file inside the Calibre Portable folder
if((hFind = FindFirstFileEx(buf, FindExInfoStandard, &fdFile, FindExSearchLimitToDirectories, NULL, 0))
!= INVALID_HANDLE_VALUE) {
do {
if(is_dots(fdFile.cFileName)) continue;
if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
_sntprintf_s(buf, BUFSIZE, _TRUNCATE, _T("%s\\%s\\metadata.db"), base, fdFile.cFileName);
if (PathFileExists(buf)) {
// some dir/metadata.db exists, we use it as the library
PathRemoveFileSpec(buf);
_tcscpy(library_dir, buf);
FindClose(hFind);
return;
}
}
} while(FindNextFile(hFind, &fdFile));
FindClose(hFind);
}
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{ {
LPTSTR app_dir, config_dir, exe, library_dir, too_long; LPTSTR app_dir, config_dir, exe, library_dir, too_long;
@ -147,6 +188,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
_sntprintf_s(exe, BUFSIZE, _TRUNCATE, _T("%sCalibre\\calibre.exe"), app_dir); _sntprintf_s(exe, BUFSIZE, _TRUNCATE, _T("%sCalibre\\calibre.exe"), app_dir);
_sntprintf_s(library_dir, BUFSIZE, _TRUNCATE, _T("%sCalibre Library"), app_dir); _sntprintf_s(library_dir, BUFSIZE, _TRUNCATE, _T("%sCalibre Library"), app_dir);
find_calibre_library(library_dir);
if ( _tcscnlen(library_dir, BUFSIZE) <= 74 ) { if ( _tcscnlen(library_dir, BUFSIZE) <= 74 ) {
launch_calibre(exe, config_dir, library_dir); launch_calibre(exe, config_dir, library_dir);
} else { } else {

View File

@ -30,7 +30,7 @@ def installers():
installers = list(map(installer_name, ('dmg', 'msi', 'tar.bz2'))) installers = list(map(installer_name, ('dmg', 'msi', 'tar.bz2')))
installers.append(installer_name('tar.bz2', is64bit=True)) installers.append(installer_name('tar.bz2', is64bit=True))
installers.insert(0, 'dist/%s-%s.tar.xz'%(__appname__, __version__)) installers.insert(0, 'dist/%s-%s.tar.xz'%(__appname__, __version__))
installers.append('dist/%s-portable-%s.zip'%(__appname__, __version__)) installers.append('dist/%s-portable-installer-%s.exe'%(__appname__, __version__))
return installers return installers
def installer_description(fname): def installer_description(fname):

View File

@ -4,7 +4,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
__appname__ = u'calibre' __appname__ = u'calibre'
numeric_version = (0, 8, 68) numeric_version = (0, 8, 69)
__version__ = u'.'.join(map(unicode, numeric_version)) __version__ = u'.'.join(map(unicode, numeric_version))
__author__ = u"Kovid Goyal <kovid@kovidgoyal.net>" __author__ = u"Kovid Goyal <kovid@kovidgoyal.net>"

View File

@ -1269,17 +1269,6 @@ class StoreBNStore(StoreBase):
headquarters = 'US' headquarters = 'US'
formats = ['NOOK'] formats = ['NOOK']
class StoreBeamEBooksDEStore(StoreBase):
name = 'Beam EBooks DE'
author = 'Charles Haley'
description = u'Bei uns finden Sie: Tausende deutschsprachige eBooks; Alle eBooks ohne hartes DRM; PDF, ePub und Mobipocket Format; Sofortige Verfügbarkeit - 24 Stunden am Tag; Günstige Preise; eBooks für viele Lesegeräte, PC,Mac und Smartphones; Viele Gratis eBooks'
actual_plugin = 'calibre.gui2.store.stores.beam_ebooks_de_plugin:BeamEBooksDEStore'
drm_free_only = True
headquarters = 'DE'
formats = ['EPUB', 'MOBI', 'PDF']
affiliate = True
class StoreBeWriteStore(StoreBase): class StoreBeWriteStore(StoreBase):
name = 'BeWrite Books' name = 'BeWrite Books'
description = u'Publishers of fine books. Highly selective and editorially driven. Does not offer: books for children or exclusively YA, erotica, swords-and-sorcery fantasy and space-opera-style science fiction. All other genres are represented.' description = u'Publishers of fine books. Highly selective and editorially driven. Does not offer: books for children or exclusively YA, erotica, swords-and-sorcery fantasy and space-opera-style science fiction. All other genres are represented.'
@ -1650,7 +1639,6 @@ plugins += [
StoreAmazonUKKindleStore, StoreAmazonUKKindleStore,
StoreBaenWebScriptionStore, StoreBaenWebScriptionStore,
StoreBNStore, StoreSonyStore, StoreBNStore, StoreSonyStore,
StoreBeamEBooksDEStore,
StoreBeWriteStore, StoreBeWriteStore,
StoreBiblioStore, StoreBiblioStore,
StoreBookotekaStore, StoreBookotekaStore,

View File

@ -62,7 +62,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None):
already have been called (for example in the main GUI), pass in the list of already have been called (for example in the main GUI), pass in the list of
device plugins as the plugins parameter. device plugins as the plugins parameter.
''' '''
import textwrap import textwrap, platform
from calibre.customize.ui import device_plugins from calibre.customize.ui import device_plugins
from calibre.devices.scanner import DeviceScanner, win_pnp_drives from calibre.devices.scanner import DeviceScanner, win_pnp_drives
from calibre.constants import iswindows, isosx, __version__ from calibre.constants import iswindows, isosx, __version__
@ -85,7 +85,21 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None):
out('Startup failed for device plugin: %s'%d) out('Startup failed for device plugin: %s'%d)
try: try:
out('Version:', __version__) out('Calibre Version:', __version__)
out(platform.platform(), platform.system())
out(platform.system_alias(platform.system(), platform.release(),
platform.version()))
out('Python', platform.python_version())
try:
if iswindows:
out('Windows:', platform.win32_ver())
elif isosx:
out('OSX:', platform.mac_ver())
else:
out('Linux:', platform.linux_distribution())
except:
pass
s = DeviceScanner() s = DeviceScanner()
s.scan() s.scan()
devices = (s.devices) devices = (s.devices)

View File

@ -45,6 +45,7 @@ class ANDROID(USBMS):
0xce5 : HTC_BCDS, 0xce5 : HTC_BCDS,
0xcec : HTC_BCDS, 0xcec : HTC_BCDS,
0x2910 : HTC_BCDS, 0x2910 : HTC_BCDS,
0xe77 : HTC_BCDS,
0xff9 : HTC_BCDS, 0xff9 : HTC_BCDS,
}, },

View File

@ -12,7 +12,10 @@ import struct
from calibre.ebooks.mobi.reader.mobi6 import MobiReader from calibre.ebooks.mobi.reader.mobi6 import MobiReader
from calibre.ebooks.pdb.header import PdbHeaderReader from calibre.ebooks.pdb.header import PdbHeaderReader
from calibre.ebooks.mobi.reader.headers import MetadataHeader
from calibre.utils.logging import default_log from calibre.utils.logging import default_log
from calibre import prints
from calibre.constants import DEBUG
class APNXBuilder(object): class APNXBuilder(object):
''' '''
@ -25,11 +28,32 @@ class APNXBuilder(object):
pass in a value to page_count, otherwise a count will be estimated pass in a value to page_count, otherwise a count will be estimated
using either the fast or accurate algorithm. using either the fast or accurate algorithm.
''' '''
# Check that this is really a MOBI file. import uuid
apnx_meta = { 'guid': str(uuid.uuid4()).replace('-', '')[:8], 'asin':
'', 'cdetype': 'EBOK', 'format': 'MOBI_7', 'acr': '' }
with open(mobi_file_path, 'rb') as mf: with open(mobi_file_path, 'rb') as mf:
ident = PdbHeaderReader(mf).identity() ident = PdbHeaderReader(mf).identity()
if ident != 'BOOKMOBI': if ident != 'BOOKMOBI':
raise Exception(_('Not a valid MOBI file. Reports identity of %s') % ident) # Check that this is really a MOBI file.
raise Exception(_('Not a valid MOBI file. Reports identity of %s') % ident)
apnx_meta['acr'] = str(PdbHeaderReader(mf).name())
# We'll need the PDB name, the MOBI version, and some metadata to make FW 3.4 happy with KF8 files...
with open(mobi_file_path, 'rb') as mf:
mh = MetadataHeader(mf, default_log)
if mh.mobi_version == 8:
apnx_meta['format'] = 'MOBI_8'
else:
apnx_meta['format'] = 'MOBI_7'
if mh.exth is None or not mh.exth.cdetype:
apnx_meta['cdetype'] = 'EBOK'
else:
apnx_meta['cdetype'] = str(mh.exth.cdetype)
if mh.exth is None or not mh.exth.uuid:
apnx_meta['asin'] = ''
else:
apnx_meta['asin'] = str(mh.exth.uuid)
# Get the pages depending on the chosen parser # Get the pages depending on the chosen parser
pages = [] pages = []
@ -51,23 +75,32 @@ class APNXBuilder(object):
raise Exception(_('Could not generate page mapping.')) raise Exception(_('Could not generate page mapping.'))
# Generate the APNX file from the page mapping. # Generate the APNX file from the page mapping.
apnx = self.generate_apnx(pages) apnx = self.generate_apnx(pages, apnx_meta)
# Write the APNX. # Write the APNX.
with open(apnx_path, 'wb') as apnxf: with open(apnx_path, 'wb') as apnxf:
apnxf.write(apnx) apnxf.write(apnx)
def generate_apnx(self, pages): def generate_apnx(self, pages, apnx_meta):
import uuid
apnx = '' apnx = ''
content_vals = { if DEBUG:
'guid': str(uuid.uuid4()).replace('-', '')[:8], prints('APNX META: guid:', apnx_meta['guid'])
'isbn': '', prints('APNX META: ASIN:', apnx_meta['asin'])
} prints('APNX META: CDE:', apnx_meta['cdetype'])
prints('APNX META: format:', apnx_meta['format'])
prints('APNX META: Name:', apnx_meta['acr'])
content_header = '{"contentGuid":"%(guid)s","asin":"%(isbn)s","cdeType":"EBOK","fileRevisionId":"1"}' % content_vals # Updated header if we have a KF8 file...
page_header = '{"asin":"%(isbn)s","pageMap":"(1,a,1)"}' % content_vals if apnx_meta['format'] == 'MOBI_8':
content_header = '{"contentGuid":"%(guid)s","asin":"%(asin)s","cdeType":"%(cdetype)s","format":"%(format)s","fileRevisionId":"1","acr":"%(acr)s"}' % apnx_meta
else:
# My 5.1.x Touch & 3.4 K3 seem to handle the 'extended' header fine for legacy mobi files, too. But, since they still handle this one too, let's try not to break old devices, and keep using the simple header ;).
content_header = '{"contentGuid":"%(guid)s","asin":"%(asin)s","cdeType":"%(cdetype)s","fileRevisionId":"1"}' % apnx_meta
page_header = '{"asin":"%(asin)s","pageMap":"(1,a,1)"}' % apnx_meta
if DEBUG:
prints('APNX Content Header:', content_header)
apnx += struct.pack('>I', 65537) apnx += struct.pack('>I', 65537)
apnx += struct.pack('>I', 12 + len(content_header)) apnx += struct.pack('>I', 12 + len(content_header))

View File

@ -289,7 +289,8 @@ class KINDLE2(KINDLE):
description = _('Communicate with the Kindle 2/3/4/Touch eBook reader.') description = _('Communicate with the Kindle 2/3/4/Touch eBook reader.')
FORMATS = ['azw3'] + KINDLE.FORMATS + ['pdf', 'azw4', 'pobi'] FORMATS = ['azw3'] + KINDLE.FORMATS + ['pdf', 'azw4', 'pobi']
DELETE_EXTS = KINDLE.DELETE_EXTS + ['.mbp1', '.mbs', '.sdr'] DELETE_EXTS = KINDLE.DELETE_EXTS + ['.mbp1', '.mbs', '.sdr', '.han']
# On the Touch, there's also .asc files, but not using the same basename (for X-Ray & End Actions), azw3f & azw3r files, but all of them are in the .sdr sidecar folder
PRODUCT_ID = [0x0002, 0x0004] PRODUCT_ID = [0x0002, 0x0004]
BCD = [0x0100] BCD = [0x0100]

View File

@ -8,6 +8,7 @@ import time
from calibre.utils.date import parse_date from calibre.utils.date import parse_date
from calibre.devices.usbms.books import Book as Book_ from calibre.devices.usbms.books import Book as Book_
from calibre.ebooks.metadata import author_to_author_sort
class Book(Book_): class Book(Book_):
@ -20,6 +21,7 @@ class Book(Book_):
self.authors = [''] self.authors = ['']
else: else:
self.authors = [authors] self.authors = [authors]
self.author_sort = author_to_author_sort(self.authors[0])
if not title: if not title:
self.title = _('Unknown') self.title = _('Unknown')

View File

@ -45,13 +45,12 @@ class MTP_DEVICE(BASE):
@property @property
def prefs(self): def prefs(self):
if self._prefs is None: if self._prefs is None:
from calibre.library.save_to_disk import config
self._prefs = p = JSONConfig('mtp_devices') self._prefs = p = JSONConfig('mtp_devices')
p.defaults['format_map'] = self.FORMATS p.defaults['format_map'] = self.FORMATS
p.defaults['send_to'] = ['Calibre_Companion', 'Books', p.defaults['send_to'] = ['Calibre_Companion', 'Books',
'eBooks/import', 'eBooks', 'wordplayer/calibretransfer', 'eBooks/import', 'eBooks', 'wordplayer/calibretransfer',
'sdcard/ebooks', 'kindle'] 'sdcard/ebooks', 'kindle']
p.defaults['send_template'] = config().parse().send_template p.defaults['send_template'] = '{title} - {authors}'
p.defaults['blacklist'] = [] p.defaults['blacklist'] = []
p.defaults['history'] = {} p.defaults['history'] = {}
p.defaults['rules'] = [] p.defaults['rules'] = []
@ -291,7 +290,7 @@ class MTP_DEVICE(BASE):
prefix_path=path, prefix_path=path,
path_type=posixpath, path_type=posixpath,
maxlen=self.MAX_PATH_LEN, maxlen=self.MAX_PATH_LEN,
use_subdirs=True, use_subdirs='/' in self.save_template,
news_in_folder=self.NEWS_IN_FOLDER, news_in_folder=self.NEWS_IN_FOLDER,
) )
return tuple(x for x in filepath.split('/')) return tuple(x for x in filepath.split('/'))

View File

@ -204,7 +204,7 @@ class FilesystemCache(object):
except KeyError: except KeyError:
# Parent does not exist, set the parent to be the storage # Parent does not exist, set the parent to be the storage
# object # object
sid = p.storage_id sid = item.storage_id
if sid not in all_storage_ids: if sid not in all_storage_ids:
sid = all_storage_ids[0] sid = all_storage_ids[0]
item.parent_id = sid item.parent_id = sid

View File

@ -292,13 +292,7 @@
DEVICE_FLAG_PLAYLIST_SPL_V1 | DEVICE_FLAG_PLAYLIST_SPL_V1 |
DEVICE_FLAG_UNIQUE_FILENAMES | DEVICE_FLAG_UNIQUE_FILENAMES |
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST }, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
// From qnub <qnub@users.sourceforge.net> // The "YP-R2" (0x04e8/0x512d) is NOT MTP, it is UMS only.
// Guessing on .spl flag
{ "Samsung", 0x04e8, "YP-R2", 0x512d,
DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_PLAYLIST_SPL_V1 |
DEVICE_FLAG_UNIQUE_FILENAMES |
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
// From Manuel Carro // From Manuel Carro
// Copied from Q2 // Copied from Q2
{ "Samsung", 0x04e8, "YP-Q3", 0x5130, { "Samsung", 0x04e8, "YP-Q3", 0x5130,
@ -357,25 +351,30 @@
{ "Samsung", 0x04e8, "GT-S8500", 0x6819, { "Samsung", 0x04e8, "GT-S8500", 0x6819,
DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_PLAYLIST_SPL_V1 }, DEVICE_FLAG_PLAYLIST_SPL_V1 },
// From Harrison Metzger <harrisonmetz@gmail.com>
{ "Samsung", 0x04e8,
"Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates", 0x685c,
DEVICE_FLAGS_ANDROID_BUGS |
DEVICE_FLAG_PLAYLIST_SPL_V2 },
// Reported by David Goodenough <dfgdga@users.sourceforge.net>
// Guessing on flags.
{ "Samsung", 0x04e8, "Galaxy Y", 0x685e,
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_LONG_TIMEOUT |
DEVICE_FLAG_PROPLIST_OVERRIDES_OI },
/* /*
* This entry (device 0x6860) seems to be used on a *lot* of Samsung * These entries seems to be used on a *lot* of Samsung
* Android (gingerbread, 2.3) phones. It is *not* the Android MTP stack * Android phones. It is *not* the Android MTP stack but an internal
* but an internal Samsung stack. * Samsung stack. The devices present a few different product IDs
* depending on mode:
* *
* Popular devices: Galaxy S2 and S3. * 0x685b - UMS
* 0x685c - MTP + ADB
* 0x685e - UMS + CDC
* 0x6860 - MTP mode (default)
* 0x6863 - USB CDC RNDIS (not MTP)
* 0x6865 - PTP mode (not MTP)
* 0x6877 - Kies mode? Does it have MTP?
*
* Used on these samsung devices:
* GT P7310/P7510/N7000/I9100/I9250/I9300
* Galaxy Nexus
* Galaxy Tab 7.7/10.1
* Galaxy S GT-I9000
* Galaxy S Advance GT-I9070
* Galaxy S2
* Galaxy S3
* Galaxy Note
* Galaxy Y
* *
* - It seems that some PTP commands are broken. * - It seems that some PTP commands are broken.
* - Devices seem to have a connection timeout, the session must be * - Devices seem to have a connection timeout, the session must be
@ -385,15 +384,30 @@
* US markets for some weird reason. * US markets for some weird reason.
* *
* From: Ignacio Martínez <ignacio.martinezrivera@yahoo.es> and others * From: Ignacio Martínez <ignacio.martinezrivera@yahoo.es> and others
* From Harrison Metzger <harrisonmetz@gmail.com>
*/ */
{ "Samsung", 0x04e8, { "Samsung", 0x04e8,
"GT P7310/P7510/N7000/I9070/I9100/I9300 Galaxy Tab 7.7/10.1/S2/S3/Nexus/Note/Y", 0x6860, "Galaxy models (MTP+ADB)", 0x685c,
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_LONG_TIMEOUT |
DEVICE_FLAG_PROPLIST_OVERRIDES_OI },
// Reported by David Goodenough <dfgdga@users.sourceforge.net>
// Guessing on flags.
{ "Samsung", 0x04e8, "Galaxy Y", 0x685e,
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_LONG_TIMEOUT |
DEVICE_FLAG_PROPLIST_OVERRIDES_OI },
{ "Samsung", 0x04e8,
"Galaxy models (MTP)", 0x6860,
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_LONG_TIMEOUT | DEVICE_FLAG_LONG_TIMEOUT |
DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, DEVICE_FLAG_PROPLIST_OVERRIDES_OI },
// Note: ID 0x6865 is some PTP mode! Don't add it.
// From: Erik Berglund <erikjber@users.sourceforge.net> // From: Erik Berglund <erikjber@users.sourceforge.net>
// Logs indicate this needs DEVICE_FLAG_NO_ZERO_READS // Logs indicate this needs DEVICE_FLAG_NO_ZERO_READS
// No Samsung platlists on this device. // No Samsung platlists on this device.
@ -401,7 +415,7 @@
// i5800 duplicate reported by igel <igel-kun@users.sourceforge.net> // i5800 duplicate reported by igel <igel-kun@users.sourceforge.net>
// Guessing this has the same problematic MTP stack as the device // Guessing this has the same problematic MTP stack as the device
// above. // above.
{ "Samsung", 0x04e8, "Galaxy S GT-I9000/Galaxy 3 i5800/Kies mode", 0x6877, { "Samsung", 0x04e8, "Galaxy models Kies mode", 0x6877,
DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_UNLOAD_DRIVER |
DEVICE_FLAG_LONG_TIMEOUT | DEVICE_FLAG_LONG_TIMEOUT |
DEVICE_FLAG_PROPLIST_OVERRIDES_OI }, DEVICE_FLAG_PROPLIST_OVERRIDES_OI },
@ -526,6 +540,9 @@
{ "Acer", 0x0502, "Iconia TAB A200 (ID2)", 0x337d, DEVICE_FLAGS_ANDROID_BUGS }, { "Acer", 0x0502, "Iconia TAB A200 (ID2)", 0x337d, DEVICE_FLAGS_ANDROID_BUGS },
// Reported by nE0sIghT <ne0sight@users.sourceforge.net> // Reported by nE0sIghT <ne0sight@users.sourceforge.net>
{ "Acer", 0x0502, "Iconia TAB A510", 0x338a, DEVICE_FLAGS_ANDROID_BUGS }, { "Acer", 0x0502, "Iconia TAB A510", 0x338a, DEVICE_FLAGS_ANDROID_BUGS },
// Reported by Maxime de Roucy <maxime1986@users.sourceforge.net>
{ "Acer", 0x0502, "E350 Liquid Gallant Duo", 0x33c3,
DEVICE_FLAGS_ANDROID_BUGS },
/* /*
* SanDisk * SanDisk
@ -859,6 +876,7 @@
{ "Archos", 0x0e79, "SPOD (MTP mode)", 0x1341, DEVICE_FLAG_UNLOAD_DRIVER }, { "Archos", 0x0e79, "SPOD (MTP mode)", 0x1341, DEVICE_FLAG_UNLOAD_DRIVER },
{ "Archos", 0x0e79, "5S IT (MTP mode)", 0x1351, DEVICE_FLAG_UNLOAD_DRIVER }, { "Archos", 0x0e79, "5S IT (MTP mode)", 0x1351, DEVICE_FLAG_UNLOAD_DRIVER },
{ "Archos", 0x0e79, "5H IT (MTP mode)", 0x1357, DEVICE_FLAG_UNLOAD_DRIVER }, { "Archos", 0x0e79, "5H IT (MTP mode)", 0x1357, DEVICE_FLAG_UNLOAD_DRIVER },
{ "Archos", 0x0e79, "Arnova Childpad", 0x1458, DEVICE_FLAG_UNLOAD_DRIVER },
// Reported by anonymous Sourceforge user // Reported by anonymous Sourceforge user
{ "Archos", 0x0e79, "8o G9 (MTP mode)", 0x1508, DEVICE_FLAG_UNLOAD_DRIVER }, { "Archos", 0x0e79, "8o G9 (MTP mode)", 0x1508, DEVICE_FLAG_UNLOAD_DRIVER },
// Reported by Clément <clemvangelis@users.sourceforge.net> // Reported by Clément <clemvangelis@users.sourceforge.net>
@ -1264,6 +1282,9 @@
{ "LG Electronics Inc.", 0x1004, "V909 G-Slate", 0x61f9, { "LG Electronics Inc.", 0x1004, "V909 G-Slate", 0x61f9,
DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
DEVICE_FLAG_UNLOAD_DRIVER }, DEVICE_FLAG_UNLOAD_DRIVER },
// Reported by Brian J. Murrell
{ "LG Electronics Inc.", 0x1004, "LG-E617G/P700", 0x631c,
DEVICE_FLAGS_ANDROID_BUGS },
/* /*
* Sony * Sony
@ -1346,6 +1367,9 @@
// Reported by Jan Rheinlaender <jrheinlaender@users.sourceforge.net> // Reported by Jan Rheinlaender <jrheinlaender@users.sourceforge.net>
{ "Sony", 0x054c, "NWZ-S765", 0x05a8, { "Sony", 0x054c, "NWZ-S765", 0x05a8,
DEVICE_FLAGS_SONY_NWZ_BUGS }, DEVICE_FLAGS_SONY_NWZ_BUGS },
// Olivier Keshavjee <olivierkes@users.sourceforge.net>
{ "Sony", 0x054c, "Sony Tablet S", 0x05b3,
DEVICE_FLAGS_ANDROID_BUGS },
// Reported by ghalambaz <ghalambaz@users.sourceforge.net> // Reported by ghalambaz <ghalambaz@users.sourceforge.net>
{ "Sony", 0x054c, "Sony Tablet S1", 0x05b4, { "Sony", 0x054c, "Sony Tablet S1", 0x05b4,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
@ -1430,7 +1454,7 @@
* Legend: * Legend:
* MTP = Media Transfer Protocol * MTP = Media Transfer Protocol
* UMS = USB Mass Storage Protocol * UMS = USB Mass Storage Protocol
* ADB = Android Debug Bridhe Protocol * ADB = Android Debug Bridge Protocol
* CDC = Communications Device Class, Internet Sharing * CDC = Communications Device Class, Internet Sharing
* *
* 0x0nnn = MTP * 0x0nnn = MTP
@ -1450,120 +1474,103 @@
* detection has to be more elaborate. The code in libmtp.c will do * detection has to be more elaborate. The code in libmtp.c will do
* this and assign the proper bug flags (hopefully). * this and assign the proper bug flags (hopefully).
* That is why DEVICE_FLAG_NONE is used for these devices. * That is why DEVICE_FLAG_NONE is used for these devices.
*
* Devices reported by:
* Jonas Salling
* Eamonn Webster <eweb@users.sourceforge.net>
* Alejandro DC <Alejandro_DC@users.sourceforge.ne>
* StehpanKa <stehp@users.sourceforge.net>
* hdhoang <hdhoang@users.sourceforge.net>
* Paul Taylor
* Bruno Basilio <bbasilio@users.sourceforge.net>
* Christoffer Holmstedt <christofferh@users.sourceforge.net>
* equaeghe <equaeghe@users.sourceforge.net>
* Ondra Lengal
* Michael K. <kmike@users.sourceforge.net>
* Jean-François B. <changi67@users.sourceforge.net>
* Eduard Bloch <blade@debian.org>
* Ah Hong <hongster@users.sourceforge.net>
*/ */
// Reported by Jonas Salling <>
// Erroneous MTP implementation seems to be from Aricent, returns
// broken transaction ID.
{ "SonyEricsson", 0x0fce, "LT15i (Xperia arc S)", 0x014f, { "SonyEricsson", 0x0fce, "LT15i (Xperia arc S)", 0x014f,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Eamonn Webster <eweb@users.sourceforge.net>
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "MT11i Xperia Neo", 0x0156, { "SonyEricsson", 0x0fce, "MT11i Xperia Neo", 0x0156,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Alejandro DC <Alejandro_DC@users.sourceforge.ne>
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "MK16i Xperia", 0x015a, { "SonyEricsson", 0x0fce, "MK16i Xperia", 0x015a,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by <wealas@users.sourceforge.net>
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "ST18a Xperia Ray", 0x0161, { "SonyEricsson", 0x0fce, "ST18a Xperia Ray", 0x0161,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
/*
* Reported by StehpanKa <stehp@users.sourceforge.net>
* Android with homebrew MTP stack in one firmware, possibly Aricent
* Android with Android stack in another one, so let the run-time
* detector look up the device bug flags, set to NONE initially.
*/
{ "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro", 0x0166, { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro", 0x0166,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by hdhoang <hdhoang@users.sourceforge.net>
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "ST15i Xperia Mini", 0x0167, { "SonyEricsson", 0x0fce, "ST15i Xperia Mini", 0x0167,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Paul Taylor { "SonyEricsson", 0x0fce, "ST17i Xperia Active", 0x0168,
{ "SONY", 0x0fce, "Xperia S", 0x0169, DEVICE_FLAG_NONE },
{ "SONY", 0x0fce, "LT26i Xperia S", 0x0169,
DEVICE_FLAG_NO_ZERO_READS }, DEVICE_FLAG_NO_ZERO_READS },
// Reported by Bruno Basilio <bbasilio@users.sourceforge.net>
{ "SONY", 0x0fce, "WT19i Live Walkman", 0x016d, { "SONY", 0x0fce, "WT19i Live Walkman", 0x016d,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Christoffer Holmstedt <christofferh@users.sourceforge.net>
{ "SONY", 0x0fce, "ST21i Xperia Tipo", 0x0170, { "SONY", 0x0fce, "ST21i Xperia Tipo", 0x0170,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by equaeghe <equaeghe@users.sourceforge.net>
{ "SONY", 0x0fce, "ST15i Xperia U", 0x0171, { "SONY", 0x0fce, "ST15i Xperia U", 0x0171,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Ondra Lengal { "SONY", 0x0fce, "LT22i Xperia P", 0x0172,
{ "SONY", 0x0fce, "Xperia P", 0x0172,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Guessing on this one
{ "SONY", 0x0fce, "LT26w Xperia Acro S", 0x0176, { "SONY", 0x0fce, "LT26w Xperia Acro S", 0x0176,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
/* /*
* MTP+MSC personalities of MTP devices (see above) * MTP+UMS personalities of MTP devices (see above)
*/ */
// Guessing on this one { "SonyEricsson", 0x0fce, "ST17i Xperia Active (MTP+UMS mode)", 0x4168,
{ "SONY", 0x0fce, "Xperia S (MTP+ADB mode)", 0x4169, DEVICE_FLAG_NONE },
{ "SONY", 0x0fce, "LT26i Xperia S (MTP+UMS mode)", 0x4169,
DEVICE_FLAG_NO_ZERO_READS }, DEVICE_FLAG_NO_ZERO_READS },
// Guessing on this one { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+UMS mode)", 0x4170,
{ "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+MSC mode)", 0x4170,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by equaeghe <equaeghe@users.sourceforge.net> { "SONY", 0x0fce, "ST25i Xperia U (MTP+UMS mode)", 0x4171,
{ "SONY", 0x0fce, "ST25i Xperia U (MTP+MSC mode)", 0x4171,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Guessing on this one { "SONY", 0x0fce, "LT22i Xperia P (MTP+UMS mode)", 0x4172,
{ "SONY", 0x0fce, "Xperia P (MTP+MSC mode)", 0x4172,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Guessing on this one { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+UMS mode)", 0x4176,
{ "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+MSC mode)", 0x4176,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
/* /*
* MTP+ADB personalities of MTP devices (see above) * MTP+ADB personalities of MTP devices (see above)
*/ */
// Reported by anonymous sourceforge user
// Suspect Aricent stack, guessing on these bug flags
{ "SonyEricsson", 0x0fce, "LT15i Xperia Arc (MTP+ADB mode)", 0x514f, { "SonyEricsson", 0x0fce, "LT15i Xperia Arc (MTP+ADB mode)", 0x514f,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Michael K. <kmike@users.sourceforge.net>
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "MT11i Xperia Neo (MTP+ADB mode)", 0x5156, { "SonyEricsson", 0x0fce, "MT11i Xperia Neo (MTP+ADB mode)", 0x5156,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Jean-François B. <changi67@users.sourceforge.net> { "SonyEricsson", 0x0fce, "ST17i Xperia Active (MTP+ADB mode)", 0x5168,
{ "SONY", 0x0fce, "Xperia S (MTP+ADB mode)", 0x5169, DEVICE_FLAG_NONE },
{ "SONY", 0x0fce, "LT26i Xperia S (MTP+ADB mode)", 0x5169,
DEVICE_FLAG_NO_ZERO_READS }, DEVICE_FLAG_NO_ZERO_READS },
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "MK16i Xperia (MTP+ADB mode)", 0x515a, { "SonyEricsson", 0x0fce, "MK16i Xperia (MTP+ADB mode)", 0x515a,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Eduard Bloch <blade@debian.org>
// Xperia Ray (2012), SE Android 2.3.4, flags from ST18a
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "ST18i Xperia Ray (MTP+ADB mode)", 0x5161, { "SonyEricsson", 0x0fce, "ST18i Xperia Ray (MTP+ADB mode)", 0x5161,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by StehpanKa <stehp@users.sourceforge.net>
// Android with homebrew MTP stack, possibly Aricent
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x5166, { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x5166,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Android with homebrew MTP stack, possibly Aricent
// Runtime detect the Aricent or Android stack
{ "SonyEricsson", 0x0fce, "ST15i Xperia Mini (MTP+ADB mode)", 0x5167, { "SonyEricsson", 0x0fce, "ST15i Xperia Mini (MTP+ADB mode)", 0x5167,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
{ "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+? mode)", 0x516d, { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x516d,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Guessing on this one
{ "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+ADB mode)", 0x5170, { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+ADB mode)", 0x5170,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by equaeghe <equaeghe@users.sourceforge.net>
{ "SONY", 0x0fce, "ST25i Xperia U (MTP+ADB mode)", 0x5171, { "SONY", 0x0fce, "ST25i Xperia U (MTP+ADB mode)", 0x5171,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Ondra Lengál { "SONY", 0x0fce, "LT22i Xperia P (MTP+ADB mode)", 0x5172,
{ "SONY", 0x0fce, "Xperia P (MTP+ADB mode)", 0x5172,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
// Reported by Ah Hong <hongster@users.sourceforge.net>
{ "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+ADB mode)", 0x5176, { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+ADB mode)", 0x5176,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
{ "SONY", 0x0fce, "MT27i Xperia Sola (MTP+MSC+? mode)", 0xa173,
/*
* MTP+UMS+? modes
* No reports on other personalities on these devices.
*/
{ "SONY", 0x0fce, "MT27i Xperia Sola (MTP+UMS+? mode)", 0xa173,
DEVICE_FLAG_NONE },
{ "SONY", 0x0fce, "ST27i Xperia Go (MTP+UMS+? mode)", 0xa17e,
DEVICE_FLAG_NONE }, DEVICE_FLAG_NONE },
/* /*
@ -1591,6 +1598,9 @@
// Reported by B,H,Kissinger <mrkissinger@users.sourceforge.net> // Reported by B,H,Kissinger <mrkissinger@users.sourceforge.net>
{ "Motorola", 0x22b8, "XT912/XT928", 0x4362, { "Motorola", 0x22b8, "XT912/XT928", 0x4362,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
// Reported by Lundgren <alundgren@users.sourceforge.net>
{ "Motorola", 0x22b8, "DROID4", 0x437f,
DEVICE_FLAGS_ANDROID_BUGS },
// Reported by Marcus Meissner to libptp2 // Reported by Marcus Meissner to libptp2
{ "Motorola", 0x22b8, "IdeaPad K1", 0x4811, { "Motorola", 0x22b8, "IdeaPad K1", 0x4811,
DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST }, DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST },
@ -1603,10 +1613,32 @@
// Reported by anonymous user // Reported by anonymous user
{ "Motorola", 0x22b8, "RAZR2 V8/U9/Z6", 0x6415, { "Motorola", 0x22b8, "RAZR2 V8/U9/Z6", 0x6415,
DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST }, DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST },
// Reported by Google Inc's Yavor Goulishev <yavor@google.com> /*
// Android 3.0 MTP stack seems to announce that it supports the * Motorola Xoom (Wingray) variants
// list operations, but they do not work? *
{ "Motorola", 0x22b8, "Xoom (ID 1)", 0x70a8, DEVICE_FLAGS_ANDROID_BUGS }, * These devices seem to use these product IDs simulatenously
* https://code.google.com/p/android-source-browsing/source/browse/init.stingray.usb.rc?repo=device--moto--wingray
*
* 0x70a3 - Factory test - reported as early MTP ID
* 0x70a8 - MTP
* 0x70a9 - MTP+ADB
* 0x70ae - RNDIS
* 0x70af - RNDIS+ADB
* 0x70b0 - ACM
* 0x70b1 - ACM+ADB
* 0x70b2 - ACM+RNDIS
* 0x70b3 - ACM+RNDIS+ADB
* 0x70b4 - PTP
* 0x70b5 - PTP+ADB
*
* Reported by Google Inc's Yavor Goulishev <yavor@google.com>
*/
{ "Motorola", 0x22b8, "Xoom (Factory test)", 0x70a3,
DEVICE_FLAGS_ANDROID_BUGS },
{ "Motorola", 0x22b8, "Xoom (MTP)", 0x70a8,
DEVICE_FLAGS_ANDROID_BUGS },
{ "Motorola", 0x22b8, "Xoom (MTP+ADB)", 0x70a9,
DEVICE_FLAGS_ANDROID_BUGS },
// Reported by anonymous Sourceforge user // Reported by anonymous Sourceforge user
// "carried by C Spire and other CDMA US carriers" // "carried by C Spire and other CDMA US carriers"
{ "Motorola", 0x22b8, "Milestone X2", 0x70ca, DEVICE_FLAGS_ANDROID_BUGS }, { "Motorola", 0x22b8, "Milestone X2", 0x70ca, DEVICE_FLAGS_ANDROID_BUGS },
@ -1629,17 +1661,15 @@
{ "Google Inc (for Samsung)", 0x18d1, "Nexus S", 0x4e21, { "Google Inc (for Samsung)", 0x18d1, "Nexus S", 0x4e21,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
// Reported by Chris Smith <tcgsmythe@users.sourceforge.net> // Reported by Chris Smith <tcgsmythe@users.sourceforge.net>
{ "Google Inc (for Asus)", 0x18d1, "Nexus 7 (mode 1)", 0x4e41, { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (MTP)", 0x4e41,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
// Reported by Michael Hess <mhess126@gmail.com> // Reported by Michael Hess <mhess126@gmail.com>
{ "Google Inc (for Asus)", 0x18d1, "Nexus 7 (mode 2)", 0x4e42, { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (MTP+ADB)", 0x4e42,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
// WiFi-only version of Xoom // WiFi-only version of Xoom
// See: http://bugzilla.gnome.org/show_bug.cgi?id=647506 // See: http://bugzilla.gnome.org/show_bug.cgi?id=647506
{ "Google Inc (for Motorola)", 0x18d1, "Xoom (MZ604)", 0x70a8, { "Google Inc (for Motorola)", 0x18d1, "Xoom (MZ604)", 0x70a8,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
{ "Google Inc (for Motorola)", 0x22b8, "Xoom (ID 2)", 0x70a9,
DEVICE_FLAGS_ANDROID_BUGS },
{ "Google Inc (for Toshiba)", 0x18d1, "Thrive 7/AT105", 0x7102, { "Google Inc (for Toshiba)", 0x18d1, "Thrive 7/AT105", 0x7102,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
{ "Google Inc (for Lenovo)", 0x18d1, "Ideapad K1", 0x740a, { "Google Inc (for Lenovo)", 0x18d1, "Ideapad K1", 0x740a,
@ -1769,6 +1799,9 @@
// Reported by jaile <jaile@users.sourceforge.net> // Reported by jaile <jaile@users.sourceforge.net>
{ "Asus", 0x0b05, "TF300 Transformer (USB debug mode)", 0x4c81, { "Asus", 0x0b05, "TF300 Transformer (USB debug mode)", 0x4c81,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
// Repored by Florian Apolloner <f-apolloner@users.sourceforge.net>
{ "Asus", 0x0b05, "TF700 Transformer", 0x4c90,
DEVICE_FLAGS_ANDROID_BUGS },
// Reported by anonymous Sourceforge user // Reported by anonymous Sourceforge user
{ "Asus", 0x0b05, "TF201 Transformer Prime (keyboard dock)", 0x4d00, { "Asus", 0x0b05, "TF201 Transformer Prime (keyboard dock)", 0x4d00,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
@ -1795,6 +1828,13 @@
// Adding Android default bug flags since it appears to be an Android // Adding Android default bug flags since it appears to be an Android
{ "Lenovo", 0x17ef, "ThinkPad Tablet", 0x741c, { "Lenovo", 0x17ef, "ThinkPad Tablet", 0x741c,
DEVICE_FLAGS_ANDROID_BUGS }, DEVICE_FLAGS_ANDROID_BUGS },
// Reported by: XChesser <XChesser@users.sourceforge.net>
{ "Lenovo", 0x17ef, "P700", 0x7497,
DEVICE_FLAGS_ANDROID_BUGS },
// Reported by: anonymous sourceforge user
{ "Lenovo", 0x17ef, "Lifetab S9512", 0x74cc,
DEVICE_FLAGS_ANDROID_BUGS },
/* /*
* Huawei * Huawei

View File

@ -146,6 +146,13 @@ class MTP_DEVICE(MTPDeviceBase):
p(traceback.format_exc()) p(traceback.format_exc())
return False return False
if not pnp_ids:
p('The Windows WPD service says there are no portable devices connected')
return False
p('List of WPD PNP ids:')
p(pprint.pformat(list(pnp_ids)))
for pnp_id in pnp_ids: for pnp_id in pnp_ids:
try: try:
data = self.wpd.device_info(pnp_id) data = self.wpd.device_info(pnp_id)

View File

@ -163,7 +163,7 @@ def render_html(path_to_html, width=590, height=750, as_xhtml=True):
def check_ebook_format(stream, current_guess): def check_ebook_format(stream, current_guess):
ans = current_guess ans = current_guess
if current_guess.lower() in ('prc', 'mobi', 'azw', 'azw1'): if current_guess.lower() in ('prc', 'mobi', 'azw', 'azw1', 'azw3'):
stream.seek(0) stream.seek(0)
if stream.read(3) == 'TPZ': if stream.read(3) == 'TPZ':
ans = 'tpz' ans = 'tpz'

View File

@ -70,7 +70,7 @@ class ArchiveExtract(FileTypePlugin):
fname = fnames[0] fname = fnames[0]
ext = os.path.splitext(fname)[1][1:] ext = os.path.splitext(fname)[1][1:]
if ext.lower() not in ('lit', 'epub', 'mobi', 'prc', 'rtf', 'pdf', if ext.lower() not in ('lit', 'epub', 'mobi', 'prc', 'rtf', 'pdf',
'mp3', 'pdb', 'azw', 'azw1', 'fb2'): 'mp3', 'pdb', 'azw', 'azw1', 'azw3', 'fb2'):
return archive return archive
of = self.temporary_file('_archive_extract.'+ext) of = self.temporary_file('_archive_extract.'+ext)

View File

@ -15,7 +15,7 @@ _METADATA_PRIORITIES = [
'html', 'htm', 'xhtml', 'xhtm', 'html', 'htm', 'xhtml', 'xhtm',
'rtf', 'fb2', 'pdf', 'prc', 'odt', 'rtf', 'fb2', 'pdf', 'prc', 'odt',
'epub', 'lit', 'lrx', 'lrf', 'mobi', 'epub', 'lit', 'lrx', 'lrf', 'mobi',
'rb', 'imp', 'azw', 'snb' 'azw', 'azw3', 'azw1', 'rb', 'imp', 'snb'
] ]
# The priorities for loading metadata from different file types # The priorities for loading metadata from different file types

View File

@ -341,11 +341,14 @@ class MetadataUpdater(object):
kindle_pdoc = None kindle_pdoc = None
share_not_sync = False share_not_sync = False
if mi.author_sort and pas: if mi.author_sort and pas:
authors = mi.author_sort # We want an EXTH field per author...
update_exth_record((100, normalize(authors).encode(self.codec, 'replace'))) authors = mi.author_sort.split(' & ')
for author in authors:
update_exth_record((100, normalize(author).encode(self.codec, 'replace')))
elif mi.authors: elif mi.authors:
authors = ';'.join(mi.authors) authors = mi.authors
update_exth_record((100, normalize(authors).encode(self.codec, 'replace'))) for author in authors:
update_exth_record((100, normalize(author).encode(self.codec, 'replace')))
if mi.publisher: if mi.publisher:
update_exth_record((101, normalize(mi.publisher).encode(self.codec, 'replace'))) update_exth_record((101, normalize(mi.publisher).encode(self.codec, 'replace')))
if mi.comments: if mi.comments:
@ -360,6 +363,7 @@ class MetadataUpdater(object):
if mi.isbn: if mi.isbn:
update_exth_record((104, mi.isbn.encode(self.codec, 'replace'))) update_exth_record((104, mi.isbn.encode(self.codec, 'replace')))
if mi.tags: if mi.tags:
# FIXME: Keep a single subject per EXTH field?
subjects = '; '.join(mi.tags) subjects = '; '.join(mi.tags)
update_exth_record((105, normalize(subjects).encode(self.codec, 'replace'))) update_exth_record((105, normalize(subjects).encode(self.codec, 'replace')))

View File

@ -32,7 +32,7 @@ def get_metadata(stream):
if stream_type: if stream_type:
stream_type = stream_type[1:] stream_type = stream_type[1:]
if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub',
'rb', 'imp', 'pdf', 'lrf', 'azw'): 'rb', 'imp', 'pdf', 'lrf', 'azw', 'azw1', 'azw3'):
with TemporaryDirectory() as tdir: with TemporaryDirectory() as tdir:
with CurrentDir(tdir): with CurrentDir(tdir):
stream = extract_member(path, match=None, name=f, stream = extract_member(path, match=None, name=f,

View File

@ -23,7 +23,7 @@ def get_metadata(stream):
if stream_type: if stream_type:
stream_type = stream_type[1:] stream_type = stream_type[1:]
if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub', if stream_type in ('lit', 'opf', 'prc', 'mobi', 'fb2', 'epub',
'rb', 'imp', 'pdf', 'lrf', 'azw'): 'rb', 'imp', 'pdf', 'lrf', 'azw', 'azw1', 'azw3'):
with TemporaryDirectory() as tdir: with TemporaryDirectory() as tdir:
with CurrentDir(tdir): with CurrentDir(tdir):
path = zf.extract(f) path = zf.extract(f)

View File

@ -116,61 +116,83 @@ class Record(object): # {{{
# EXTH {{{ # EXTH {{{
class EXTHRecord(object): class EXTHRecord(object):
def __init__(self, type_, data): def __init__(self, type_, data, length):
self.type = type_ self.type = type_
self.data = data self.data = data
self.length = length
self.name = { self.name = {
1 : 'DRM Server id', 1 : 'Drm Server Id',
2 : 'DRM Commerce id', 2 : 'Drm Commerce Id',
3 : 'DRM ebookbase book id', 3 : 'Drm Ebookbase Book Id',
100 : 'author', 100 : 'Creator',
101 : 'publisher', 101 : 'Publisher',
102 : 'imprint', 102 : 'Imprint',
103 : 'description', 103 : 'Description',
104 : 'isbn', 104 : 'ISBN',
105 : 'subject', 105 : 'Subject',
106 : 'publishingdate', 106 : 'Published',
107 : 'review', 107 : 'Review',
108 : 'contributor', 108 : 'Contributor',
109 : 'rights', 109 : 'Rights',
110 : 'subjectcode', 110 : 'SubjectCode',
111 : 'type', 111 : 'Type',
112 : 'source', 112 : 'Source',
113 : 'asin', 113 : 'ASIN',
114 : 'versionnumber', 114 : 'versionNumber',
115 : 'sample', 115 : 'sample',
116 : 'startreading', 116 : 'StartOffset',
117 : 'adult', 117 : 'Adult',
118 : 'retailprice', 118 : 'Price',
119 : 'retailpricecurrency', 119 : 'Currency',
121 : 'KF8 header section index', 121 : 'KF8_Boundary_Section',
125 : 'KF8 resources (images/fonts) count', 122 : 'fixed-layout',
129 : 'KF8 cover URI', 123 : 'book-type',
131 : 'KF8 unknown count', 124 : 'orientation-lock',
201 : 'coveroffset', 125 : 'KF8_Count_of_Resources_Fonts_Images',
202 : 'thumboffset', 126 : 'original-resolution',
203 : 'hasfakecover', 127 : 'zero-gutter',
128 : 'zero-margin',
129 : 'KF8_Masthead/Cover_Image',
131 : 'KF8_Unidentified_Count',
132 : 'RegionMagnification',
200 : 'DictShortName',
201 : 'CoverOffset',
202 : 'ThumbOffset',
203 : 'Fake Cover',
204 : 'Creator Software', 204 : 'Creator Software',
205 : 'Creator Major Version', # '>I' 205 : 'Creator Major Version', # '>I'
206 : 'Creator Minor Version', # '>I' 206 : 'Creator Minor Version', # '>I'
207 : 'Creator Build Number', # '>I' 207 : 'Creator Build Number', # '>I'
208 : 'watermark', 208 : 'Watermark',
209 : 'tamper_proof_keys', 209 : 'Tamper Proof Keys [hex]',
300 : 'fontsignature', 300 : 'Font Signature [hex]',
301 : 'clippinglimit', # percentage '>B' 301 : 'Clipping Limit [3xx]', # percentage '>B'
402 : 'publisherlimit', 401 : 'Clipping Limit', # percentage '>B'
404 : 'TTS flag', # '>B' 1 - TTS disabled 0 - TTS enabled 402 : 'Publisher Limit',
501 : 'cdetype', # 4 chars (PDOC or EBOK) 404 : 'Text to Speech Disabled', # '>B' 1 - TTS disabled 0 - TTS enabled
502 : 'lastupdatetime', 501 : 'CDE Type', # 4 chars (PDOC, EBOK, MAGZ, ...)
503 : 'updatedtitle', 502 : 'last_update_time',
524 : 'language', 503 : 'Updated Title',
504 : 'ASIN [5xx]',
524 : 'Language',
525 : 'TextDirection',
528 : 'Unknown_Logical_Value',
535 : 'Kindlegen Build-Rev Number',
}.get(self.type, repr(self.type)) }.get(self.type, repr(self.type))
if (self.name in {'coveroffset', 'thumboffset', 'hasfakecover', if (self.name in {'sample', 'StartOffset', 'CoverOffset', 'ThumbOffset', 'Fake Cover',
'Creator Major Version', 'Creator Minor Version', 'Creator Software', 'Creator Major Version', 'Creator Minor Version',
'Creator Build Number', 'Creator Software', 'startreading'} or 'Creator Build Number', 'Clipping Limit (3xx)', 'Clipping Limit',
'Publisher Limit', 'Text to Speech Disabled'} or
self.type in {121, 125, 131}): self.type in {121, 125, 131}):
self.data, = struct.unpack(b'>I', self.data) if self.length == 9:
self.data, = struct.unpack(b'>B', self.data)
elif self.length == 10:
self.data, = struct.unpack(b'>H', self.data)
else:
self.data, = struct.unpack(b'>L', self.data)
elif self.type in {209, 300}:
self.data = bytes(self.data.encode('hex'))
def __str__(self): def __str__(self):
return '%s (%d): %r'%(self.name, self.type, self.data) return '%s (%d): %r'%(self.name, self.type, self.data)
@ -181,8 +203,8 @@ class EXTHHeader(object):
self.raw = raw self.raw = raw
if not self.raw.startswith(b'EXTH'): if not self.raw.startswith(b'EXTH'):
raise ValueError('EXTH header does not start with EXTH') raise ValueError('EXTH header does not start with EXTH')
self.length, = struct.unpack(b'>I', self.raw[4:8]) self.length, = struct.unpack(b'>L', self.raw[4:8])
self.count, = struct.unpack(b'>I', self.raw[8:12]) self.count, = struct.unpack(b'>L', self.raw[8:12])
pos = 12 pos = 12
self.records = [] self.records = []
@ -199,9 +221,9 @@ class EXTHHeader(object):
return getattr(ans, 'data', default) return getattr(ans, 'data', default)
def read_record(self, pos): def read_record(self, pos):
type_, length = struct.unpack(b'>II', self.raw[pos:pos+8]) type_, length = struct.unpack(b'>LL', self.raw[pos:pos+8])
data = self.raw[(pos+8):(pos+length)] data = self.raw[(pos+8):(pos+length)]
self.records.append(EXTHRecord(type_, data)) self.records.append(EXTHRecord(type_, data, length))
return pos + length return pos + length
@property @property

View File

@ -802,7 +802,7 @@ def inspect_mobi(mobi_file, ddir):
alltext += rec.raw alltext += rec.raw
of.seek(0) of.seek(0)
root = html.fromstring(alltext.decode('utf-8')) root = html.fromstring(alltext.decode(f.mobi_header.encoding))
with open(os.path.join(ddir, 'pretty.html'), 'wb') as of: with open(os.path.join(ddir, 'pretty.html'), 'wb') as of:
of.write(html.tostring(root, pretty_print=True, encoding='utf-8', of.write(html.tostring(root, pretty_print=True, encoding='utf-8',
include_meta_content_type=True)) include_meta_content_type=True))

View File

@ -88,7 +88,7 @@ class EXTHHeader(object): # {{{
self.mi.authors = [] self.mi.authors = []
au = content.decode(codec, 'ignore').strip() au = content.decode(codec, 'ignore').strip()
self.mi.authors.append(au) self.mi.authors.append(au)
if re.match(r'\S+?\s*,\s+\S+', au.strip()): if self.mi.is_null('author_sort') and re.match(r'\S+?\s*,\s+\S+', au.strip()):
self.mi.author_sort = au.strip() self.mi.author_sort = au.strip()
elif idx == 101: elif idx == 101:
self.mi.publisher = content.decode(codec, 'ignore').strip() self.mi.publisher = content.decode(codec, 'ignore').strip()

View File

@ -11,8 +11,9 @@ import re
from struct import pack from struct import pack
from io import BytesIO from io import BytesIO
from calibre.ebooks.mobi.utils import utf8_text from calibre.ebooks.mobi.utils import (utf8_text, to_base)
from calibre.utils.localization import lang_as_iso639_1 from calibre.utils.localization import lang_as_iso639_1
from calibre.ebooks.metadata import authors_to_sort_string
EXTH_CODES = { EXTH_CODES = {
'creator': 100, 'creator': 100,
@ -30,6 +31,7 @@ EXTH_CODES = {
'startreading': 116, 'startreading': 116,
'kf8_header_index': 121, 'kf8_header_index': 121,
'num_of_resources': 125, 'num_of_resources': 125,
'kf8_thumbnail_uri': 129,
'kf8_unknown_count': 131, 'kf8_unknown_count': 131,
'coveroffset': 201, 'coveroffset': 201,
'thumboffset': 202, 'thumboffset': 202,
@ -54,8 +56,8 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False,
items = metadata[term] items = metadata[term]
if term == 'creator': if term == 'creator':
if prefer_author_sort: if prefer_author_sort:
creators = [unicode(c.file_as or c) for c in creators = [authors_to_sort_string([unicode(c)]) for c in
items][:1] items]
else: else:
creators = [unicode(c) for c in items] creators = [unicode(c) for c in items]
items = creators items = creators
@ -159,7 +161,10 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False,
if thumbnail_offset is not None: if thumbnail_offset is not None:
exth.write(pack(b'>III', EXTH_CODES['thumboffset'], 12, exth.write(pack(b'>III', EXTH_CODES['thumboffset'], 12,
thumbnail_offset)) thumbnail_offset))
nrecs += 1 thumbnail_uri_str = bytes('kindle:embed:%s' %(to_base(thumbnail_offset, base=32, min_num_digits=4)))
exth.write(pack(b'>II', EXTH_CODES['kf8_thumbnail_uri'], len(thumbnail_uri_str) + 8))
exth.write(thumbnail_uri_str)
nrecs += 2
if start_offset is not None: if start_offset is not None:
try: try:

View File

@ -477,10 +477,13 @@ class FileIconProvider(QFileIconProvider):
'prc' : 'mobi', 'prc' : 'mobi',
'azw' : 'mobi', 'azw' : 'mobi',
'mobi' : 'mobi', 'mobi' : 'mobi',
'pobi' : 'mobi',
'mbp' : 'zero', 'mbp' : 'zero',
'azw1' : 'mobi', 'azw1' : 'tpz',
'azw2' : 'azw2',
'azw3' : 'azw3',
'azw4' : 'pdf', 'azw4' : 'pdf',
'tpz' : 'mobi', 'tpz' : 'tpz',
'tan' : 'zero', 'tan' : 'zero',
'epub' : 'epub', 'epub' : 'epub',
'fb2' : 'fb2', 'fb2' : 'fb2',

View File

@ -30,7 +30,7 @@ def get_filters():
(_('LRF Books'), ['lrf']), (_('LRF Books'), ['lrf']),
(_('HTML Books'), ['htm', 'html', 'xhtm', 'xhtml']), (_('HTML Books'), ['htm', 'html', 'xhtm', 'xhtml']),
(_('LIT Books'), ['lit']), (_('LIT Books'), ['lit']),
(_('MOBI Books'), ['mobi', 'prc', 'azw']), (_('MOBI Books'), ['mobi', 'prc', 'azw', 'azw3']),
(_('Topaz books'), ['tpz','azw1']), (_('Topaz books'), ['tpz','azw1']),
(_('Text books'), ['txt', 'text', 'rtf']), (_('Text books'), ['txt', 'text', 'rtf']),
(_('PDF Books'), ['pdf', 'azw4']), (_('PDF Books'), ['pdf', 'azw4']),

View File

@ -139,7 +139,7 @@ class ShareConnMenu(QMenu): # {{{
def setup_email(self, *args): def setup_email(self, *args):
self.config_email.emit() self.config_email.emit()
def set_state(self, device_connected): def set_state(self, device_connected, device):
self.connect_to_folder_action.setEnabled(not device_connected) self.connect_to_folder_action.setEnabled(not device_connected)
self.connect_to_itunes_action.setEnabled(not device_connected) self.connect_to_itunes_action.setEnabled(not device_connected)
self.connect_to_bambook_action.setEnabled(not device_connected) self.connect_to_bambook_action.setEnabled(not device_connected)
@ -187,8 +187,8 @@ class ConnectShareAction(InterfaceAction):
enabled = loc == 'library' enabled = loc == 'library'
self.qaction.setEnabled(enabled) self.qaction.setEnabled(enabled)
def set_state(self, device_connected): def set_state(self, device_connected, device):
self.share_conn_menu.set_state(device_connected) self.share_conn_menu.set_state(device_connected, device)
def build_email_entries(self): def build_email_entries(self):
m = self.gui.iactions['Send To Device'].qaction.menu() m = self.gui.iactions['Send To Device'].qaction.menu()

View File

@ -17,7 +17,7 @@ class PluginWidget(Widget, Ui_Form):
TITLE = _('AZW3 Output') TITLE = _('AZW3 Output')
HELP = _('Options specific to')+' AZW3 '+_('output') HELP = _('Options specific to')+' AZW3 '+_('output')
COMMIT_NAME = 'azw3_output' COMMIT_NAME = 'azw3_output'
ICON = I('mimetypes/mobi.png') ICON = I('mimetypes/azw3.png')
def __init__(self, parent, get_option, get_help, db=None, book_id=None): def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent, Widget.__init__(self, parent,

View File

@ -929,7 +929,8 @@ class DeviceMixin(object): # {{{
self._sync_menu.fetch_annotations.connect( self._sync_menu.fetch_annotations.connect(
self.iactions['Fetch Annotations'].fetch_annotations) self.iactions['Fetch Annotations'].fetch_annotations)
self._sync_menu.disconnect_mounted_device.connect(self.disconnect_mounted_device) self._sync_menu.disconnect_mounted_device.connect(self.disconnect_mounted_device)
self.iactions['Connect Share'].set_state(self.device_connected) self.iactions['Connect Share'].set_state(self.device_connected,
None)
if self.device_connected: if self.device_connected:
self._sync_menu.disconnect_mounted_device_action.setEnabled(True) self._sync_menu.disconnect_mounted_device_action.setEnabled(True)
else: else:
@ -968,7 +969,8 @@ class DeviceMixin(object): # {{{
# Device connected {{{ # Device connected {{{
def set_device_menu_items_state(self, connected): def set_device_menu_items_state(self, connected):
self.iactions['Connect Share'].set_state(connected) self.iactions['Connect Share'].set_state(connected,
self.device_manager.device)
if connected: if connected:
self._sync_menu.disconnect_mounted_device_action.setEnabled(True) self._sync_menu.disconnect_mounted_device_action.setEnabled(True)
self._sync_menu.enable_device_actions(True, self._sync_menu.enable_device_actions(True,

View File

@ -208,11 +208,12 @@ class Rule(QWidget):
self.l = l = QHBoxLayout() self.l = l = QHBoxLayout()
self.setLayout(l) self.setLayout(l)
self.l1 = l1 = QLabel(_('Send the ')) p, s = _('Send the %s format to the folder:').partition('%s')[0::2]
self.l1 = l1 = QLabel(p)
l.addWidget(l1) l.addWidget(l1)
self.fmt = f = QComboBox(self) self.fmt = f = QComboBox(self)
l.addWidget(f) l.addWidget(f)
self.l2 = l2 = QLabel(_(' format to the folder: ')) self.l2 = l2 = QLabel(s)
l.addWidget(l2) l.addWidget(l2)
self.folder = f = QLineEdit(self) self.folder = f = QLineEdit(self)
f.setPlaceholderText(_('Folder on the device')) f.setPlaceholderText(_('Folder on the device'))

View File

@ -1193,7 +1193,10 @@ class DeviceBooksModel(BooksModel): # {{{
ax = authors_to_string(self.db[x].authors) ax = authors_to_string(self.db[x].authors)
except: except:
ax = '' ax = ''
return ax try:
return sort_key(ax)
except:
return ax
keygen = { keygen = {
'title': ('title_sorter', lambda x: sort_key(x) if x else ''), 'title': ('title_sorter', lambda x: sort_key(x) if x else ''),

View File

@ -1,92 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division, absolute_import, print_function)
__license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en'
import urllib2
from contextlib import closing
from lxml import html
from PyQt4.Qt import QUrl
from calibre import browser
from calibre.gui2 import open_url
from calibre.gui2.store import StorePlugin
from calibre.gui2.store.basic_config import BasicStoreConfig
from calibre.gui2.store.search_result import SearchResult
from calibre.gui2.store.web_store_dialog import WebStoreDialog
class BeamEBooksDEStore(BasicStoreConfig, StorePlugin):
def open(self, parent=None, detail_item=None, external=False):
url = 'http://klick.affiliwelt.net/klick.php?bannerid=10072&pid=32307&prid=908'
url_details = ('http://klick.affiliwelt.net/klick.php?'
'bannerid=10730&pid=32307&prid=908&prodid={0}')
if external or self.config.get('open_external', False):
if detail_item:
url = url_details.format(detail_item)
open_url(QUrl(url))
else:
detail_url = None
if detail_item:
detail_url = url_details.format(detail_item)
d = WebStoreDialog(self.gui, url, parent, detail_url)
d.setWindowTitle(self.name)
d.set_tags(self.config.get('tags', ''))
d.exec_()
def search(self, query, max_results=10, timeout=60):
url = 'http://www.beam-ebooks.de/suchergebnis.php?Type=&sw=' + urllib2.quote(query)
br = browser()
counter = max_results
with closing(br.open(url, timeout=timeout)) as f:
doc = html.fromstring(f.read())
for data in doc.xpath('//table[tr/td/div[@class="stil2"]]'):
if counter <= 0:
break
id = ''.join(data.xpath('./tr/td[1]/a/@href')).strip()
if not id:
continue
id = id[7:]
cover_url = ''.join(data.xpath('./tr/td[1]/a/img/@src'))
if cover_url:
cover_url = 'http://www.beam-ebooks.de' + cover_url
temp = ''.join(data.xpath('./tr/td[1]/a/img/@alt'))
colon = temp.find(':')
if not temp.startswith('eBook') or colon < 0:
continue
author = temp[5:colon]
title = temp[colon+1:]
price = ''.join(data.xpath('./tr/td[3]/text()'))
pdf = data.xpath(
'boolean(./tr/td[3]/a/img[contains(@alt, "PDF")]/@alt)')
epub = data.xpath(
'boolean(./tr/td[3]/a/img[contains(@alt, "ePub")]/@alt)')
mobi = data.xpath(
'boolean(./tr/td[3]/a/img[contains(@alt, "Mobipocket")]/@alt)')
counter -= 1
s = SearchResult()
s.cover_url = cover_url
s.title = title.strip()
s.author = author.strip()
s.price = price
s.drm = SearchResult.DRM_UNLOCKED
s.detail_item = id
formats = []
if epub:
formats.append('ePub')
if pdf:
formats.append('PDF')
if mobi:
formats.append('MOBI')
s.formats = ', '.join(formats)
yield s

View File

@ -234,6 +234,9 @@ class QueueBulk(QProgressDialog):
def fetch_scheduled_recipe(arg): # {{{ def fetch_scheduled_recipe(arg): # {{{
fmt = prefs['output_format'].lower() fmt = prefs['output_format'].lower()
# Never use AZW3 for periodicals...
if fmt == 'azw3':
fmt = 'mobi'
pt = PersistentTemporaryFile(suffix='_recipe_out.%s'%fmt.lower()) pt = PersistentTemporaryFile(suffix='_recipe_out.%s'%fmt.lower())
pt.close() pt.close()
recs = [] recs = []

View File

@ -346,8 +346,6 @@ class EPUB_MOBI(CatalogPlugin):
recommendations.append(('remove_fake_margins', False, recommendations.append(('remove_fake_margins', False,
OptionRecommendation.HIGH)) OptionRecommendation.HIGH))
recommendations.append(('comments', '', OptionRecommendation.HIGH)) recommendations.append(('comments', '', OptionRecommendation.HIGH))
recommendations.append(('output_profile', opts.output_profile,
OptionRecommendation.HIGH))
""" """
>>> Use to debug generated catalog code before pipeline conversion <<< >>> Use to debug generated catalog code before pipeline conversion <<<
@ -363,10 +361,13 @@ class EPUB_MOBI(CatalogPlugin):
OptionRecommendation.HIGH)) OptionRecommendation.HIGH))
if opts.output_profile and opts.output_profile.startswith("kindle"): if opts.output_profile and opts.output_profile.startswith("kindle"):
recommendations.append(('no_inline_toc', True, recommendations.append(('output_profile', opts.output_profile,
OptionRecommendation.HIGH)) OptionRecommendation.HIGH))
recommendations.append(('book_producer',opts.output_profile, recommendations.append(('book_producer',opts.output_profile,
OptionRecommendation.HIGH)) OptionRecommendation.HIGH))
if opts.fmt == 'mobi':
recommendations.append(('no_inline_toc', True,
OptionRecommendation.HIGH))
# Use existing cover or generate new cover # Use existing cover or generate new cover
cpath = None cpath = None

View File

@ -33,6 +33,12 @@ class CatalogBuilder(object):
catalog = Catalog(notification=Reporter()) catalog = Catalog(notification=Reporter())
catalog.build_sources() catalog.build_sources()
Options managed in gui2.catalog.catalog_epub_mobi.py Options managed in gui2.catalog.catalog_epub_mobi.py
Turned off fetch_bookmarks as of 0.8.70
self.generate_recently_read = True if (_opts.generate_recently_added and
_opts.connected_kindle and
self.generate_for_kindle_mobi) else False
Does not work with AZW3, interferes with new prefix handling
''' '''
DEBUG = False DEBUG = False
@ -85,9 +91,9 @@ class CatalogBuilder(object):
@property @property
def SYMBOL_READING(self): def SYMBOL_READING(self):
if self.generate_for_kindle_mobi: if self.generate_for_kindle_mobi:
return self.format_prefix('&#x25b7;') return '&#x25b7;'
else: else:
return self.format_prefix('&nbsp;') return '&nbsp;'
def __init__(self, db, _opts, plugin, def __init__(self, db, _opts, plugin,
@ -103,6 +109,9 @@ class CatalogBuilder(object):
self.cache_dir = os.path.join(config_dir, 'caches', 'catalog') self.cache_dir = os.path.join(config_dir, 'caches', 'catalog')
self.catalog_path = PersistentTemporaryDirectory("_epub_mobi_catalog", prefix='') self.catalog_path = PersistentTemporaryDirectory("_epub_mobi_catalog", prefix='')
self.excluded_tags = self.get_excluded_tags() self.excluded_tags = self.get_excluded_tags()
self.generate_for_kindle_azw3 = True if (_opts.fmt == 'azw3' and
_opts.output_profile and
_opts.output_profile.startswith("kindle")) else False
self.generate_for_kindle_mobi = True if (_opts.fmt == 'mobi' and self.generate_for_kindle_mobi = True if (_opts.fmt == 'mobi' and
_opts.output_profile and _opts.output_profile and
_opts.output_profile.startswith("kindle")) else False _opts.output_profile.startswith("kindle")) else False
@ -120,9 +129,7 @@ class CatalogBuilder(object):
self.content_dir = os.path.join(self.catalog_path, "content") self.content_dir = os.path.join(self.catalog_path, "content")
self.current_step = 0.0 self.current_step = 0.0
self.error = [] self.error = []
self.generate_recently_read = True if (_opts.generate_recently_added and self.generate_recently_read = False
_opts.connected_kindle and
self.generate_for_kindle_mobi) else False
self.genres = [] self.genres = []
self.genre_tags_dict = None self.genre_tags_dict = None
self.html_filelist_1 = [] self.html_filelist_1 = []
@ -457,8 +464,9 @@ class CatalogBuilder(object):
catalog_resources = P("catalog") catalog_resources = P("catalog")
files_to_copy = [('','DefaultCover.jpg'), files_to_copy = [('','DefaultCover.jpg'),
('content','stylesheet.css'), ('content','stylesheet.css')]
('images','mastheadImage.gif')] if self.generate_for_kindle_mobi:
files_to_copy.extend([('images','mastheadImage.gif')])
for file in files_to_copy: for file in files_to_copy:
if file[0] == '': if file[0] == '':
@ -955,7 +963,7 @@ class CatalogBuilder(object):
""" """
from calibre.devices.usbms.device import Device from calibre.devices.usbms.device import Device
from calibre.devices.kindle.driver import Bookmark from calibre.devices.kindle.bookmark import Bookmark
from calibre.ebooks.metadata import MetaInformation from calibre.ebooks.metadata import MetaInformation
MBP_FORMATS = [u'azw', u'mobi', u'prc', u'txt'] MBP_FORMATS = [u'azw', u'mobi', u'prc', u'txt']
@ -981,7 +989,10 @@ class CatalogBuilder(object):
file_fmts.add(fmt) file_fmts.add(fmt)
bookmark_extension = None bookmark_extension = None
if file_fmts.intersection(mbp_formats): if file_fmts.intersection(han_formats):
book_extension = list(file_fmts.intersection(han_formats))[0]
bookmark_extension = 'han'
elif file_fmts.intersection(mbp_formats):
book_extension = list(file_fmts.intersection(mbp_formats))[0] book_extension = list(file_fmts.intersection(mbp_formats))[0]
bookmark_extension = 'mbp' bookmark_extension = 'mbp'
elif file_fmts.intersection(tan_formats): elif file_fmts.intersection(tan_formats):
@ -1008,6 +1019,7 @@ class CatalogBuilder(object):
path_map.pop(id) path_map.pop(id)
return path_map, book_ext return path_map, book_ext
self.bookmarked_books = {}
if self.generate_recently_read: if self.generate_recently_read:
self.opts.log.info(" Collecting Kindle bookmarks matching catalog entries") self.opts.log.info(" Collecting Kindle bookmarks matching catalog entries")
@ -1042,8 +1054,6 @@ class CatalogBuilder(object):
bookmarks[id] = ((myBookmark,book)) bookmarks[id] = ((myBookmark,book))
self.bookmarked_books = bookmarks self.bookmarked_books = bookmarks
else:
self.bookmarked_books = {}
def filter_db_tags(self): def filter_db_tags(self):
""" Remove excluded tags from data set, return normalized genre list. """ Remove excluded tags from data set, return normalized genre list.
@ -2778,7 +2788,8 @@ class CatalogBuilder(object):
ncx = soup.find('ncx') ncx = soup.find('ncx')
navMapTag = Tag(soup, 'navMap') navMapTag = Tag(soup, 'navMap')
navPointTag = Tag(soup, 'navPoint') navPointTag = Tag(soup, 'navPoint')
navPointTag['class'] = "periodical" if self.generate_for_kindle_mobi:
navPointTag['class'] = "periodical"
navPointTag['id'] = "title" navPointTag['id'] = "title"
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -2817,12 +2828,13 @@ class CatalogBuilder(object):
contentTag['src'] = "content/book_%d.html" % int(sort_descriptions_by[0]['id']) contentTag['src'] = "content/book_%d.html" % int(sort_descriptions_by[0]['id'])
navPointTag.insert(1, contentTag) navPointTag.insert(1, contentTag)
cmiTag = Tag(soup, '%s' % 'calibre:meta-img') if self.generate_for_kindle_mobi:
cmiTag['id'] = "mastheadImage" cmiTag = Tag(soup, '%s' % 'calibre:meta-img')
cmiTag['src'] = "images/mastheadImage.gif" cmiTag['id'] = "mastheadImage"
navPointTag.insert(2,cmiTag) cmiTag['src'] = "images/mastheadImage.gif"
navMapTag.insert(0,navPointTag) navPointTag.insert(2,cmiTag)
navMapTag.insert(0,navPointTag)
ncx.insert(0,navMapTag) ncx.insert(0,navMapTag)
self.ncx_soup = soup self.ncx_soup = soup
@ -2843,15 +2855,19 @@ class CatalogBuilder(object):
self.update_progress_full_step(_("NCX for Descriptions")) self.update_progress_full_step(_("NCX for Descriptions"))
# --- Construct the 'Books by Title' section --- sort_descriptions_by = self.books_by_author if self.opts.sort_descriptions_by_author \
else self.books_by_title
# --- Construct the 'Descriptions' section ---
ncx_soup = self.ncx_soup ncx_soup = self.ncx_soup
body = ncx_soup.find("navPoint") body = ncx_soup.find("navPoint")
btc = len(body.contents) btc = len(body.contents)
# Add the section navPoint # Add the section navPoint
navPointTag = Tag(ncx_soup, 'navPoint') navPointTag = Tag(ncx_soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['id'] = "bytitle-ID" navPointTag['class'] = "section"
navPointTag['id'] = "bydescription-ID"
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
navLabelTag = Tag(ncx_soup, 'navLabel') navLabelTag = Tag(ncx_soup, 'navLabel')
@ -2862,17 +2878,16 @@ class CatalogBuilder(object):
navPointTag.insert(nptc, navLabelTag) navPointTag.insert(nptc, navLabelTag)
nptc += 1 nptc += 1
contentTag = Tag(ncx_soup,"content") contentTag = Tag(ncx_soup,"content")
contentTag['src'] = "content/book_%d.html" % int(self.books_by_title[0]['id']) contentTag['src'] = "content/book_%d.html" % int(sort_descriptions_by[0]['id'])
navPointTag.insert(nptc, contentTag) navPointTag.insert(nptc, contentTag)
nptc += 1 nptc += 1
# Loop over the titles # Loop over the titles
sort_descriptions_by = self.books_by_author if self.opts.sort_descriptions_by_author \
else self.books_by_title
for book in sort_descriptions_by: for book in sort_descriptions_by:
navPointVolumeTag = Tag(ncx_soup, 'navPoint') navPointVolumeTag = Tag(ncx_soup, 'navPoint')
navPointVolumeTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointVolumeTag['class'] = "article"
navPointVolumeTag['id'] = "book%dID" % int(book['id']) navPointVolumeTag['id'] = "book%dID" % int(book['id'])
navPointVolumeTag['playOrder'] = self.play_order navPointVolumeTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -2976,7 +2991,8 @@ class CatalogBuilder(object):
# --- Construct the 'Books By Series' section --- # --- Construct the 'Books By Series' section ---
navPointTag = Tag(soup, 'navPoint') navPointTag = Tag(soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['class'] = "section"
navPointTag['id'] = "byseries-ID" navPointTag['id'] = "byseries-ID"
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3032,7 +3048,8 @@ class CatalogBuilder(object):
# Add *article* entries for each populated series title letter # Add *article* entries for each populated series title letter
for (i,books) in enumerate(series_by_letter): for (i,books) in enumerate(series_by_letter):
navPointByLetterTag = Tag(soup, 'navPoint') navPointByLetterTag = Tag(soup, 'navPoint')
navPointByLetterTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointByLetterTag['class'] = "article"
navPointByLetterTag['id'] = "%sSeries-ID" % (title_letters[i].upper()) navPointByLetterTag['id'] = "%sSeries-ID" % (title_letters[i].upper())
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3099,7 +3116,8 @@ class CatalogBuilder(object):
# --- Construct the 'Books By Title' section --- # --- Construct the 'Books By Title' section ---
navPointTag = Tag(soup, 'navPoint') navPointTag = Tag(soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['class'] = "section"
navPointTag['id'] = "byalphatitle-ID" navPointTag['id'] = "byalphatitle-ID"
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3157,7 +3175,8 @@ class CatalogBuilder(object):
# Add *article* entries for each populated title letter # Add *article* entries for each populated title letter
for (i,books) in enumerate(books_by_letter): for (i,books) in enumerate(books_by_letter):
navPointByLetterTag = Tag(soup, 'navPoint') navPointByLetterTag = Tag(soup, 'navPoint')
navPointByLetterTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointByLetterTag['class'] = "article"
navPointByLetterTag['id'] = "%sTitles-ID" % (title_letters[i].upper()) navPointByLetterTag['id'] = "%sTitles-ID" % (title_letters[i].upper())
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3222,7 +3241,8 @@ class CatalogBuilder(object):
# --- Construct the 'Books By Author' *section* --- # --- Construct the 'Books By Author' *section* ---
navPointTag = Tag(soup, 'navPoint') navPointTag = Tag(soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['class'] = "section"
file_ID = "%s" % tocTitle.lower() file_ID = "%s" % tocTitle.lower()
file_ID = file_ID.replace(" ","") file_ID = file_ID.replace(" ","")
navPointTag['id'] = "%s-ID" % file_ID navPointTag['id'] = "%s-ID" % file_ID
@ -3272,7 +3292,8 @@ class CatalogBuilder(object):
# master_author_list{}: [0]:author list [1]:Initial letter # master_author_list{}: [0]:author list [1]:Initial letter
for authors_by_letter in master_author_list: for authors_by_letter in master_author_list:
navPointByLetterTag = Tag(soup, 'navPoint') navPointByLetterTag = Tag(soup, 'navPoint')
navPointByLetterTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointByLetterTag['class'] = "article"
navPointByLetterTag['id'] = "%sauthors-ID" % (authors_by_letter[1]) navPointByLetterTag['id'] = "%sauthors-ID" % (authors_by_letter[1])
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3343,7 +3364,8 @@ class CatalogBuilder(object):
# --- Construct the 'Recently Added' *section* --- # --- Construct the 'Recently Added' *section* ---
navPointTag = Tag(soup, 'navPoint') navPointTag = Tag(soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['class'] = "section"
file_ID = "%s" % tocTitle.lower() file_ID = "%s" % tocTitle.lower()
file_ID = file_ID.replace(" ","") file_ID = file_ID.replace(" ","")
navPointTag['id'] = "%s-ID" % file_ID navPointTag['id'] = "%s-ID" % file_ID
@ -3387,7 +3409,8 @@ class CatalogBuilder(object):
# master_date_range_list{}: [0]:titles list [1]:datestr # master_date_range_list{}: [0]:titles list [1]:datestr
for books_by_date_range in master_date_range_list: for books_by_date_range in master_date_range_list:
navPointByDateRangeTag = Tag(soup, 'navPoint') navPointByDateRangeTag = Tag(soup, 'navPoint')
navPointByDateRangeTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointByDateRangeTag['class'] = "article"
navPointByDateRangeTag['id'] = "%s-ID" % books_by_date_range[1].replace(' ','') navPointByDateRangeTag['id'] = "%s-ID" % books_by_date_range[1].replace(' ','')
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3446,7 +3469,8 @@ class CatalogBuilder(object):
for books_by_month in master_month_list: for books_by_month in master_month_list:
datestr = strftime(u'%B %Y', books_by_month[1].timetuple()) datestr = strftime(u'%B %Y', books_by_month[1].timetuple())
navPointByMonthTag = Tag(soup, 'navPoint') navPointByMonthTag = Tag(soup, 'navPoint')
navPointByMonthTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointByMonthTag['class'] = "article"
navPointByMonthTag['id'] = "bda_%s-%s-ID" % (books_by_month[1].year,books_by_month[1].month ) navPointByMonthTag['id'] = "bda_%s-%s-ID" % (books_by_month[1].year,books_by_month[1].month )
navPointTag['playOrder'] = self.play_order navPointTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3521,7 +3545,8 @@ class CatalogBuilder(object):
# --- Construct the 'Recently Read' *section* --- # --- Construct the 'Recently Read' *section* ---
navPointTag = Tag(soup, 'navPoint') navPointTag = Tag(soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['class'] = "section"
file_ID = "%s" % tocTitle.lower() file_ID = "%s" % tocTitle.lower()
file_ID = file_ID.replace(" ","") file_ID = file_ID.replace(" ","")
navPointTag['id'] = "%s-ID" % file_ID navPointTag['id'] = "%s-ID" % file_ID
@ -3591,7 +3616,8 @@ class CatalogBuilder(object):
for books_by_day in master_day_list: for books_by_day in master_day_list:
datestr = strftime(u'%A, %B %d', books_by_day[1].timetuple()) datestr = strftime(u'%A, %B %d', books_by_day[1].timetuple())
navPointByDayTag = Tag(soup, 'navPoint') navPointByDayTag = Tag(soup, 'navPoint')
navPointByDayTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointByDayTag['class'] = "article"
navPointByDayTag['id'] = "bdr_%s-%s-%sID" % (books_by_day[1].year, navPointByDayTag['id'] = "bdr_%s-%s-%sID" % (books_by_day[1].year,
books_by_day[1].month, books_by_day[1].month,
books_by_day[1].day ) books_by_day[1].day )
@ -3659,7 +3685,8 @@ class CatalogBuilder(object):
# --- Construct the 'Books By Genre' *section* --- # --- Construct the 'Books By Genre' *section* ---
navPointTag = Tag(ncx_soup, 'navPoint') navPointTag = Tag(ncx_soup, 'navPoint')
navPointTag['class'] = "section" if self.generate_for_kindle_mobi:
navPointTag['class'] = "section"
file_ID = "%s" % tocTitle.lower() file_ID = "%s" % tocTitle.lower()
file_ID = file_ID.replace(" ","") file_ID = file_ID.replace(" ","")
navPointTag['id'] = "%s-ID" % file_ID navPointTag['id'] = "%s-ID" % file_ID
@ -3681,7 +3708,8 @@ class CatalogBuilder(object):
for genre in self.genres: for genre in self.genres:
# Add an article for each genre # Add an article for each genre
navPointVolumeTag = Tag(ncx_soup, 'navPoint') navPointVolumeTag = Tag(ncx_soup, 'navPoint')
navPointVolumeTag['class'] = "article" if self.generate_for_kindle_mobi:
navPointVolumeTag['class'] = "article"
navPointVolumeTag['id'] = "genre-%s-ID" % genre['tag'] navPointVolumeTag['id'] = "genre-%s-ID" % genre['tag']
navPointVolumeTag['playOrder'] = self.play_order navPointVolumeTag['playOrder'] = self.play_order
self.play_order += 1 self.play_order += 1
@ -3820,12 +3848,13 @@ class CatalogBuilder(object):
manifest.insert(mtc, itemTag) manifest.insert(mtc, itemTag)
mtc += 1 mtc += 1
itemTag = Tag(soup, "item") if self.generate_for_kindle_mobi:
itemTag['id'] = 'mastheadimage-image' itemTag = Tag(soup, "item")
itemTag['href'] = "images/mastheadImage.gif" itemTag['id'] = 'mastheadimage-image'
itemTag['media-type'] = 'image/gif' itemTag['href'] = "images/mastheadImage.gif"
manifest.insert(mtc, itemTag) itemTag['media-type'] = 'image/gif'
mtc += 1 manifest.insert(mtc, itemTag)
mtc += 1
# Write the thumbnail images, descriptions to the manifest # Write the thumbnail images, descriptions to the manifest
sort_descriptions_by = [] sort_descriptions_by = []
@ -3911,11 +3940,12 @@ class CatalogBuilder(object):
stc += 1 stc += 1
# Guide # Guide
referenceTag = Tag(soup, "reference") if self.generate_for_kindle_mobi:
referenceTag['type'] = 'masthead' referenceTag = Tag(soup, "reference")
referenceTag['title'] = 'mastheadimage-image' referenceTag['type'] = 'masthead'
referenceTag['href'] = 'images/mastheadImage.gif' referenceTag['title'] = 'mastheadimage-image'
guide.insert(0,referenceTag) referenceTag['href'] = 'images/mastheadImage.gif'
guide.insert(0,referenceTag)
# Write the OPF file # Write the OPF file
outfile = open("%s/%s.opf" % (self.catalog_path, self.opts.basename), 'w') outfile = open("%s/%s.opf" % (self.catalog_path, self.opts.basename), 'w')

View File

@ -363,6 +363,18 @@ class PostInstall:
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True) cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True)
self.icon_resources.append(('mimetypes', 'application-lrs', self.icon_resources.append(('mimetypes', 'application-lrs',
'128')) '128'))
render_img('mimetypes/mobi.png', 'calibre-mobi.png')
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-mobi.png application-x-mobipocket-ebook', shell=True)
self.icon_resources.append(('mimetypes', 'application-x-mobipocket-ebook', '128'))
render_img('mimetypes/tpz.png', 'calibre-tpz.png')
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-tpz.png application-x-topaz-ebook', shell=True)
self.icon_resources.append(('mimetypes', 'application-x-topaz-ebook', '128'))
render_img('mimetypes/azw2.png', 'calibre-azw2.png')
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-azw2.png application-x-kindle-application', shell=True)
self.icon_resources.append(('mimetypes', 'application-x-kindle-application', '128'))
render_img('mimetypes/azw3.png', 'calibre-azw3.png')
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-azw3.png application-x-mobi8-ebook', shell=True)
self.icon_resources.append(('mimetypes', 'application-x-mobi8-ebook', '128'))
render_img('lt.png', 'calibre-gui.png', width=256, height=256) render_img('lt.png', 'calibre-gui.png', width=256, height=256)
cc('xdg-icon-resource install --noupdate --size 256 calibre-gui.png calibre-gui', shell=True) cc('xdg-icon-resource install --noupdate --size 256 calibre-gui.png calibre-gui', shell=True)
self.icon_resources.append(('apps', 'calibre-gui', '128')) self.icon_resources.append(('apps', 'calibre-gui', '128'))
@ -397,11 +409,11 @@ class PostInstall:
cc(' '.join(cmd), shell=True) cc(' '.join(cmd), shell=True)
self.menu_resources.append(x) self.menu_resources.append(x)
cc(['xdg-desktop-menu', 'forceupdate']) cc(['xdg-desktop-menu', 'forceupdate'])
f = open('calibre-mimetypes', 'wb') f = open('calibre-mimetypes.xml', 'wb')
f.write(MIME) f.write(MIME)
f.close() f.close()
self.mime_resources.append('calibre-mimetypes') self.mime_resources.append('calibre-mimetypes.xml')
cc('xdg-mime install ./calibre-mimetypes', shell=True) cc('xdg-mime install ./calibre-mimetypes.xml', shell=True)
except Exception: except Exception:
if self.opts.fatal_errors: if self.opts.fatal_errors:
raise raise
@ -563,6 +575,33 @@ MIME = '''\
<comment>SONY E-book source format</comment> <comment>SONY E-book source format</comment>
<glob pattern="*.lrs"/> <glob pattern="*.lrs"/>
</mime-type> </mime-type>
<mime-type type="application/x-mobipocket-ebook">
<comment>Amazon Mobipocket e-book format</comment>
<sub-class-of type="application/x-palm-database"/>
<glob pattern="*.azw"/>
</mime-type>
<mime-type type="application/x-topaz-ebook">
<comment>Amazon Topaz ebook format</comment>
<glob pattern="*.tpz"/>
<glob pattern="*.azw1"/>
</mime-type>
<mime-type type="application/x-kindle-application">
<comment>Amazon Kindle Application (Kindlet)</comment>
<sub-class-of type="application/x-java-archive"/>
<glob pattern="*.azw2"/>
</mime-type>
<mime-type type="application/x-mobipocket-subscription">
<comment>Amazon Mobipocket ebook newspaper format</comment>
<sub-class-of type="application/x-mobipocket-ebook"/>
<!-- Technically, this depends on the cdeType (NWPR or MAGZ), but since EXTH headers have a variable length, it's tricky to probe via magic... -->
<alias type="application/x-mobipocket-subscription-magazine"/>
<glob pattern="*.pobi"/>
</mime-type>
<mime-type type="application/x-mobi8-ebook">
<comment>Amazon KF8 ebook format</comment>
<sub-class-of type="application/x-palm-database"/>
<glob pattern="*.azw3"/>
</mime-type>
</mime-info> </mime-info>
''' '''

File diff suppressed because it is too large Load Diff

View File

@ -95,6 +95,25 @@ struct tagDrives
WCHAR volume[BUFSIZE]; WCHAR volume[BUFSIZE];
}; };
static void console_out(LPCWSTR fmt, LPCWSTR arg) {
char *bfmt, *barg;
int sz;
sz = WideCharToMultiByte(CP_UTF8, 0, fmt, -1, NULL, 0, NULL, NULL);
bfmt = (char*)calloc(sz+1, sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, fmt, -1, bfmt, sz, NULL, NULL);
sz = WideCharToMultiByte(CP_UTF8, 0, arg, -1, NULL, 0, NULL, NULL);
barg = (char*)calloc(sz+1, sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, arg, -1, barg, sz, NULL, NULL);
if (bfmt != NULL && barg != NULL) {
printf(bfmt, barg);
fflush(stdout);
free(bfmt); free(barg);
}
}
static PyObject * static PyObject *
winutil_folder_path(PyObject *self, PyObject *args) { winutil_folder_path(PyObject *self, PyObject *args) {
int res; DWORD dwFlags; int res; DWORD dwFlags;
@ -276,8 +295,10 @@ get_all_removable_disks(struct tagDrives *g_drives)
for(nLoopIndex = 0; nLoopIndex < MAX_DRIVES; nLoopIndex++) for(nLoopIndex = 0; nLoopIndex < MAX_DRIVES; nLoopIndex++)
{ {
// if a drive is present, // if a drive is present (we ignore the A and B drives as they are
if(dwDriveMask & 1) // always present (even if no actual floppy is present) and we dont
// care about floppies)
if(nLoopIndex > 1 && dwDriveMask & 1)
{ {
caDrive[0] = 'A' + nLoopIndex; caDrive[0] = 'A' + nLoopIndex;
@ -579,7 +600,7 @@ get_device_ancestors(HDEVINFO hDevInfo, DWORD index, PyObject *candidates, BOOL
// Get the device instance of parent. // Get the device instance of parent.
if (CM_Get_Parent(&parent, pos, 0) != CR_SUCCESS) break; if (CM_Get_Parent(&parent, pos, 0) != CR_SUCCESS) break;
if (CM_Get_Device_ID(parent, temp, BUFSIZE, 0) == CR_SUCCESS) { if (CM_Get_Device_ID(parent, temp, BUFSIZE, 0) == CR_SUCCESS) {
if (ddebug) wprintf(L"device id: %s\n", temp); fflush(stdout); if (ddebug) console_out(L"device id: %s\n", temp);
devid = PyUnicode_FromWideChar(temp, wcslen(temp)); devid = PyUnicode_FromWideChar(temp, wcslen(temp));
if (devid) { if (devid) {
PyList_Append(candidates, devid); PyList_Append(candidates, devid);
@ -635,14 +656,14 @@ winutil_get_removable_drives(PyObject *self, PyObject *args) {
interfaceDetailData->DevicePath[length] = L'\\'; interfaceDetailData->DevicePath[length] = L'\\';
interfaceDetailData->DevicePath[length+1] = 0; interfaceDetailData->DevicePath[length+1] = 0;
if (ddebug) wprintf(L"Device path: %s\n", interfaceDetailData->DevicePath); fflush(stdout); if (ddebug) console_out(L"Device path: %s\n", interfaceDetailData->DevicePath);
// On Vista+ DevicePath contains the information we need. // On Vista+ DevicePath contains the information we need.
temp = PyUnicode_FromWideChar(interfaceDetailData->DevicePath, length); temp = PyUnicode_FromWideChar(interfaceDetailData->DevicePath, length);
if (temp == NULL) return PyErr_NoMemory(); if (temp == NULL) return PyErr_NoMemory();
PyList_Append(candidates, temp); PyList_Append(candidates, temp);
Py_DECREF(temp); Py_DECREF(temp);
if(GetVolumeNameForVolumeMountPointW(interfaceDetailData->DevicePath, volume, BUFSIZE)) { if(GetVolumeNameForVolumeMountPointW(interfaceDetailData->DevicePath, volume, BUFSIZE)) {
if (ddebug) wprintf(L"Volume: %s\n", volume); fflush(stdout); if (ddebug) console_out(L"Volume: %s\n", volume);
for(j = 0; j < MAX_DRIVES; j++) { for(j = 0; j < MAX_DRIVES; j++) {
if(g_drives[j].letter != 0 && wcscmp(g_drives[j].volume, volume)==0) { if(g_drives[j].letter != 0 && wcscmp(g_drives[j].volume, volume)==0) {

View File

@ -453,11 +453,11 @@ class BasicNewsRecipe(Recipe):
Override in a subclass to customize extraction of the :term:`URL` that points Override in a subclass to customize extraction of the :term:`URL` that points
to the content for each article. Return the to the content for each article. Return the
article URL. It is called with `article`, an object representing a parsed article article URL. It is called with `article`, an object representing a parsed article
from a feed. See `feedparser <http://www.feedparser.org/docs/>`_. from a feed. See `feedparser <http://packages.python.org/feedparser/>`_.
By default it looks for the original link (for feeds syndicated via a By default it looks for the original link (for feeds syndicated via a
service like feedburner or pheedo) and if found, service like feedburner or pheedo) and if found,
returns that or else returns returns that or else returns
`article.link <http://www.feedparser.org/docs/reference-entry-link.html>`_. `article.link <http://packages.python.org/feedparser/reference-entry-link.html>`_.
''' '''
for key in article.keys(): for key in article.keys():
if key.endswith('_origlink'): if key.endswith('_origlink'):