Mark the file as downloaded (by the nature of Plex it will be marked as downloaded within
            any SyncItem where it presented).

            Parameters:
                media (base.Playable): the media to be marked as downloaded.
336758
def markDownloaded(self, media):
        
        url = '/sync/%s/item/%s/downloaded' % (self.clientIdentifier, media.ratingKey)
        media._server.query(url, method=requests.put)
957625
def _parse_downloaded_items(self, result, camera, path):
        """"""
        for item in result:
            try:
                created_at = item['created_at']
                camera_name = item['camera_name']
                is_deleted = item['deleted']
                address = item['address']
            except KeyError:
                _LOGGER.info("Missing clip information, skipping...")
                continue

            if camera_name not in camera and 'all' not in camera:
                _LOGGER.debug("Skipping videos for %s.", camera_name)
                continue

            if is_deleted:
                _LOGGER.debug("%s: %s is marked as deleted.",
                              camera_name,
                              address)
                continue

            clip_address = "{}{}".format(self.urls.base_url, address)
            filename = "{}_{}.mp4".format(camera_name, created_at)
            filename = os.path.join(path, filename)

            if os.path.isfile(filename):
                _LOGGER.info("%s already exists, skipping...", filename)
                continue

            response = api.http_get(self, url=clip_address,
                                    stream=True, json=False)
            with open(filename, 'wb') as vidfile:
                copyfileobj(response.raw, vidfile)

            _LOGGER.info("Downloaded video to %s", filename)
231190
private void play(Media media, Align alignment)
    {
        try (Playback playback = createPlayback(media, alignment, volume))
        {
            if (opened.containsKey(media))
            {
                opened.get(media).close();
            }
            opened.put(media, playback);

            final AudioInputStream input = openStream(media);
            final SourceDataLine dataLine = playback.getDataLine();
            dataLine.start();
            readSound(input, dataLine);
            close(input, dataLine);
        }
        catch (final IOException exception)
        {
            if (last == null || !exception.getMessage().equals(last.getMessage()))
            {
                Verbose.exception(exception, media.toString());
                last = exception;
            }
        }
    }
18828
def save(self):
        
        storage = get_media_storage()
        for storage_name in self.cleaned_data['selected_files']:
            full_path = storage.path(storage_name)
            try:
                storage.delete(storage_name)
                self.success_files.append(full_path)
            except OSError:
                self.error_files.append(full_path)
1272278
def update_media(media_uri, file_path, content_type)
      file_path = Pathname.new(file_path) unless file_path.is_a?(Pathname)
      stream = file_path.open { |f| f.binmode; f.read }
      update_resource(media_uri, stream, content_type)
    end
707310
protected function markPhysicallyUnavailable()
    {
        $this->is_physically_present = false;

        $this->mime = 'image/png';
        $this->width = 256;
        $this->height = 256;
        $this->file = $this->getSubstituteFilename();
        $this->etag = null;

        $this->path = $this->app['root.path'] . '/www/assets/common/images/icons/substitution/';
        $this->url = Url::factory('/assets/common/images/icons/substitution/' . $this->file);

        if (!file_exists($this->getRealPath())) {
            $this->path = $this->app['root.path'] . '/www/assets/common/images/icons/';
            $this->file = 'substitution.png';
            $this->url = Url::factory('/assets/common/images/icons/' . $this->file);
        }
    }
593911
def already_downloaded(track, title, filename):
    
    global arguments
    already_downloaded = False

    if os.path.isfile(filename):
        already_downloaded = True
    if arguments['--flac'] and can_convert(filename) \
                           and os.path.isfile(filename[:-4] + ".flac"):
        already_downloaded = True
    if arguments['--download-archive'] and in_download_archive(track):
        already_downloaded = True

    if arguments['--flac'] and can_convert(filename) and os.path.isfile(filename):
        already_downloaded = False

    if already_downloaded:
        if arguments['-c'] or arguments['--remove']:
            logger.info('Track "{0}" already downloaded.'.format(title))
            return True
        else:
            logger.error('Track "{0}" already exists!'.format(title))
            logger.error('Exiting... (run again with -c to continue)')
            sys.exit(0)
    return False
414642
def upload_permanent_media(self, media_type, media_file):
        
        return self.post(
            url="https://api.weixin.qq.com/cgi-bin/material/add_material",
            params={
                "access_token": self.token,
                "type": media_type
            },
            files={"media": media_file}
        )
350591
def get_or_add_media_part(self, media):
        
        media_part = self._find_by_sha1(media.sha1)
        if media_part is None:
            media_part = MediaPart.new(self._package, media)
        return media_part
576730
def attach(self, media: typing.Union[InputMedia, typing.Dict]):
        
        if isinstance(media, dict):
            if 'type' not in media:
                raise ValueError(f"Invalid media!")

            media_type = media['type']
            if media_type == 'photo':
                media = InputMediaPhoto(**media)
            elif media_type == 'video':
                media = InputMediaVideo(**media)
            # elif media_type == 'document':
            #     media = InputMediaDocument(**media)
            # elif media_type == 'audio':
            #     media = InputMediaAudio(**media)
            # elif media_type == 'animation':
            #     media = InputMediaAnimation(**media)
            else:
                raise TypeError(f"Invalid media type '{media_type}'!")

        elif not isinstance(media, InputMedia):
            raise TypeError(f"Media must be an instance of InputMedia or dict, not {type(media).__name__}")

        elif media.type in ['document', 'audio', 'animation']:
            raise ValueError(f"This type of media is not supported by media groups!")

        self.media.append(media)
182597
public void play ()
    {
        if (_state == AL10.AL_PLAYING) {
            log.warning("Tried to play stream already playing.");
            return;
        }
        if (_state == AL10.AL_INITIAL) {
            _qidx = _qlen = 0;
            queueBuffers(_buffers.length);
        }
        _source.play();
        _state = AL10.AL_PLAYING;
    }
80588
def ytdl_progress_hook(self, d):
        """"""
        if d['status'] == 'downloading':
            self.play_empty()

            if "elapsed" in d:
                if d["elapsed"] > self.current_download_elapsed + 4:
                    self.current_download_elapsed = d["elapsed"]

                    current_download = 0
                    current_download_total = 0
                    current_download_eta = 0
                    if "total_bytes" in d and d["total_bytes"] > 0:
                        current_download_total = d["total_bytes"]
                    elif "total_bytes_estimate" in d and d["total_bytes_estimate"] > 0:
                        current_download_total = d["total_bytes_estimate"]
                    if "downloaded_bytes" in d and d["downloaded_bytes"] > 0:
                        current_download = d["downloaded_bytes"]
                    if "eta" in d and d["eta"] > 0:
                        current_download_eta = d["eta"]

                    if current_download_total > 0:
                        percent = round(100 * (current_download / current_download_total))
                        if percent > 100:
                            percent = 100
                        elif percent < 0:
                            percent = 0

                        seconds = str(round(current_download_eta)) if current_download_eta > 0 else ""
                        eta = " ({} {} remaining)".format(seconds, "seconds" if seconds != 1 else "second")

                        downloading = "Downloading song: {}%{}".format(percent, eta)
                        if self.prev_time != downloading:
                            self.timelog.debug(downloading)
                            self.prev_time = downloading
        if d['status'] == 'error':
            self.statuslog.error("Error downloading song")
        elif d['status'] == 'finished':
            self.statuslog.info("Downloaded song")
            downloading = "Downloading song: {}%".format(100)
            if self.prev_time != downloading:
                self.timelog.debug(downloading)
                self.prev_time = downloading

            if "elapsed" in d:
                download_time = "{} {}".format(d["elapsed"] if d["elapsed"] > 0 else "<1",
                                               "seconds" if d["elapsed"] != 1 else "second")
                self.logger.debug("Downloaded song in {}".format(download_time))

            # Create an FFmpeg player
            future = asyncio.run_coroutine_threadsafe(self.create_ffmpeg_player(d['filename']), client.loop)
            try:
                future.result()
            except Exception as e:
                logger.exception(e)
                return
896790
def _play(self):
        
        while True:
            if self._buffered:
                self._source.push(self._buffer.get())
434395
def download_artifact(path, opts = {})
      download_file = "#{name}.#{Time.new.to_i}"
      begin
        URI.download path, download_file, opts
        if File.exist?(download_file)
          FileUtils.mkdir_p(File.dirname(name))
          FileUtils.mv(download_file, name)
        end
      ensure
        File.delete(download_file) if File.exist?(download_file)
      end
    end
944957
def download(self, media_id, as_stream=False):
        
        response = self.__app.native_api_call('media', 'd/' + media_id, {}, self.__options, False, None, as_stream, http_path="/api/meta/v1/", http_method='GET')
        return response
187252
protected function assignMedia()
	{

		// On development create all the packed files on the fly:
		if ( \Sifo\Domains::getInstance()->getDevMode() )
		{
			$packer = new \Sifo\JsPacker();
			$packer->packMedia();
			$packer = new \Sifo\CssPacker();
			$packer->packMedia();
		}

		$this->assign( 'media', \Sifo\Config::getInstance()->getConfig( 'css' ) );
		$this->assign( 'css_groups', $this->css_groups );
		$this->assign( 'js_groups', $this->js_groups );

		$this->assign( 'static_rev', $this->getStaticRevision() );
		$this->assign( 'media_module', $this->fetch( 'shared/media_packer.tpl' ) );

	}
685282
def media(self, uri):
        """"""
        try:
            local_path, _ = urllib.request.urlretrieve(uri)
            metadata = mutagen.File(local_path, easy=True)
            if metadata.tags:
                self._tags = metadata.tags
            title = self._tags.get(TAG_TITLE, [])
            self._manager[ATTR_TITLE] = title[0] if len(title) else ''
            artist = self._tags.get(TAG_ARTIST, [])
            self._manager[ATTR_ARTIST] = artist[0] if len(artist) else ''
            album = self._tags.get(TAG_ALBUM, [])
            self._manager[ATTR_ALBUM] = album[0] if len(album) else ''
            local_uri = 'file://{}'.format(local_path)

        # urllib.error.HTTPError
        except Exception:  # pylint: disable=broad-except
            local_uri = uri
        self._player.set_state(Gst.State.NULL)
        self._player.set_property(PROP_URI, local_uri)
        self._player.set_state(Gst.State.PLAYING)
        self.state = STATE_PLAYING
        self._manager[ATTR_URI] = uri
        self._manager[ATTR_DURATION] = self._duration()
        self._manager[ATTR_VOLUME] = self._player.get_property(PROP_VOLUME)
        _LOGGER.info('playing %s (as %s)', uri, local_uri)