Skip to content

Commit

Permalink
added a bunch of new variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestecker committed Mar 7, 2018
1 parent 0b6e4bb commit 92aa17a
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/services/VideoEmbedderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,71 @@ public function getVideoThumbnail($url) {

}

/**
* Retrieves the title of video
* @param - $url: the url of the "player"
* @return - string
*
**/
public function getTitle($url) {
$url_parts = parse_url($url);

$title = $this->cleanUrl($this->getInfo($url)->title);
return $title;
}

/**
* Retrieves the description of embed url
* @param - $url: the url of the "player"
* @return - string
*
**/
public function getDescription($url) {
$url_parts = parse_url($url);

$description = $this->cleanUrl($this->getInfo($url)->description);
return $description;
}

/**
* Retrieves the type of embed url
* @param - $url: the url of the "player"
* @return - string
*
**/
public function getType($url) {
$url_parts = parse_url($url);

$type = $this->cleanUrl($this->getInfo($url)->type);
return $type;
}

/**
* Retrieves the aspect ratio of embed url
* @param - $url: the url of the "player"
* @return - string
*
**/
public function getAspectRatio($url) {
$url_parts = parse_url($url);

$aspectRatio = $this->cleanUrl($this->getInfo($url)->aspectRatio);
return $aspectRatio;
}

/**
* Retrieves the provider of the embed url
* @param - $url: the url of the "player"
* @return - string
*
**/
public function getProviderName($url) {
$url_parts = parse_url($url);

$providerName = $this->cleanUrl($this->getInfo($url)->providerName);
return $providerName;
}

private function cleanUrl($url) {
$stripped = preg_replace( '/^https?:/', '', $url );
return $stripped;
Expand Down
55 changes: 55 additions & 0 deletions src/variables/VideoEmbedderVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,59 @@ public function getVideoThumbnail($url) {
return Template::raw(VideoEmbedder::$plugin->service->getVideoThumbnail($url));
}

/**
* Retrieves the title of the embed url
* @param - $url: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
public function getTitle($url) {
return Template::raw(VideoEmbedder::$plugin->service->getTitle($url));
}

/**
* Retrieves the description of the embed from url
* @param - $url: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
public function getDescription($url) {
return Template::raw(VideoEmbedder::$plugin->service->getDescription($url));
}

/**
* Retrieves the type of embed from url
* @param - $url: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
public function getType($url) {
return Template::raw(VideoEmbedder::$plugin->service->getType($url));
}

/**
* Retrieves the aspect ratio of embed url
* @param - $url: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
public function getAspectRatio($url) {
return Template::raw(VideoEmbedder::$plugin->service->getAspectRatio($url));
}

/**
* Retrieves the provider of the embed url
* @param - $url: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
public function getProviderName($url) {
return Template::raw(VideoEmbedder::$plugin->service->getProviderName($url));
}

}

0 comments on commit 92aa17a

Please sign in to comment.