def __init__(self,file,tag='MediaList',load=1): self.file = policy.get_policy().get_path(file) if load: try: self.obj = factory.from_file(self.file) except IOError: self.obj = List(tag) else: self.obj = List(tag)
def _process(self): fd = StringIO(self.content) rss = factory.from_file(fd) media_list = List('MediaList') for channel in rss.channels(): publisher = channel.title(content=1) for item in channel.items(): enclosure = item.enclosure() if enclosure is None: continue self.log.debug('%s %s %s\n' % \ (item.title(content=1), publisher, enclosure.url)) attrs = {'title': item.title(content=1), 'publisher': publisher, 'link': enclosure.url, 'type': ''} media = GenericMedia('Media',attrs=attrs) if self.filter(media): media_list.append(media) return media_list