Update of /cvsroot/freevo/freevo/lib/pywebinfo/src/rss
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12272
Added Files:
.cvsignore __init__.py rss.py
Log Message:
New module for grabbing/scraping information from the web. Contains own
httplib implementation for keeping the notifier alive.
--- NEW FILE: .cvsignore ---
*.pyc *.pyo
--- NEW FILE: rss.py ---
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
# rss.py - Rss parser
# -----------------------------------------------------------------------------
# $Id: rss.py,v 1.1 2005/04/15 21:00:37 vifredr Exp $
#
# Notes:
# Uses feedparser by Mark Pilgrim <http://diveintomark.org/>
#
# -----------------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
#
# First Edition: Viggo Fredriksen <[EMAIL PROTECTED]>
# Maintainer: Viggo Fredriksen <[EMAIL PROTECTED]>
#
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# 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 2 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 MER-
# CHANTABILITY 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, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------------
# python modules
from cStringIO import StringIO
# webinfo module
from pywebinfo.grabber import Grabber
from pywebinfo.lib.feedparser import parse
class RssGrabber(Grabber):
"""
This is just a thin layer above the feedparser to accommodate
our needs for notifying the main loop. It does not return an
item, only the raw dicts from feedparser. For more information
on how to use it, ckeck lib/feedparser.
"""
def __init__(self, cb_progress=None, cb_error=None,
cb_result=None, language='en-US'):
Grabber.__init__(self, cb_progress, cb_error, cb_result, language)
self.data = None
def handle_line(self, url, line):
"""
Handle one line of data
"""
self.data.write(line)
def handle_finished(self, url):
# Use feedparser to parse the results.
# PS: This seems to take a lot of time
# (~1.3s on my 2800+), if anyone knows
# a good implementation which takes as
# many formats as feedparser, but is
# quicker, please let me know.
self.data.seek(0)
feed = parse(self.data)
self.data.close()
self.deliver_result(feed)
def search(self, rss_url):
"""
Gets an RSS feed.
"""
self.data = StringIO()
self.get_url(rss_url)
return self.return_result()
--- NEW FILE: __init__.py ---
__all__ = ['RssGrabber']
from rss import RssGrabber
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog