いまさらながらオライリーのepubが600円均一祭りな件に気づいたのでメモ

iPhoneのO'ReillyアプリはDRMフリーでepubが格納されていて、簡単に抽出できる…らしい。


404 Blog Not Found:perl - O'ReillyのiPhoneアプリ本からepubをぶっこぬく
http://blog.livedoor.jp/dankogai/archives/51484907.html

とりあえずいくつか買ってみてテスト

  • The Ruby Programming Language
  • Best of TOC
  • Natural Language Processing with Python
  • Beautiful Testing
  • Hadoop: The Definitive Guide

こんな感じに

1000000354

うまく見れるようだ

1000000355

見出しもOK

1000000356


perlの抽出スクリプトは存在していたけど、環境を汚すのがイヤだったのでPythonで適当に。

#!-*- coding:utf-8 -*-

import sys
import os
import re
import zipfile

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "Usage: # python oipa2epub.py filename"
        sys.exit(1)
    filename = sys.argv[1]
    if not filename.endswith(".ipa"):
        print "%s is not supported file!" % filename
        sys.exit(1)
    filename = os.path.splitext(filename)[0]
    z    = zipfile.ZipFile( filename + ".ipa", 'r' )
    newz = zipfile.ZipFile( filename + ".epub", 'w', zipfile.ZIP_DEFLATED )
    p = re.compile("^Payload/[^/]+/book/(.+)")
    for (item, info) in zip(z.namelist(), z.infolist()):
        if not p.search(item):
            continue
        info.filename = p.sub(r"\1", info.filename)
        newz.writestr(info, z.read(item))
    z.close()
    newz.close()

…さて、気がつけばiTunes残高が10円。買いすぎには注意しましょうー

以下、適当にアフィリンク集。だいたい600円。価格破壊すぎる。

Learning Python
jQuery Cookbook
Learning iPhone Programming
Building iPhone Apps with HTML, CSS, and JavaScript
Mac OS X Snow Leopard Pocket Guide
Learning Perl, Fifth Edition
The Ruby Programming Language
Programming Scala
Cocoa and Objective-C: Up and Running, 1e
Python Pocket Reference, Fourth Edition
Microsoft® Office Excel® 2007: Data Analysis and Business Modeling
iPhone 3D Programming
Learning PHP, MySQL, and JavaScript
Masterminds of Programming
Real World Haskell
HTML5: Up and Running
Hadoop: The Definitive Guide
iPhone Game Development
Beautiful Code
Programming Google App Engine
O'Reilly JavaScript Library
HTML and XHTML Pocket Reference
JavaScript: The Good Parts
JavaScript Pocket Reference, Second Edition
Effective UI
C++ In a Nutshell
sendmail, Fourth Edition
Using SQLite
Python Cookbook
Regular Expression Pocket Reference
Introducing Microsoft® Silverlight™ 3, Third Edition
Mathematica Cookbook
Beautiful Testing
Learning PHP 5
Linux Pocket Guide
Cisco IOS Cookbook, Second Edition
RESTful Java with JAX-RS
Linux Networking Cookbook
Essential System Administration, Third Edition
Programming Python, Third Edition
Mind Performance Hacks
Apprenticeship Patterns
iPhone: The Missing Manual Lite
Ruby Best Practices
sed and awk Pocket Reference
JavaScript Cookbook
vi Editor Pocket Reference
Unix Power Tools, Third Edition
SQL Pocket Guide
Learning Java, Third Edition

(これでほんの一部…)