Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import feedparser
- import time
- import requests
- import smtplib
- from email.mime.text import MIMEText
- from_email = "User <from@user.com>"
- to_email = "to@user.com"
- smtp_host = "smtp.server.com"
- smtp_user = "smtp_username"
- smtp_pass = "smtp_password"
- sms_number = "sms_number"
- sms_password = "secret_token"
- search_words = ['GTA',
- 'grand theft auto']
- previously_added = []
- if __name__ == "__main__":
- print "Script is running..."
- while True:
- feed = feedparser.parse("http://rss.url.com/")
- for item in feed['entries']:
- for search_word in search_words:
- if search_word.lower() in item['title'].lower():
- if item['title'].lower() not in previously_added:
- previously_added.append(item['title'].lower())
- print item['title']
- try:
- payload = {'password': sms_password, 'phone': sms_number, 'text': item['title']}
- r = requests.get('http://127.0.0.1:9090/sendsms', params=payload)
- except Exception:
- pass
- try:
- s = smtplib.SMTP_SSL(smtp_host)
- s.login(smtp_user, smtp_pass)
- msg = MIMEText("The following release has been uploaded:\n"
- "%s\n\n"
- "Enjoy." % item['title'])
- msg['Subject'] = 'Release: %s' % item['title'].encode('utf8')
- msg['From'] = from_email
- msg['To'] = to_email
- s.sendmail(from_email, to_email, msg.as_string())
- s.quit()
- except Exception:
- pass
- time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement