Advertisement
Fugiman

openbound_ebubble.py

Aug 31st, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.87 KB | None | 0 0
  1. import xml.etree.ElementTree as ET
  2. import urllib2, re
  3.  
  4. tweets = []
  5. data = urllib2.urlopen('http://mspaintadventures.com/storyfiles/hs2/05260/levels/openbound/redBubbleText.xml').read()
  6. tree = ET.fromstring(data)
  7. for args in tree.iter('args'):
  8.     tweets.extend(args.text.split('@dave_idle%alttextbox_twitter DAVE/_EBUBBLES:'))
  9.  
  10. text = ""
  11. html = """<!doctype html>
  12. <html><head>
  13.    <title>Openbound Dave_EBubbles</title>
  14.    <style>
  15.        @font-face { font-family: Sburb; src: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/fonts/cour.ttf'), url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/fonts/cour.woff'); }
  16.        body { font-size: 14px; font-weight: bold; font-family: Courier New, Courier, Sburb; }
  17.        .tweet { float: left; margin: 10px 40px 10px 10px; position: relative; height: 470px; width: 700px; }
  18.        .dave { top: 0px; left: -30px; position: absolute; z-index: 1; width: 380px; height: 470px; background: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/dialogs/dave_idle.png') no-repeat; }
  19.        .words { top: 125px; left: 190px; position: absolute; z-index: 0; height: 325px; width: 537px; }
  20.        .text { color: #e00707; padding: 30px 30px 50px 150px; height: 151px; width: 358px; background: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/interface/alttextbox_twitter.png'); }
  21.        .hashtag { text-align: right; padding: 14px 5px; height: 27px; width: 527px; background: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/interface/hashtagbar.png'); }
  22.        .hashtag a { display: inline-block; height: 26px; width: 30px; z-index: 2; }
  23.        .spade { background: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/interface/icons_spade.png') no-repeat; }
  24.        .heart { background: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/interface/icons_heart.png') no-repeat; }
  25.        .rebubble { background: url('http://mspaintadventures.com/storyfiles/hs2/05260/resources/openbound/interface/icons_bub.png') no-repeat; }
  26.    </style>
  27. </head><body>
  28. """
  29. id = 1
  30. template = '<div id="ebubble-%d" class="dave"></div><div class="words"><div class="text"><span>DAVE_EBUBBLES: %s</span></div><div class="hashtag"><a class="spade" title="Permalink" href="#ebubble-%d"></a><a class="heart" title="Permalink" href="#ebubble-%d"></a><a class="rebubble" title="Permalink" href="#ebubble-%d"></a></div></div></div>'
  31. for t in tweets:
  32.     t = t.strip()
  33.     if not t:
  34.         continue
  35.     html += '\t<div class="tweet">'
  36.     html += template % (id, t, id, id, id)
  37.     html += '</div>\n'
  38.     text += "DAVE_EBUBBLES: %s\n" % t
  39.     id += 1
  40. html += '</body></html>'
  41.  
  42. with open("openbound_ebubble.html","w") as f:
  43.     f.write(html)
  44.  
  45. with open("openbound_ebubble.txt","w") as f:
  46.     f.write(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement