def _on_net_stop(self, widget): self.toolbar.stop_button.disable() self.enable_disable_navigation() self.toolbar.loading_icon.hide() logging.info("checking %s", self.browser.get_current_url()) if flashscraper.is_maybe_flashscrapable(unicode(self.browser.get_current_url())): self.toolbar.download_button.show()
def callback(headers): """We need to figure out if the URL is a external video link, or a link to a feed. """ if check_url_exists(url): return content_type = headers.get("content-type") if content_type: if filetypes.is_feed_content_type(content_type): add_feeds([url]) return if flashscraper.is_maybe_flashscrapable(url): entry = _build_entry(url, "video/x-flv", additional=metadata) download_video(entry) return if filetypes.is_maybe_feed_content_type(content_type): logging.info("%s content type is %s. " "going to peek to see if it's a feed....", url, content_type) httpclient.grab_url(url, callback_peek, errback) return entry = _build_entry(url, content_type) if filetypes.is_video_enclosure(entry["enclosures"][0]): download_video(entry) else: handle_unknown_callback(url)
def _on_net_stop(self, widget): self.toolbar.stop_button.disable() self.enable_disable_navigation() self.toolbar.loading_icon.set_throbber(False) logging.debug("checking %s", self.browser.get_current_url()) if flashscraper.is_maybe_flashscrapable( unicode(self.browser.get_current_url())): self.toolbar.download_button.show()
def _yahoo_hack(feedparser_entries): """Hack yahoo search to provide enclosures""" for entry in feedparser_entries: if 'enclosures' not in entry: try: url = entry['link'] except KeyError: continue mimetype = filetypes.guess_mime_type(url) if mimetype is not None: entry['enclosures'] = [{'url': util.to_uni(url), 'type': util.to_uni(mimetype)}] elif flashscraper.is_maybe_flashscrapable(url): entry['enclosures'] = [{'url': util.to_uni(url), 'type': util.to_uni("video/flv")}]
def callback(headers, content_type=None): """We need to figure out if the URL is a external video link, or a link to a feed. """ print 'callback for', url, headers, content_type if check_url_exists(url): return if content_type is None: content_type = headers.get("content-type") if content_type: if filetypes.is_feed_content_type(content_type): add_feeds([url]) return if flashscraper.is_maybe_flashscrapable(url): entry = _build_entry(url, 'video/x-flv', additional=metadata) download_video(entry) return if amazon.is_amazon_content_type(content_type): amazon.download_file(url, handle_unknown_callback) return if filetypes.is_maybe_feed_content_type(content_type): logging.info( "%s content type is %s. " "going to peek to see if it's a feed....", url, content_type) httpclient.grab_url(url, callback_peek, errback) return entry = _build_entry(url, content_type) if filetypes.is_video_enclosure(entry['enclosures'][0]): download_video(entry) else: handle_unknown_callback(url)