Returns a list of videos created in a given time period sorted by number of views, most popular first.

@param array $options

@return mixed
432203
public function videosTop($options = [])
    {
        $availableOptions = ['limit', 'offset', 'game', 'period'];

        $query = [];

        //  Filter the available options
        foreach ($availableOptions as $option) {

            if (isset($options[ $option ])) {

                $query[ $option ] = $options[ $option ];
            }
        }

        $parameters = $this->getDefaultHeaders();
        $parameters[ 'query' ] = $query;

        $response = $this->client->get('/kraken/videos/top', $parameters);

        return $response->json();
    }
98892
private function getVideos(): array {
        $videos = [];

        $topNode = $this->article()->getTopNode();

        if ($topNode instanceof Element && $topNode->parent() instanceof Element) {
            $nodes = $topNode->parent()->find('embed, object, iframe, video');

            foreach ($nodes as $node) {
                if ($node->hasAttribute('src')) {
                    $src = $node->attr('src');
                } else {
                    $src = $node->attr('data');
                }

                $match = array_reduce(self::$VIDEO_PROVIDERS, function($match, $domain) use ($src) {
                    $srcHost = (string)parse_url($src, PHP_URL_HOST);
                    $srcScheme = (string)parse_url($src, PHP_URL_SCHEME);

                    return $match || preg_match('@' . $domain . '$@i', $srcHost) && in_array($srcScheme, ['http', 'https']);
                });

                if (!$match) {
                    $srcPath = parse_url(strtolower($src), PHP_URL_PATH);
                    $srcExtension = pathinfo((string)$srcPath, PATHINFO_EXTENSION);

                    $match = in_array($srcExtension, self::$VIDEO_EXTENSIONS);
                }

                if ($match) {
                    $videos[] = $src;
                }
            }
        }

        return $videos;
    }
975032
public function getUploads($maxResults=50)
	{
		$channelsResponse = $this->youtube->channels->listChannels('contentDetails', array(
			'mine' => 'true',
		));

		foreach ($channelsResponse['items'] as $channel)
		{
			$uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];

			$playlistItemsResponse = $this->youtube->playlistItems->listPlaylistItems('snippet', array(
																									'playlistId' => $uploadsListId,
																									'maxResults' => $maxResults
																								));

			$items = [];
			foreach ($playlistItemsResponse['items'] as $playlistItem) 
			{
				$video = [];
				$video['videoId'] 		= $playlistItem['snippet']['resourceId']['videoId'];
				$video['title'] 		= $playlistItem['snippet']['title'];
				$video['publishedAt'] 	= $playlistItem['snippet']['publishedAt'];

				array_push($items, $video);
			}
		}

		return $items;
	}
1222025
public static function getAllRecords($options = [])
    {
        $options = Util::prepareOptions($options, [
            'indexField' => false,
            'order' => false,
            'limit' => false,
            'calcFoundRows' => false,
            'offset' => 0,
        ]);

        $query = 'SELECT '.($options['calcFoundRows'] ? 'SQL_CALC_FOUND_ROWS' : '').'* FROM `%s`';
        $params = [
            static::$tableName,
        ];

        if ($options['order']) {
            $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
        }

        if ($options['limit']) {
            $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']);
        }

        if ($options['indexField']) {
            return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']);
        } else {
            return DB::allRecords($query, $params, [static::class,'handleError']);
        }
    }
1240690
public function listCollections(array $options = [])
    {
        $collections = [];
        foreach ($this->collections as $name => $collection) {
            $collections[] = [
                'name' => $this->name . '.' . $name,
                'options' => $collection['options']
            ];
        }

        return new CollectionInfoLegacyIterator(new ArrayIterator($collections));
    }
405639
private function _get_collection($keyword, $start, $max, $sort) {
        global $SESSION;

        // The new API doesn't use "page" numbers for browsing through results.
        // It uses a prev and next token in each set that you need to use to
        // request the next page of results.
        $sesspagetoken = 'youtube_'.$this->id.'_nextpagetoken';
        $pagetoken = '';
        if ($start > 1 && isset($SESSION->{$sesspagetoken})) {
            $pagetoken = $SESSION->{$sesspagetoken};
        }

        $list = array();
        $error = null;
        try {
            $this->init_youtube_service(); // About to use the service, ensure it's loaded.
            $response = $this->service->search->listSearch('id,snippet', array(
                'q' => $keyword,
                'maxResults' => $max,
                'order' => $sort,
                'pageToken' => $pagetoken,
                'type' => 'video',
                'videoEmbeddable' => 'true',
            ));

            // Track the next page token for the next request (when a user
            // scrolls down in the file picker for more videos).
            $SESSION->{$sesspagetoken} = $response['nextPageToken'];

            foreach ($response['items'] as $result) {
                $title = $result->snippet->title;
                $source = 'http://www.youtube.com/v/' . $result->id->videoId . '#' . $title;
                $thumb = $result->snippet->getThumbnails()->getDefault();

                $list[] = array(
                    'shorttitle' => $title,
                    'thumbnail_title' => $result->snippet->description,
                    'title' => $title.'.avi', // This is a hack so we accept this file by extension.
                    'thumbnail' => $thumb->url,
                    'thumbnail_width' => (int)$thumb->width,
                    'thumbnail_height' => (int)$thumb->height,
                    'size' => '',
                    'date' => '',
                    'source' => $source,
                );
            }
        } catch (Google_Service_Exception $e) {
            // If we throw the google exception as-is, we may expose the apikey
            // to end users. The full message in the google exception includes
            // the apikey param, so we take just the part pertaining to the
            // actual error.
            $error = $e->getErrors()[0]['message'];
            throw new moodle_exception('apierror', 'repository_youtube', '', $error);
        }

        return $list;
    }
6840
public function render($video, $options = array()) {
        $helper = $this->_getSpecializedHelper($video);
        return $helper->render($video, $options);
    }
379495
public function getPager(array $options = array())
    {
        $options += array(
            'query' => $this->getFilterQuery(),
            'limit' => $this->config('list_limit', 20)
        );

        return array(
            'rendered' => $this->getWidgetPager($options),
            'limit' => $this->pager->getLimit()
        );
    }
707763
public function getLists(array $options = array())
    {

        $uri = $this->buildUserResourceUri('lists');
        $response = $this->makeAuthenticatedApiRequest($uri, $options);

        return $response->lists;

    }
1044764
public function listFiles($options = [])
    {
        $builder = $this->processHelper->getProcessBuilder(
            [
                'git',
                '--no-pager',
                'ls-files',
            ]
        );

        foreach ($options as $name => $value) {
            $builder->setOption($name, $value);
        }

        $process = $builder->getProcess();
        $process->run();

        return StringUtil::splitLines($process->getOutput());
    }
620346
public function bucket_get_objects( $options = array() ) {
	 	
	 	$result = null;
	 	if( ! is_array( $options ) ) {
		
			$this->errors[$this->error_count] = 'options not given as array';
			$this->error_count++;
		
		}
		try {
		
			$result = $this->bucket->objects( $options );
		
		}
		catch( \Exception $e ) {
	
			$result = $e;
			$this->errors[$this->error_count] = $e->getServiceException()->getMessage();
			$this->error_count++;
		
		}
		return $result;		
		
	 }
289772
public function getCollections($options = [])
    {
        $list = [];
        foreach ($this->db->listCollections($options) as $coll) {
            $list[] = $coll->getName();
        }

        return $list;
    }
536764
public function getData(Options $options = null)
    {
        if ($options === null) {
            // Take store global/default options
            $options = $this->store->getOptions();
            // By default formatters are disabled in JSON format
            $options->getHydrationOptions()->disableFormatters();
        }

        // Get unformatted data when using json
        $options->getHydrationOptions()->disableFormatters();

        $data = $this->store->getData($options);
        $now = new DateTime();

        $d = [
            'success' => true,
            'timestamp' => $now->format(DateTime::W3C),
            'total' => $data->getTotalRows(),
            'request_id' => $this->request_id,
            'start' => $data->getSource()->getOptions()->getOffset(),
            'limit' => $data->getSource()->getOptions()->getLimit(),
            'data' => $data->toArray()
        ];

        if ($this->options['debug']) {
            $source = $data->getSource();
            if ($source instanceof QueryableSourceInterface) {
                $d['query'] = $source->getQueryString();
            }
        }

        return json_encode($d);
    }
1196875
public static function query($options = array())
	{
		$timestamp_start_name = static::temporal_property('start_column');
		$timestamp_end_name = static::temporal_property('end_column');
		$max_timestamp = static::temporal_property('max_timestamp');

		$query = Query_Temporal::forge(get_called_class(), static::connection(), $options)
			->set_temporal_properties($max_timestamp, $timestamp_end_name, $timestamp_start_name);

		//Check if we need to add filtering
		$class = get_called_class();
		$timestamp = \Arr::get(static::$_lazy_filtered_classes, $class, null);

		if( ! is_null($timestamp))
		{
			$query->where($timestamp_start_name, '<=', $timestamp)
				->where($timestamp_end_name, '>', $timestamp);
		}
		elseif(static::get_primary_key_status() and ! static::get_primary_key_id_only_status())
		{
			$query->where($timestamp_end_name, $max_timestamp);
		}

		return $query;
	}
632594
public function getFollowedVideos($params = [])
  {
      $this->wrapper->checkScope('user_read');

      $defaults = [
          'limit'  => 10,
          'offset' => 0,
      ];

      return $this->wrapper->request('GET', 'videos/followed', ['query' => $this->resolveOptions($params, $defaults)], true);
  }
1234931
public function getAllVideos()
    {
        $videos = new ArrayList();
        if ($this->hasHeroVideo()) {
            $videos->push($this->HeroVideo());
        }
        if ($this->hasGalleryVideos()) {
            $videos->merge($this->VideoGallery());
        }
        $videos->removeDuplicates('HailID');

        return $videos;
    }
26994
public function fromArray(array $options)
    {
        if (isset($options['Id'])) {
            Validate::isString($options['Id'], 'options[Id]');
            $this->_id = $options['Id'];
        }

        if (isset($options['Configuration'])) {
            Validate::isString($options['Configuration'], 'options[Configuration]');
            $this->_configuration = $options['Configuration'];
        }

        if (isset($options['Created'])) {
            Validate::isDateString($options['Created'], 'options[Created]');
            $this->_created = new \DateTime($options['Created']);
        }

        if (isset($options['Description'])) {
            Validate::isString($options['Description'], 'options[Description]');
            $this->_description = $options['Description'];
        }

        if (isset($options['LastModified'])) {
            Validate::isDateString(
                $options['LastModified'],
                'options[LastModified]'
            );
            $this->_lastModified = new \DateTime($options['LastModified']);
        }

        if (isset($options['MediaProcessorId'])) {
            Validate::isString(
                $options['MediaProcessorId'],
                'options[MediaProcessorId]'
            );
            $this->_mediaProcessorId = $options['MediaProcessorId'];
        }

        if (isset($options['Name'])) {
            Validate::isString($options['Name'], 'options[Name]');
            $this->_name = $options['Name'];
        }

        if (isset($options['NumberofInputAssets'])) {
            Validate::isInteger(
                $options['NumberofInputAssets'],
                'options[NumberofInputAssets]'
            );
            $this->_numberofInputAssets = $options['NumberofInputAssets'];
        }

        if (isset($options['NumberofOutputAssets'])) {
            Validate::isInteger(
                $options['NumberofOutputAssets'],
                'options[NumberofOutputAssets]'
            );
            $this->_numberofOutputAssets = $options['NumberofOutputAssets'];
        }

        if (isset($options['Options'])) {
            Validate::isInteger($options['Options'], 'options[Options]');
            $this->_options = $options['Options'];
        }

        if (isset($options['EncryptionKeyId'])) {
            Validate::isString(
                $options['EncryptionKeyId'],
                'options[EncryptionKeyId]'
            );
            $this->_encryptionKeyId = $options['EncryptionKeyId'];
        }

        if (isset($options['EncryptionScheme'])) {
            Validate::isString(
                $options['EncryptionScheme'],
                'options[EncryptionScheme]'
            );
            $this->_encryptionScheme = $options['EncryptionScheme'];
        }

        if (isset($options['EncryptionVersion'])) {
            Validate::isString(
                $options['EncryptionVersion'],
                'options[EncryptionVersion]'
            );
            $this->_encryptionVersion = $options['EncryptionVersion'];
        }

        if (isset($options['InitializationVector'])) {
            Validate::isString(
                $options['InitializationVector'],
                'options[InitializationVector]'
            );
            $this->_initializationVector = $options['InitializationVector'];
        }
    }