Retrieves a feed of videos.

@param mixed $location (optional) The URL to query or a
Zend_Gdata_Query object from which a URL can be determined
@return Zend_Gdata_YouTube_VideoFeed The feed of videos found at the
specified URL.
559711
public function getVideoFeed($location = null)
    {
        if ($location == null) {
            $uri = self::VIDEO_URI;
        } else if ($location instanceof Zend_Gdata_Query) {
            $uri = $location->getQueryUrl($this->getMajorProtocolVersion());
        } else {
            $uri = $location;
        }
        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');
    }
938056
public function getVideoByUrl(string $videoUrl): Video
	{
		$url = new Nette\Http\Url($videoUrl);

		if (stripos($url->host, 'youtu.be') !== false) {
			return $this->getVideo(trim($url->getPath(), '/'));
		}

		$videoId = $url->getQueryParameter('v');
		if (stripos($url->host, 'youtube.com') === false || $videoId === null) {
			throw new Nette\InvalidArgumentException('videoUrl must be valid youtube url.');
		}

		return $this->getVideo($videoId);
	}
1221756
public function fetch_feeds( $url = null ) {
		if ( ! $url ) {
			$url = $this->url;
		}
		if ( empty( $url ) ) {
			return new WP_Error( 'invalid-url', __( 'A valid URL was not provided.', 'indieweb-post-kinds' ) );
		}
		$fetch = $this->fetch( $url );
		if ( is_wp_error( $fetch ) ) {
			return $fetch;
		}
		// A feed was given
		if ( $this->content instanceof SimplePie ) {
			if ( ! class_exists( 'Parse_This_RSS', false ) ) {
				require_once plugin_dir_path( __FILE__ ) . '/class-parse-this-rss.php';
			}
			return array(
				'results' => array(
					array(
						'url'        => $url,
						'type'       => 'feed',
						'_feed_type' => Parse_This_RSS::get_type( $this->content ),
						'name'       => $this->content->get_title(),
					),
				),
			);
		}
		if ( $this->doc instanceof DOMDocument ) {
			$xpath = new DOMXPath( $this->doc );
			// Fetch and gather <link> data.
			$links = array();
			foreach ( $xpath->query( '(//link|//a)[@rel and @href]' ) as $link ) {
				$rel   = $link->getAttribute( 'rel' );
				$href  = $link->getAttribute( 'href' );
				$title = $link->getAttribute( 'title' );
				$type  = self::get_feed_type( $link->getAttribute( 'type' ) );
				if ( in_array( $rel, array( 'alternate', 'feed' ), true ) && ! empty( $type ) ) {
					$links[] = array_filter(
						array(
							'url'        => WP_Http::make_absolute_url( $href, $url ),
							'type'       => 'feed',
							'_feed_type' => $type,
							'name'       => $title,
						)
					);
				}
			}
			// Check to see if the current page is an h-feed
			$this->parse( array( 'feed' => true ) );
			if ( isset( $this->jf2['type'] ) && 'feed' === $this->jf2['type'] ) {
				$links[] = array_filter(
					array(
						'url'        => $url,
						'type'       => 'feed',
						'_feed_type' => 'microformats',
						'name'       => $this->jf2['name'],
					)
				);
			} elseif ( isset( $this->jf2['items'] ) ) {
				foreach ( $this->jf2['items'] as $item ) {
					if ( 'feed' === $item['type'] && isset( $item['uid'] ) ) {
						$links[] = array_filter(
							array(
								'url'        => $item['uid'],
								'type'       => 'feed',
								'_feed_type' => 'microformats',
								'name'       => ifset( $item['name'] ),
							)
						);
					}
				}
			}
			// Sort feeds by priority
			$rank = array(
				'jf2feed'      => 0,
				'microformats' => 1,
				'jsonfeed'     => 2,
				'atom'         => 3,
				'rss'          => 4,
			);
			usort(
				$links,
				function( $a, $b ) use ( $rank ) {
					return $rank[ $a['_feed_type'] ] > $rank[ $b['_feed_type'] ];
				}
			);

			return array( 'results' => $links );
		}
		return new WP_Error( 'unknown error', null, $this->content );
	}
390207
public function setFeedType($feedType, $videoId = null, $entry = null)
    {
        switch ($feedType) {
        case 'top rated':
            $this->_url = Zend_Gdata_YouTube::STANDARD_TOP_RATED_URI;
            break;
        case 'most viewed':
            $this->_url = Zend_Gdata_YouTube::STANDARD_MOST_VIEWED_URI;
            break;
        case 'recently featured':
            $this->_url = Zend_Gdata_YouTube::STANDARD_RECENTLY_FEATURED_URI;
            break;
        case 'mobile':
            $this->_url = Zend_Gdata_YouTube::STANDARD_WATCH_ON_MOBILE_URI;
            break;
        case 'related':
            if ($videoId === null) {
                require_once 'Zend/Gdata/App/InvalidArgumentException.php';
                throw new Zend_Gdata_App_InvalidArgumentException(
                    'Video ID must be set for feed of type: ' . $feedType);
            } else {
                $this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' . $videoId .
                    '/related';
            }
            break;
        case 'responses':
            if ($videoId === null) {
                require_once 'Zend/Gdata/App/InvalidArgumentException.php';
                throw new Zend_Gdata_App_Exception(
                    'Video ID must be set for feed of type: ' . $feedType);
            } else {
                $this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' . $videoId .
                    '/responses';
            }
            break;
        case 'comments':
            if ($videoId === null) {
                require_once 'Zend/Gdata/App/InvalidArgumentException.php';
                throw new Zend_Gdata_App_Exception(
                    'Video ID must be set for feed of type: ' . $feedType);
            } else {
                $this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' .
                    $videoId . '/comments';
                if ($entry !== null) {
                    $this->_url .= '/' . $entry;
                }
            }
            break;
        default:
            require_once 'Zend/Gdata/App/Exception.php';
            throw new Zend_Gdata_App_Exception('Unknown feed type');
            break;
        }
    }
67788
public static function getMetadataByLocation( ezpContentLocation $location )
    {
        $url = $location->url_alias;
        eZURI::transformURI( $url, false, 'full' ); // $url is passed as a reference

        $aMetadata = array(
            'nodeId'        => (int)$location->node_id,
            'nodeRemoteId'  => $location->remote_id,
            'fullUrl'       => $url
        );

        return $aMetadata;
    }
419540
private function getContentType(EzLocation $location): ContentType
    {
        if (method_exists($location, 'getContent') && method_exists($location->getContent(), 'getContentType')) {
            return $location->getContent()->getContentType();
        }

        // @deprecated Remove when support for eZ kernel < 7.4 ends

        return $this->repository->getContentTypeService()->loadContentType(
            $location->contentInfo->contentTypeId
        );
    }
143953
public function getDocumentListEntry($location = null)
    {
        if ($location === null) {
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
            throw new Zend_Gdata_App_InvalidArgumentException(
                    'Location must not be null'
            );
        } else if ($location instanceof Zend_Gdata_Query) {
            $uri = $location->getQueryUrl();
        } else {
            $uri = $location;
        }
        return parent::getEntry($uri, 'Zend_Gdata_Docs_DocumentListEntry');
    }
1158055
public function find_feed($url, $http_function = false)
    {
        // using google feed API
        $url = "http://ajax.googleapis.com/ajax/services/feed/lookup?key={$this->google_key}&v=1.0&q=" . urlencode($url);
        // fetch the content
        if ($http_function) {
            $response = $http_function($url);
        } else {
            $response = $this->http($url);
        }

        $result = json_decode($response, true);
        $rss_url = $result['responseData']['url'];

        return $rss_url;
    }
1016167
public function getCalendarEventFeed($location = null)
    {
        if ($location == null) {
            $uri = self::CALENDAR_EVENT_FEED_URI;
        } else if ($location instanceof Zend_Gdata_Query) {
            $uri = $location->getQueryUrl();
        } else {
            $uri = $location;
        }
        return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed');
    }
256825
public function getListFeed($location)
    {
        if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) {
            $uri = $location->getQueryUrl();
        } else if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) {
            $uri = $location->getLink(self::LIST_FEED_LINK_URI)->href;
        } else {
            $uri = $location;
        }

        return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_ListFeed');
    }
508698
public function getFeed($options = []) {
        $pool = Registry::getStash();

        $cache = $pool->getItem('nyaa/feed/database/'.hash('sha512', json_encode($options)));

        if ($cache->isMiss()) {
            $cache->lock();

            $results = $this->getResults($options);
            $torrents = [];

            foreach ($results as $result) {
                $torrents[] = NyaaTorrent::fromArray($result);
            }

            $cache->set($torrents, 864000);
        }

        $data = $cache->get();

        return $data;
    }
820032
public function createLocation(Location $location): UIValue\Content\Location
    {
        return new UIValue\Content\Location($location, [
            'childCount' => $this->locationService->getLocationChildCount($location),
            'pathLocations' => $this->pathService->loadPathLocations($location),
            'userCanManage' => $this->permissionResolver->canUser(
                'content', 'manage_locations', $location->getContentInfo()
            ),
            'userCanRemove' => $this->permissionResolver->canUser(
                'content', 'remove', $location->getContentInfo(), [$location]
            ),
            'userCanEdit' => $this->permissionResolver->canUser(
                'content', 'edit', $location->getContentInfo(), [$location]
            ),
            'main' => $location->getContentInfo()->mainLocationId === $location->id,
        ]);
    }
222362
public function getCellEntry($location)
    {
        if ($location instanceof Zend_Gdata_Spreadsheets_CellQuery) {
            $uri = $location->getQueryUrl();
        } else {
            $uri = $location;
        }

        return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_CellEntry');
    }
865822
public function getUserEntry($location)
    {
        if ($location === null) {
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
            throw new Zend_Gdata_App_InvalidArgumentException(
                    'Location must not be null');
        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {
            $location->setType('entry');
            $uri = $location->getQueryUrl();
        } else if ($location instanceof Zend_Gdata_Query) {
            $uri = $location->getQueryUrl();
        } else {
            $uri = $location;
        }
        return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry');
    }
953513
public function loadPathLocations(Location $location)
    {
        $locationQuery = new LocationQuery([
            'filter' => new Ancestor($location->pathString),
            'sortClauses' => [new Path()],
        ]);

        $searchResult = $this->searchService->findLocations($locationQuery);

        return array_map(function (SearchHit $searchHit) {
            return $searchHit->valueObject;
        }, $searchResult->searchHits);
    }
22721
public function findNearbyHubs(Geolocatable $location)
    {
        $qb = $this->getEntityManager()->createQueryBuilder()
            ->select('pf')
            ->from('HarvestCloudCoreBundle:Profile', 'pf')
            ->addSelect('GEO(pf.latitude = :latitude, pf.longitude = :longitude) AS distance')
            ->where('pf.hub_status = :hub_status')
            ->andWhere('pf.system_hub_status = :system_hub_status')
            ->andWhere('GEO(pf.latitude = :latitude, pf.longitude = :longitude) < 50')
            ->setParameter('latitude', $location->getLatitude())
            ->setParameter('longitude', $location->getLongitude())
            ->setParameter('hub_status', Profile::STATUS_ACTIVE)
            ->setParameter('system_hub_status', Profile::STATUS_ENABLED)
            ->orderBy('distance')
        ;

        return $qb->getQuery()->execute();
    }
669548
public function loadContentInfoByLocationId($locationId)
    {
        try {
            return $this->innerGateway->loadContentInfoByLocationId($locationId);
        } catch (DBALException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        } catch (\PDOException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        }
    }