perfect alarm clock

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.

perfect alarm clock

Postby igotapochahontas » Thu Apr 24, 2014 2:11 pm

This alarm uses task bomb and sl4a script launcher to wake you up by reading you a joke.
(Written with python for android and sl4a) with a lot of help from the users on this forum.
Code: Select all
import re
import urllib2
import android
droid = android.Android()
def remove_html_tags(text):
    pattern = re.compile(r'</b></a>')
    return pattern.sub('', text)

page = urllib2.urlopen("http://www.m.funtweets.com/random").read()
umatch = re.search(r"<span>@</span>(\w+)", page)
user = umatch.group()
utext = re.search(r"</b></a> (\w.*)", page)
text = utext.group()
joke = remove_html_tags(text)
print joke
ignore = "... Stop ignoring your alarm, its time to wake up."
droid.ttsSpeak (joke+ignore)
igotapochahontas
 
Posts: 20
Joined: Thu Apr 10, 2014 5:51 pm

Re: perfect alarm clock

Postby micseydel » Tue May 06, 2014 12:39 am

I wanted to try this out, but I just took my second shot at trying to get SL4A working without success. What'd you use to get started? I just tried scanning the barcode here, but after it scans, I hear a beep, and then I end up back at a mostly black screen that says "Scripts" at the top and "No matches found" later on. So frustrating D=
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1268
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: perfect alarm clock

Postby igotapochahontas » Sun Jul 06, 2014 4:18 pm

you have to add the python for android interpreter after downloading sl4a. sl4a does nothing without an python for android. dont bother though. funtweets changed something on their site so this code doesnt work anymore. i cant figure out what changed because i dont know html well enough to fix the problem.
igotapochahontas
 
Posts: 20
Joined: Thu Apr 10, 2014 5:51 pm


Return to Completed Scripts

Who is online

Users browsing this forum: No registered users and 1 guest