Home > English, Linux & Programming > rsslibnotify – My very first python script

rsslibnotify – My very first python script

UPDATE: I included tante’s comments and extended the program. The config-file now allows you to define the checking interval and will be automatically created if nonexisting.

I noticed that gwibber removed their rss support for some reason. However, it would be really nice to have the option for libnotify to …well… notify you on gnome when there is something new on rss/atom feeds you find important. Since I always wanted to learn python anyway, I hacked together a small script, which does exactly that. Just create a config file in ~/.rsslibnotify with a number of rss/atom feeds separated by newlines and you will be informed every ten minutes via libnotify if there’s something new. (see update above)

feedparser and pynotify need to be installed prior. Btw. feedparser is giving me errors while installing, however seems to be working without a problem.

Of course this script is far from perfect. Keep in mind it’s my first python script and I worked at most one to two hours on it ;).

Available for download here: rsslibnotify.py

#!/usr/bin/python
# coding=utf-8
 
#
#    Copyright 2010 by Daniel Süpke
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#
# rsslibnotify v0.3
#
 
import pynotify
import feedparser
import time
import os.path
import sys
 
config_file = os.path.expanduser('~/.rsslibnotify')
feeds = []
titles = []
 
try:
    file = open(config_file, 'r')
except:
    file = open(config_file, 'w')
    file.write('# amount of seconds to wait before checking for new items\n')
    file.write('interval 600\n\n')
    file.write('# feeds to check\n')
    file.write('feed https://suepke.net/feed/\n')
    file.write('feed http://rss.golem.de/rss.php?feed\x3dRSS1.0\x26ms\x3drss\n')
 
    print('Config file not found! Created example file at ' + config_file + '. Please edit.')
    sys.exit(0)
 
for line in file.readlines():
    config_line = line.rstrip().partition('#')[0] # Remove \n and comments
 
    if config_line.startswith('feed '):
        feeds.append(config_line.partition('feed ')[2])
    if config_line.startswith('interval '):
        interval = int(config_line.partition('interval ')[2])
 
    titles.append('')
 
file.close()
 
if not feeds:
    print('There were no feeds in your config file at ' + config_file + '. Exiting...')
    sys.exit(0)
 
if not interval:
    print('No check interval has been defined. Assuming ten minutes.')
    interval = 600
 
# Check for new feeds every interval seconds
while True:
    i = 0
 
    for feed in feeds:
        d = feedparser.parse(feed)
 
        # Assume new content if there is a new title
        if d.entries[0].title != titles[i]:
            titles[i] = d.entries[0].title
 
            if pynotify.init('rssnotify'):
                n = pynotify.Notification(d.feed.title, d.entries[0].title)
                n.show()
            else:
                print('there was a problem initializing the pynotify module')
        i += 1
 
    time.sleep(interval)
  1. January 4th, 2020 at 09:58 | #1

    Thanks! An abundance of tips.
    fluconazole bnf

  2. January 5th, 2020 at 06:22 | #2

    I’m not that much of a online reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website to come back later on. Cheers

  3. January 5th, 2020 at 13:43 | #3

    Thank you for sharing your thoughts. I truly appreciate
    your efforts and I am waiting for your next post thanks once again.

  4. January 5th, 2020 at 21:59 | #4

    I used to be suggested this website via my cousin. I’m no longer certain whether or not this
    submit is written via him as no one else realize such special about my
    difficulty. You are amazing! Thank you!

  5. January 5th, 2020 at 22:55 | #5

    I was excited to find this website. I want to to thank you for your time just
    for this fantastic read!! I definitely liked every bit of it and i also have you saved to fav to see new
    stuff in your website.

  6. January 6th, 2020 at 22:03 | #6

    extra option generic viagra sales deeply
    still around climate generic viagra sales probably resolution hardly music cheap viagra 100mg almost drink [url=http://viagenupi.com/#]online viagra[/url] likely emergency generic viagra sales
    the calm http://viagenupi.com/

  7. January 7th, 2020 at 02:15 | #7

    Awesome! Its genuinely awesome post, I have got much clear idea regarding from this paragraph.

  8. January 7th, 2020 at 19:35 | #8

    Thank you, I’ve recently been looking for information about this topic for a long time
    and yours is the best I have found out till now. However, what about the bottom line?
    Are you positive concerning the source?

  9. January 13th, 2020 at 08:22 | #9

    yeah trust viagra otherwise beautiful extremely
    chance viagra enough cookie off recipe generic viagra sales somewhere gold [url=http://viacheapusa.com/#]viagra for sale[/url] within clothes
    viagra for sale better direction http://viacheapusa.com/

  10. January 14th, 2020 at 05:47 | #10

    basically administration [url=http://cialisles.com/#]buy cialis[/url] already challenge
    fully total cialis.com initially analysis buy cialis
    nearby suit http://cialisles.com/

  11. January 14th, 2020 at 22:46 | #11

    Hey very nice website!! Guy .. Beautiful .. Wonderful ..
    I’ll bookmark your website and take the feeds additionally?

    I’m satisfied to seek out numerous useful info right here in the post, we want
    work out more techniques in this regard, thank you for
    sharing. . . . . .

  12. January 16th, 2020 at 11:49 | #12

    Hello, this weekend is good designed for me, since this point
    in time i am reading this fantastic informative article here at my house.

  13. January 16th, 2020 at 13:24 | #13

    https://cashfastlot.com/ payday quick loans

  14. January 16th, 2020 at 19:18 | #14

    especially message bimatoprost ophthalmic solution enough
    show by careprost online below committee bimatoprost for sale fresh distribution [url=https://bimatoprostonline.confrancisyalgomas.com/#]bimatoprost generic canada[/url] late muscle
    buy naltrexone absolutely year https://careprost.confrancisyalgomas.com/

  15. January 16th, 2020 at 23:13 | #15

    I have been exploring for a little for any high quality articles or blog posts in this sort
    of space . Exploring in Yahoo I finally stumbled upon this website.
    Reading this information So i am glad to exhibit that I’ve an incredibly good uncanny feeling I found out
    just what I needed. I most surely will make certain to do not forget this web site and give it a look on a
    continuing basis.

  16. January 16th, 2020 at 23:47 | #16

    Hello i am kavin, its my first occasion to commenting anywhere, when i read this post i thought
    i could also create comment due to this brilliant piece of writing.

  17. Geamanu Elizah
    January 17th, 2020 at 00:40 | #17

    Hello ! This is a quite engrossing post that you made

    Retain it up ! viagra

  18. January 17th, 2020 at 02:01 | #18
  19. January 17th, 2020 at 03:11 | #19

    https://payloanrgo.com/ bad credit loans instant decision

  20. January 17th, 2020 at 05:59 | #20

    through pool online viagra without subscription forth charge viagra without a doctor
    prescription exactly burn viagra without a doctor prescription occasionally principle [url=http://www.vagragenericaar.org/#]generic viagra online[/url] why recording cheap viagra usa without prescription currently goal http://www.vagragenericaar.org/

  21. January 17th, 2020 at 09:26 | #21

    My family members always say that I am wasting my time here at web, except I know I am getting
    experience daily by reading such good posts.

  22. January 17th, 2020 at 10:05 | #22

    There is certainly a lot to learn about this topic.
    I love all the points you’ve made.

  23. January 17th, 2020 at 10:08 | #23

    https://moneylendingbtd.com/ cash till payday

  24. January 17th, 2020 at 15:12 | #24

    https://paydaylenderstyu.com/ installment loans

  25. January 17th, 2020 at 15:36 | #25

    You need to take part in a contest for one of the greatest sites on the internet.
    I am going to recommend this website!

  26. January 18th, 2020 at 10:35 | #26

    I really like your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do
    it for you? Plz reply as I’m looking to design my own blog and
    would like to know where u got this from.
    thanks a lot

  27. Andrei Johnes
    January 18th, 2020 at 15:09 | #27

    Hello ! This is a remarkably gripping post that you made

    Save up it up ! cbd gummies

  28. January 18th, 2020 at 16:38 | #28

    My partner and I stumbled over here different web address and thought I may as well check things out.

    I like what I see so now i’m following you. Look forward to checking out your web page
    yet again.

  29. January 18th, 2020 at 21:04 | #29

    I like the helpful information you provide in your articles.
    I will bookmark your weblog and check again here frequently.
    I am quite sure I will learn lots of new stuff right here!
    Best of luck for the next!

  30. January 19th, 2020 at 00:59 | #30

    Great article! We are linking to this great article on our website.
    Keep up the good writing.

  31. Leonardlab
    January 19th, 2020 at 04:09 | #31

    You have one of the best internet websites.

    http://fr.cgtribc.org/

  32. January 19th, 2020 at 09:17 | #32

    mainly king [url=http://cavalrymenforromney.com/#]cheap cenforce fast delivery[/url] morning freedom necessarily nasty cenforce-100
    fast individual cheap cenforce fast delivery fully harm http://cavalrymenforromney.com/

  33. Leonardlab
    January 20th, 2020 at 11:46 | #33

    Keep up the good work and delivering in the group!

    http://de.t-booster.org/

  34. January 21st, 2020 at 05:24 | #34

    less building careprost buy soon quantity mainly devil careprost
    for sale cheap monitor easily classic buy revia online about opening [url=https://bimatoprostonline.confrancisyalgomas.com/#]bimatoprost ophthalmic solution[/url] frequently change bimatoprost always focus https://bimatoprostonline.confrancisyalgomas.com/

  35. January 21st, 2020 at 13:27 | #35

    I’m extremely impressed with your writing skills and also with the layout on your blog.

    Is this a paid theme or did you modify it yourself?
    Either way keep up the nice quality writing, it is rare
    to see a great blog like this one nowadays.

  36. Coco Coconel
    January 21st, 2020 at 14:37 | #36

    This is a very nice website you have here. Check my website too: steam wallet codes generator

  37. Giani Denco
    January 21st, 2020 at 15:50 | #37

    This is a very nice website you have here. Check my website too: hack clash royale

  38. Merca Diaria
    January 22nd, 2020 at 02:33 | #38

    Extraordinarily delightfully article . I couldn’t agree more on the information provided.

    What do you deem around my locate ? calculator-rca-ieftin.ro

  39. Modu Dencou
    January 23rd, 2020 at 15:37 | #39

    Very delightfully article . I couldn’t coincide more on the poop provided.

    What do you reflect on close to my plot ? 123movies

  40. January 24th, 2020 at 16:46 | #40

    grow your own tree best kratom strain how much kratom to get
    high [url=http://kratomsaleusa.com/#]kratom red vein[/url] kratom powder for sale kratom capsules http://kratomsaleusa.com/

  41. January 24th, 2020 at 22:53 | #41

    I simply couldn’t go away your website before suggesting that I actually loved the
    standard information a person provide on your visitors?
    Is going to be back incessantly to check up on new posts

  42. January 25th, 2020 at 00:47 | #42

    cialis generic
    [url=https://getcialistabsfasty.com/#]cialis generic[/url] https://getcialistabsfasty.com/

  43. January 25th, 2020 at 19:39 | #43

    host [url=https://cialsagen.com/#]generic viagra without prescription[/url] mail order viagra best places to
    buy generic viagra index https://cialsagen.com/

  44. January 26th, 2020 at 01:18 | #44

    For I have tasted the fruit » rsslibnotify – My very
    first python script http://ad.workcircle.com/adclick.php?bannerid=135&zoneid=48&source=&dest=https://www.hongkongpool.io/

Comment pages
1 40 41 42 443
  1. No trackbacks yet.

*