Example #1
0
    def should_load_url(self, url):
        """Returns True if the Miro browser should handle the url and
        False otherwise.

        Situations which should return false:

        * if the url is something that Miro should download instead
        * other things?
        """
        logging.debug("got %s", url)

        if url in self.seen_cache:
            del self.seen_cache[url]
            return True

        url = util.to_uni(url)
        if subscription.is_subscribe_link(url):
            self.emit('download-started')
            messages.SubscriptionLinkClicked(url).send_to_backend()
            return False


        if filetypes.is_maybe_rss_url(url):
            logging.debug("miro wants to handle %s", url)
            self.emit('download-started')
            messages.DownloadURL(url, self.unknown_callback).send_to_backend()
            return False

        # parse the path out of the url and run that through the filetypes
        # code to see if it might be a video, audio or torrent file.
        # if so, try downloading it.
        ret = urlparse(url)
        if filetypes.is_allowed_filename(ret[2]):
            logging.debug("miro wants to handle %s", url)
            self.emit('download-started')
            messages.DownloadURL(url, self.unknown_callback).send_to_backend()
            return False

        if util.is_magnet_uri(url):
            logging.debug("miro wants to handle %s", url)
            self.emit('download-started')
            messages.DownloadURL(url, self.unknown_callback).send_to_backend()
            return False

        return True
Example #2
0
def handle_external_url(url):
    if url.startswith(u'feed://') or url.startswith(u'feeds://'):
        feed_info = app.tabs['feed'].find_feed_with_url(url)
        if feed_info is not None:
            print 'SHOULD BLINK: %r' % feed_info.name
        return

    if filetypes.is_feed_filename(url):
        ask_for_feed_subscribe(url)
    elif filetypes.is_allowed_filename(url): # media URL, download it
        messages.DownloadURL(url).send_to_backend()
    else:
        app.widgetapp.open_url(url)
Example #3
0
    def should_load_mimetype(self, url, mimetype):
        """Like should_load_url(), but for mimetype checking.  """

        # FIXME: this never gets called on windows

        if filetypes.is_allowed_mimetype(mimetype):
            logging.debug("miro wants to handle %s", url)
            metadata = {'mime_type': mimetype}
            self.emit('download-started')
            messages.DownloadURL(url, self.unknown_callback,
                                 metadata).send_to_backend()
            return False

        return True
Example #4
0
 def _on_browser_download(self, widget):
     metadata = {"title": unicode(self.browser.get_current_title())}
     messages.DownloadURL(self.browser.get_current_url(),
                          metadata=metadata).send_to_backend()
Example #5
0
 def do_download_finished(self, url):
     logging.debug('finished downloading %s', url)
     self.emit('download-started')
     messages.DownloadURL(url, self.unknown_callback).send_to_backend()