This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#login info | |
user = '[email protected]' | |
password = '********' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set up service | |
blogger_service = service.GDataService(user, password) | |
blogger_service.source = 'gpowered' | |
blogger_service.service = 'blogger' | |
blogger_service.server = 'www.blogger.com' | |
blogger_service.ProgrammaticLogin() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def PrintUserBlogTitles(blogger_service): | |
query = service.Query() | |
query.feed = '/feeds/default/blogs' | |
feed = blogger_service.Get(query.ToUri()) | |
print feed.title.text | |
for entry in feed.entry: | |
print "\t" + entry.title.text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blog_id = 413573351281770670 | |
feed_url = '/feeds/%s/posts/default' % str(blog_id) | |
query = service.Query() | |
query.feed = feed_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get the total number of posts for this feed | |
def get_total(query): | |
#query for no posts | |
query.max_results = '0' | |
query.start_index = '1' | |
#get back entryless feed | |
feed = blogger_service.Get(query.ToUri()) | |
return int(feed.total_results.text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom"> | |
<ns1:totalresults xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">1</ns1:totalresults> | |
<ns1:itemsperpage xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">0</ns1:itemsperpage> | |
<ns1:startindex xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">1</ns1:startindex> | |
<ns0:generator uri="http://www.blogger.com" version="7.00">Blogger</ns0:generator> | |
<ns0:author><ns0:name>Tim</ns0:name></ns0:author> | |
<ns0:id>tag:blogger.com,1999:blog-413573351281770670</ns0:id> | |
<ns0:link href="http://gpowered.blogspot.com/" rel="alternate" type="text/html" /> | |
<ns0:link href="http://gpowered.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" /> | |
<ns0:link href="http://www.blogger.com/feeds/413573351281770670/posts/default?max-results=0" rel="self" type="application/atom+xml" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#show latest posts | |
def Posts(request): | |
return ListPosts(request, total_posts) | |
#show posts starting from a certain point | |
def ListPosts(request, start): | |
start = total_posts - int(start) + 1 | |
return PostFrom(request, start, show_num) | |
#show a single post |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#normalize data for output | |
for entry in feed.entry: | |
#get link for template | |
entry.my_link = entry.link[0].href | |
#id for links | |
entry.my_id = curr_id | |
curr_id -= 1 | |
#format published date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prev = total_posts - (start - count) + 1 | |
if prev > total_posts: | |
prev = None | |
next = total_posts - (start + count) + 1 | |
if next < 1: | |
next = None | |
#showing single post |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return render_to_response('posts/index.html', { | |
'entries': feed.entry, | |
'title': title, | |
'tag_link': tag_link, | |
'prev': prev, | |
'next': next, | |
'link': link, | |
'tab_home': True, | |
}) |