Author Topic: Making a Mr. Money Mustache Ebook  (Read 10610 times)

beege

  • 5 O'Clock Shadow
  • *
  • Posts: 66
  • Age: 37
  • Location: USA
  • Fired during covid
Making a Mr. Money Mustache Ebook
« on: October 28, 2013, 07:33:45 AM »
EDIT (Oct 2, 2014): Let's just cut to the good stuff. Links to the downloads. If you want the story then have at it below.

Newest release (untested):
Oct 2, 2014 (mobi) https://github.com/beege/MMM-Ebook/raw/master/Ebooks/MMM%20Blog%20-%20MMM.mobi
Oct 2, 2014 (azw3) https://github.com/beege/MMM-Ebook/raw/master/Ebooks/MMM%20Blog%20-%20MMM.azw3
Oct 2, 2014 (HTML zip) https://github.com/beege/MMM-Ebook/raw/master/Ebooks/MMM%20Blog%20-%20MMM.zip

Battle-tested stable version:
Oct 2013 version (mobi) https://github.com/beege/MMM-Ebook/raw/9e3853a3ce5242aa15e5fd73c9650c40570a9dd6/Ebooks/MMM%20Blog%20-%20MMM.mobi
Oct 2013 version (HTML zip) https://github.com/beege/MMM-Ebook/raw/9e3853a3ce5242aa15e5fd73c9650c40570a9dd6/Ebooks/MMM%20Blog%20-%20MMM.zip

EDIT: After receiving Mr. Money Mustache's endorsement I have uploaded the ebook in zip and MOBI formats (attached to this post). I can upload in other formats if desired or people can download the zip format and use Calibre to convert it themselves. I will try to find the time to update the script and fix some of the issues I outlined and add MMM's latests post(s) sometime in the future.

I recently traveled with my Girlfriend to visit friends some 7 hours away via car and wanted to take Mr. Mustache along for the ride for reading. Neither my girlfriend or myself have unlimited mobile data and the cell tower connections can be spotty along the route so reading the blog via an Internet connection was ill-advised. I already owned a kindle from my pre-Mustachian days so I had the idea of converting Mr. Money Mustache into an ebook for the trip. Details are at the end of this post.

Long story short, it worked pretty well and the Kindle's text to speech even worked for reading to the driver, giving Mr. Mustache a strangely dry delivery. Though posts could be a bit repetative at times and any posts involving a bit of mathematics was poorly dictated by the Kindle it was a positive experience. I would recommend to other Mustachians if they encounter a similar situation.

As I am not the copyright holder on Mr. Money Mustache I hesitate distributing the ebook I created without Mr. Money Mustache's explicit permission but I believe I can at least distribute the code and methods to create the book. Listening to the book with my Girlfriend on the road trip definitely helped us both grow our mustaches a bit more.

Now let's talk about how I made the book. Note: This was hacked together right before a road trip. Definite improvements could be made. I did search around the forums here to see if anyone else had already done this but did not find anything.

The tools I used were python 2.x with lxml installed to download and parse the RSS feed and then Calibre to convert the resulting HTML to an ebook. I did not get around to automating the Calibre calls. I'll leave that as an exercise for the reader.

I have no prior experience with RSS feeds so I could be missing things. I found some URL documentation for WordPress and used it to get the RSS feed for MMM from the beginning of time in ascending order (24 pages of feed you see in the code below). This can easily be changed to reverse the order, only retrieve the most recent posts, etc.

Known Issues/Bugs:
  • TOC could be improved
  • Need to capture date and add to the top of each post. This will make it easier to understand the transition to a new post while kindle reads to you.
  • Pictures show up for the ebook on my computer but not on the kindle. Not sure if it is because I did not download them and update the links. I pasted some code at the bottom (commented out) to download them but is based on BeautifulSoup and needs to be rewritten.
  • Link rewriting algorithm runs in N-squared time. Wonder if this could be improved.
  • I lamely added a "p" prefix on the created html files as the regex did not work if they started with a number. This is an unexpected bug and I did not dig into the regex any more to investigate.

Usage:
  • Create a new directory and place the script below there
  • Run the script
  • Open calibre and import the "index.html" file as an ebook
  • Run the calibre conversion process to give you the desired output format (MOBI for kindle)


This code is old and lame. Newest hotness is here: https://github.com/beege/MMM-Ebook/tree/9e3853a3ce5242aa15e5fd73c9650c40570a9dd6
Code: [Select]
#!/usr/bin/env python2
import os
import re
import sys
from lxml import etree as ET
import urllib

class RSSParser():
    def __init__(self,url):
        self.url = url

    def parse(self):
        print "Opening and parsing RSS feed @ <" + self.url + ">..."
        root = ET.parse(urllib.urlopen(self.url)).getroot().find('channel')
       
        for item in root.findall('item'):
            title = item.find('title').text
            url = item.find('link').text           
            text = item.find('.//content:encoded', namespaces=root.nsmap).text
           
            yield (title.encode('utf-8'), text.encode('utf-8'), url.encode('utf-8'))
           
class Post():
    next = 0

    def __init__(self, title, text, url):
        self.title = title
        self.text = text
        self.localUrl = 'p%03d.html' % (Post.next, )
        Post.next = Post.next + 1

MIN=1
MAX=24 #inclusive

if __name__=="__main__":
    postsInOrder = []
    posts = {}   
   
    for i in range(MIN, MAX+1):
        url = "http://www.mrmoneymustache.com/feed/?order=ASC&paged=%d" % (i)
        #url = 'www.mrmoneymustache.com.htm'
        if len(sys.argv) > 1:
            url = sys.argv[1]
        parser = RSSParser(url)
       
        for (title, text, url) in parser.parse():
            postsInOrder.append(url)
            posts[url] = Post(title, text, url)
           
   
    # Rewrite links - we do this once we have all the posts just incase MMM went and editied an earlier post to include a link to a later one   
    for url in postsInOrder:
        post = posts[url]

        for url2 in postsInOrder:
            regex = re.compile('<a\\s(.*href=")%s(".*)>(.*)</a>' % url2)
            post.text = regex.sub('<a \\1' + posts[url2].localUrl + '\\2>\\3</a>', post.text)
           
    index = open('index.html', 'wb')
   
    index.write('''<html>
   <body>
     <h1>Table of Contents</h1>
     <p style="text-indent:0pt">''')       
    for url in postsInOrder:
        post = posts[url]
       
        open(post.localUrl, 'wb').write('<title>' + post.title + "</title>\n" + '<h1>' + post.title + "</h1>\n" + post.text)
        index.write('<a href=%s>%s</a><br/>\n' % (post.localUrl, post.title))
       
    index.write('''     </p>
   </body>
</html>''')
     
#for image in soup.findAll("img"):
#    print "Image: %(src)s" % image
#    image_url = urlparse.urljoin(url, image['src'])
#    filename = image["src"].split("/")[-1]
#    outpath = os.path.join(out_folder, filename)
#    urlretrieve(image_url, outpath)
« Last Edit: October 02, 2014, 09:17:18 PM by MrMarylandMustache »

CopperTex

  • Stubble
  • **
  • Posts: 157
  • Age: 45
  • Location: Mandeville, LA
Re: Making a Mr. Money Mustache Ebook
« Reply #1 on: October 28, 2013, 08:40:24 AM »
I was on a trip earlier this year and had wished to have the posts accessible without internet in a kindle type format.  Would be nice to have something like this available.

dragoncar

  • Walrus Stache
  • *******
  • Posts: 9930
  • Registered member
Re: Making a Mr. Money Mustache Ebook
« Reply #2 on: October 28, 2013, 03:23:22 PM »
Cool, I'd be surprised if MMM wasn't willing to distribute something like this for a reasonable price given enough interest... The only thing standing in the way could be a sense of perfectionism (some blog Ebooks are just terribly converted) and preference write a "real" book.

Edit: I see tis relies on RSS.  Is it much different from http://newstoebook.com/?  I always thought RSS provided only limited history (eg latest 10 posts).
« Last Edit: October 28, 2013, 03:25:36 PM by dragoncar »

beege

  • 5 O'Clock Shadow
  • *
  • Posts: 66
  • Age: 37
  • Location: USA
  • Fired during covid
Re: Making a Mr. Money Mustache Ebook
« Reply #3 on: October 28, 2013, 07:36:34 PM »
The script most likely works the same way as newstoebook.com but uses URL arguments to affect the RSS feed in order to access all the post history.

The conversion doesn't look bad at all. The fact that the "meat" of the articles is full exposed via RSS (with the formatting in code) makes the conversion pretty trivial. Just read the XML and parse it (no web scraping required). As I mentioned the only odd formatting was that pictures didn't show up on the kindle for some reason (should be an easy fix), the need to create a table of contents, and headings for the individual articles themselves. All of those are fairly easy to address.

If MMM himself wanted to make an ebook, I know there are several Word Press plugins which do probably a better job than this hacky script. I can contact him to see if he's interested in distributing that way but he certainly won't be getting ad revenue. I think he even mentioned it in one of his posts one time but thought (rightly so) that it might be a bit of disorganized and somewhat repetitive book.

MMM

  • Administrator
  • Stubble
  • *****
  • Posts: 183
    • Mr. Money Mustache
Re: Making a Mr. Money Mustache Ebook
« Reply #4 on: October 28, 2013, 07:44:17 PM »
Awesome work!! You hereby have my full approval to share this book (and work together to improve it if you like). As long as you give it away for free!

I'll finish the real, much better book eventually. Currently distracted by other fun stuff including building the new house.

Thanks as always for sharing your cool and innovative ideas.

senecando

  • Bristles
  • ***
  • Posts: 480
  • Age: 34
  • Location: Madison, Wi
Re: Making a Mr. Money Mustache Ebook
« Reply #5 on: October 28, 2013, 08:12:08 PM »
If you'd like any help with the python, let me know. I've been working a bit in python recently, loving it, and would love to help out.

MilStachian

  • 5 O'Clock Shadow
  • *
  • Posts: 94
  • Location: New England
Re: Making a Mr. Money Mustache Ebook
« Reply #6 on: October 28, 2013, 09:54:24 PM »
MrMarylandMustache,
Awesome, thanks!  About to kick off a 37 hour road trip across the States, this will be great!

Zora

  • 5 O'Clock Shadow
  • *
  • Posts: 35
Re: Making a Mr. Money Mustache Ebook
« Reply #7 on: October 29, 2013, 03:57:15 PM »
This is awesome!  I was considering attempting to indoctrinate my husband while we are on a road trip this weekend but I'm getting cold feet.  You are removing one of my excuses.  (I still have cold feet though.  He recently told me that a million dollars is not enough to retire on.)

arebelspy

  • Administrator
  • Senior Mustachian
  • *****
  • Posts: 28444
  • Age: -997
  • Location: Seattle, WA
Re: Making a Mr. Money Mustache Ebook
« Reply #8 on: October 30, 2013, 11:20:21 AM »
This is awesome!  I was considering attempting to indoctrinate my husband while we are on a road trip this weekend but I'm getting cold feet.  You are removing one of my excuses.  (I still have cold feet though.  He recently told me that a million dollars is not enough to retire on.)

The only way to change that attitude is education.
I am a former teacher who accumulated a bunch of real estate, retired at 29, spent some time traveling the world full time and am now settled with three kids.
If you want to know more about me, this Business Insider profile tells the story pretty well.
I (rarely) blog at AdventuringAlong.com. Check out the Now page to see what I'm up to currently.

Zora

  • 5 O'Clock Shadow
  • *
  • Posts: 35
Re: Making a Mr. Money Mustache Ebook
« Reply #9 on: October 30, 2013, 03:03:38 PM »
Well, I won't hijack the thread with a discussion of my own marital relationship, but suffice it to say that I can't really predict which way he'll come down, as there are various reasons to think he might go either way.  Don't get me wrong, we're thrifty as fuck, but I'm not sure he's given much though to WHY we're saving up all this money aside from having absorbed shitty conventional wisdom about how much money you "need" to have to retire or "send kids to college." 

I'll load up the e-book and see if I get the courage to pull it out on the road trip.

Ed Mills

  • Stubble
  • **
  • Posts: 117
  • Age: 60
  • Location: Merida, Mexico & Statenville, GA
  • Join the FI Revolution Y'all!
    • The Millionaire Educator
Re: Making a Mr. Money Mustache Ebook
« Reply #10 on: October 30, 2013, 04:28:14 PM »
High fives all around!  I downloaded the MOBI version for my Kindle reader; it's great.  Thanks for taking the time to do this.
Ed

MrsPete

  • Magnum Stache
  • ******
  • Posts: 3505
Re: Making a Mr. Money Mustache Ebook
« Reply #11 on: October 30, 2013, 07:18:55 PM »
He recently told me that a million dollars is not enough to retire on.)
Quote
Maybe it is, maybe it isn't.  "Enough" depends upon quite a few factors:

- Your age when you retire
- Cost of living in your area
- Availability of health insurance
- Whether you own your house
- Whether you intend to supplement with part-time work
- Whether you have a pension
- Whether you're still raising /educating children
- Whether you're likely to be providing financially for aging parents
- And perhaps most of all, your expectations for how you'll spend in your retirement years

You could probably add a few to the list. 

What's a comfortable figure for one couple may not be "enough" for another.  The real answer is, Do your own math.

RootofGood

  • Handlebar Stache
  • *****
  • Posts: 1361
  • Age: 43
  • Location: North Carolina
  • Retired at age 33. 5 years in, still loving it!
    • Root of Good
Re: Making a Mr. Money Mustache Ebook
« Reply #12 on: November 01, 2013, 05:10:23 PM »
Well, I won't hijack the thread with a discussion of my own marital relationship, but suffice it to say that I can't really predict which way he'll come down, as there are various reasons to think he might go either way.  Don't get me wrong, we're thrifty as fuck, but I'm not sure he's given much though to WHY we're saving up all this money aside from having absorbed shitty conventional wisdom about how much money you "need" to have to retire or "send kids to college." 

I'll load up the e-book and see if I get the courage to pull it out on the road trip.

The best thing about your saving situation is that your frugal ways will lead to savings that lead to compounding over time if properly invested.  5-10 years down the road, you might have a huge portfolio and then you can figure out your magic number.

FYI, a million wasn't quite enough for us, but then again we have 3 young kids. 


myztic_man

  • 5 O'Clock Shadow
  • *
  • Posts: 1
Re: Making a Mr. Money Mustache Ebook
« Reply #13 on: October 02, 2014, 09:59:27 AM »
Just wanted to say thank you for taking the time to put this on here, just downloaded the .zip - works wonderfully.
Any chance of a more recently updated download? :)

Thegoblinchief

  • Guest
Re: Making a Mr. Money Mustache Ebook
« Reply #14 on: October 02, 2014, 01:39:17 PM »
Cool. I've thought about trying to do it before, but I don't know any coding to make it automated.

Does it include any of the comments? Might be worth curating the comments of some of those posts, as well as the "continue the blog conversation" threads, but that's a heck of a lot more work.

beege

  • 5 O'Clock Shadow
  • *
  • Posts: 66
  • Age: 37
  • Location: USA
  • Fired during covid
Re: Making a Mr. Money Mustache Ebook
« Reply #15 on: October 02, 2014, 09:07:33 PM »
I worked on this some more back in January but the project was abandoned and forgotten about. I even made a github to host it and was trying to find some free server space to make it into an automated script that remade the book like weekly or something but I didn't find a free host. Anyways I just got an email that someone posted on this thread so I went ahead and dusted off the code I wrote, uploaded it to github like I was planning and also threw up the old ebook as on there well as the new one I made tonight so people won't have to be logged in to download. I didn't get a chance to test it on my kindle but it should have the latest posts in there up till today. I also added azw3 format since that seems to be all the rage these days. I'll update my original post with the links in a sec.

FYI: Though I rewrote the script and improved a few things it looks like I still didn't finish the image downloading, so if you read the book while not connected to the Internet then you'll get nothing.

arebelspy

  • Administrator
  • Senior Mustachian
  • *****
  • Posts: 28444
  • Age: -997
  • Location: Seattle, WA
Re: Making a Mr. Money Mustache Ebook
« Reply #16 on: October 02, 2014, 10:37:32 PM »


You're awesome beege.
I am a former teacher who accumulated a bunch of real estate, retired at 29, spent some time traveling the world full time and am now settled with three kids.
If you want to know more about me, this Business Insider profile tells the story pretty well.
I (rarely) blog at AdventuringAlong.com. Check out the Now page to see what I'm up to currently.