Last active
          August 29, 2015 14:17 
        
      - 
      
- 
        Save DarwinAwardWinner/9424353345444fade493 to your computer and use it in GitHub Desktop. 
    A script to check whether Ash is doing a Sister Claire live-write and print the 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
    
  
  
    
  | The latest Sister Claire live-write started 19 hours ago at Fri, 27 Mar 2015 17:41. The URL is: | |
| https://docs.google.com/document/d/1qpj_QxQSRWMbd_S1PVHAM4aBpb-RrskMIqcMHS4i0F0/edit | 
  
    
      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
    
  
  
    
  | #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import arrow | |
| from dateutil.tz import tzlocal | |
| import requests | |
| from lxml import etree, html | |
| from lxml.etree import tostring | |
| from humanize import naturaltime | |
| ash_rss = 'http://summerlightning.tumblr.com/rss' | |
| rss_page = requests.get(ash_rss) | |
| rss = etree.fromstring(rss_page.text.encode(rss_page.encoding)) | |
| items = rss.xpath("/rss/channel/item") | |
| for item in items: | |
| desc = item.xpath("./description/text()")[0] | |
| try: | |
| gdocs_link = str(html.fromstring(desc).xpath(".//a/@href[contains(., 'docs.google.com')]")[-1]) | |
| except IndexError: | |
| continue | |
| pubdate = arrow.get(item.xpath("./pubDate/text()")[0], | |
| 'ddd, DD MMM YYYY HH:mm:ss Z') | |
| pubdate = arrow.get(pubdate.astimezone(tzlocal())) | |
| print "The latest Sister Claire live-write started %s at %s. The URL is:\n%s" % \ | |
| (pubdate.humanize(), | |
| pubdate.format("ddd, DD MMM YYYY HH:mm"), | |
| gdocs_link) | |
| break | |
| else: | |
| print "No recent Sister Claire live-writes found in the RSS feed." | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment