def _delete(self, path, callback, **kwargs): args = self._default_params() args.update(kwargs) # Turns out the SC API doesn't mind body arguments for DELETEs, # and as it's neater and slightly more secure, let's do that. body = urlencode(args) msg = Soup.Message.new('DELETE', self._url(path)) msg.set_request('application/x-www-form-urlencoded', Soup.MemoryUse.COPY, body) download(msg, self._cancellable, callback, None, try_decode=False)
def __init__(self, url, config, cancellable=None): super().__init__() self.config = config self.url = url self.cancellable = cancellable self.message = msg = Soup.Message.new('GET', self.url) self._content_type = None self._original = None download(msg, cancellable, self._sent, None) self.set_size_request(config.preview_size, config.preview_size) self._pixbuf = None
def __init__(self, url, config: Config, cancellable=None): super().__init__() self.config = config self.url = url self.cancellable = cancellable self.message = msg = Soup.Message.new('GET', self.url) self._content_type = None self._original = None download(msg, cancellable, self._sent, None, failure_callback=lambda *args: self.emit("failed", self.url)) self.set_size_request(config.preview_size, config.preview_size) self._pixbuf = None
def download_songs(self, path: Path): for s in self.songs: msg = Soup.Message.new('GET', s("~uri")) http.download(msg, cancellable=None, callback=self._downloaded, failure_callback=self._failed, data=(path, s)) yield while self.frac < 1 and self.task: sleep(0.1) yield self.task.finish() self.emit("finished", len(self.successful), len(self.failed))