def __getattr__(self, tag): if tag == "link": for elem in self._element.findall(self._ns + tag): if not elem.get("rel") == "enclosure": return elem.get("href") return '' elif tag == "enclosures": myl = [] for elem in self._element.findall(self._ns + 'link'): if elem.get("rel") == "enclosure": length = elem.get("length") if length: length = int(length) / 1048576 myl.append(ScanFile( elem.get("href"), mimetype = elem.get("type"), size = length, autodetect = False )) return myl elif tag == "summary": text = self._element.findtext(self._ns + 'summary') if not text: # NOTE: if we don't have a summary we use the full content instead elem = self._element.find(self._ns + 'content') if elem is not None and elem.get('type') == "html": text = elem.text return text return ElementWrapper.__getattr__(self, tag)
def download_file(session, url, to = None, askOpen = False, callback = None, \ **kwargs): """Provides a simple downloader Application""" from Components.Scanner import ScanFile file = ScanFile(url, autodetect=False) from MediaDownloader import MediaDownloader session.open(MediaDownloader, file, askOpen, to, callback)
def __getattr__(self, tag): if tag == "enclosures": myl = [] for elem in self._element.findall(self._ns + 'enclosure'): length = elem.get("length") if length: length = int(length) / 1048576 myl.append(ScanFile( elem.get("url"), mimetype = elem.get("type"), size = length, autodetect = False) ) return myl elif tag == "id": return self._element.findtext(self._ns + 'guid', self.title + self.link) elif tag == "updated": tag = "lastBuildDate" elif tag == "summary": tag = "description" return ElementWrapper.__getattr__(self, tag)