getURL() public method

Get URL of video from URL of page.
public getURL ( string $url, string $format = null ) : string
$url string URL of page
$format string Format to use for the video
return string URL of video
Ejemplo n.º 1
0
 /**
  * Redirect to video file.
  *
  * @param Request  $request  PSR-7 request
  * @param Response $response PSR-7 response
  *
  * @return Response HTTP response
  */
 public function redirect(Request $request, Response $response)
 {
     $params = $request->getQueryParams();
     if (isset($params['url'])) {
         try {
             $url = $this->download->getURL($params['url'], $params['format']);
             return $response->withRedirect($url);
         } catch (\Exception $e) {
             $response->getBody()->write($e->getMessage());
             return $response->withHeader('Content-Type', 'text/plain');
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Test getURL function errors.
  *
  * @param string $url URL
  *
  * @return void
  * @expectedException Exception
  * @dataProvider      ErrorUrlProvider
  */
 public function testGetURLError($url)
 {
     $this->download->getURL($url);
 }
Ejemplo n.º 3
0
 /**
  * Redirect to video file
  * @return void
  */
 static function redirect()
 {
     global $app;
     if (isset($_GET["url"])) {
         try {
             $video = VideoDownload::getURL($_GET["url"]);
             $app->redirect($video['url']);
         } catch (\Exception $e) {
             $app->response->headers->set('Content-Type', 'text/plain');
             echo $e->getMessage();
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Test getURL function errors
  *
  * @param string $url URL
  *
  * @return            void
  * @expectedException Exception
  * @dataProvider      ErrorUrlProvider
  */
 public function testGetURLError($url)
 {
     $videoURL = VideoDownload::getURL($url);
 }