Saturday, 26 November 2011

Sunday, 20 November 2011

A Sudden Enthusiasm: London, 2011 A.D.

I was very impressed with this photo Outa_Spaceman took with his Dick Tracy watch cellphone:


I knew immediately where it belonged:


Wednesday, 2 November 2011

Converting Google Reader Starred Items to Firefox Bookmarks

[Starred Items has not been removed from Google Reader.

I think that I wasn't seeing stars after the changeover because I was using Firefox 3.5 as my browser. Google no longer support versions lower than 3.6. It's either that or I have UI fatigue. That's a real thing, isn't it?]

Google made many changes to Google Reader yesterday. It was unexpected and unwelcome to the many of the people who use Google Reader as their main portal into the Internet.

The big change was Google replacing Reader's Sharing feature with the Google+ one, that seems like an improvement. But they simplified Google Reader while they were at it, and one of the simplifications was to remove the Starred Items feature.

I had been using Starred Items as a bookmarks folder for feeds. I had 413 Starred Items.

Google have given us the option of downloading our Starred Items data. Look in the Import/Export tab of Reader's Manage Subscriptions page. (You will have to be logged into Google reader to follow that link.) The Reader JSON file contains full data of the posts that were in your Starred Items. But since there is no program that can convert the raw data in that file into a usable form, it is not the mercy it seems.

I wrote myself a Python script to convert my Reader JSON file into a file that could I import into my Firefox browser's bookmarks list.  So I now have all my bookmarks back: a Starred Items bookmark menu folder, with a subfolder for each blog, and the bookmarks themselves lead to the original posts in those blogs.

I've appended my script in the box below. If you know how to run a Python script, you will find it useful. If you know how to program in Python, I encourage you to convert it into a form that a non-programmer can use. If you desperately need your Starred Items, and they are not personal, I can convert them for you - leave a comment.

# firefoxize-starred-items.py
#
# Reads a Google "Reader JSON" file exported from Google Reader and
# outputs an HTML file suitable for importing into Firefox's 
# bookmarks menu. This rescues you if you have been using Google 
# Reader Starred Items as a bookmark file for feeds.
#
# See http://googlereader.blogspot.com/2011/10/new-in-reader-fresh-design-and-google.html
# and, when logged in, http://www.google.com/reader/settings?display=import

import json, time, codecs

InputFile = '/home/glyn/Desktop/starred-items.json'  #download this
OutputFile = '/home/glyn/Desktop/starred-items-bookmarks.html'  #import this

with codecs.open(InputFile, 'r', encoding='utf-8') as f:
    GooglesItems = json.load(f)['items']

FeedURLs = {}
FeedItems = {}

for item in GooglesItems:
    feedTitle = item['origin']['title']
    feedUrl = item['origin']['htmlUrl']
    itemDate =  item['published']
    if item.has_key('title'):
        itemTitle = item['title'].split('\n')[0]
    else:
        itemTitle = feedTitle + ', ' +  time.strftime('%x', time.localtime(itemDate))
    if item.has_key('alternate'):
        itemURL = item['alternate'][0]['href']
    elif item.has_key('enclosure'):
        itemURL = item['enclosure'][0]['href']
    else:
        itemURL = feedURL
    FeedURLs[feedTitle] = feedUrl
    feedItems = FeedItems.setdefault(feedTitle, [])
    feedItems.append((itemTitle, itemURL, itemDate))

with codecs.open(OutputFile, 'w', encoding='utf-8') as b:
    b.write('''<!DOCTYPE NETSCAPE-Bookmark-file-1>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <TITLE>Bookmarks</TITLE>
    <H1>Bookmarks Menu</H1>
    <DL><p>\n''')
    b.write('<DT><H2>Google Reader Starred Items</H2>\n\n')
    b.write('<DL><p>\n')
    for feedTitle, feedURL in FeedURLs.items():
        b.write('<DT><H3>%s</H3>\n' % feedTitle)
        b.write('<DL>\n')
        b.write('<DT><A HREF="%s">(%s)</A>\n' % (feedURL, feedTitle))
        for (title, url, date) in FeedItems[feedTitle]:
            b.write('<DT><A HREF="%s" LAST_MODIFIED="%i">%s</A>\n' % (url, date, title))
        b.write('</DL>\n\n')
    b.write('</DL>\n\n\n')
    b.write('</DL><p>\n')