Commit 1 of 2:
2644fd023a
Video Functionalities
next
whole branch
Review threads live on the whole diff, not on one commit, so
none are shown here - a thread's line means something in the
branch's final form, and painting it into an intermediate
step would put it on code it is not about.
src/Client.php modified +12 -1 Changes to src/Client.php ⋯ 3 lines Show the 3 lines above this hunk @@ -4,7 +4,8 @@ namespace Meema\MeemaClient; 4 4 5 5 use Dotenv \ Dotenv ; 6 6 use GuzzleHttp \ Client as GuzzleClient ; 7 - use Meema \ MeemaClient \ Function \ Image ; 7 + use Meema \ MeemaClient \ Functions \ Image ; 8 + use Meema \ MeemaClient \ Functions \ Video ; 8 9 use Meema \ MeemaClient \ Models \ Favorite ; 9 10 use Meema \ MeemaClient \ Models \ Folder ; 10 11 use Meema \ MeemaClient \ Models \ Media ; ⋯ 159 lines Show the 159 lines above this hunk @@ -170,6 +171,16 @@ class Client 170 171 return new Image ( $this ) ; 171 172 } 172 173 174 + 175 + 176 + 177 + 178 + 179 + public function videos ( ) : Video 180 + { 181 + return new Video ( $this ) ; 182 + } 183 + 173 184 174 185 175 186
src/Functions/Image.php modified +3 -31
src/Functions/Video.php modified +129 -0 Changes to src/Functions/Video.php @@ -0,0 +1,129 @@ 1 + < ? php 2 + 3 + namespace Meema \ MeemaClient \ Functions ; 4 + 5 + use Meema \ MeemaClient \ Client ; 6 + use Meema \ MeemaClient \ Traits \ UrlResponse ; 7 + 8 + class Video 9 + { 10 + use UrlResponse ; 11 + 12 + 13 + 14 + 15 + protected $client ; 16 + 17 + 18 + 19 + 20 + protected $args = [ ] ; 21 + 22 + 23 + 24 + 25 + 26 + 27 + public function __construct ( Client $client ) 28 + { 29 + $this - > client = $client ; 30 + } 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + public function thumbnails ( $value ) 40 + { 41 + $this - > args = array_merge ( $this - > args , [ 'thumbnails' = > $value ] ) ; 42 + 43 + return $this ; 44 + } 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + public function hls ( $value ) 54 + { 55 + $this - > args = array_merge ( $this - > args , [ 'hls' = > $value ] ) ; 56 + 57 + return $this ; 58 + } 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + public function dash ( $value ) 68 + { 69 + $this - > args = array_merge ( $this - > args , [ 'dash' = > $value ] ) ; 70 + 71 + return $this ; 72 + } 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + public function poster ( $value ) 82 + { 83 + $this - > args = array_merge ( $this - > args , [ 'dash' = > $value ] ) ; 84 + 85 + return $this ; 86 + } 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + public function webvtt ( $value ) 96 + { 97 + $this - > args = array_merge ( $this - > args , [ 'webvtt' = > $value ] ) ; 98 + 99 + return $this ; 100 + } 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + public function format ( $value ) 110 + { 111 + $this - > args = array_merge ( $this - > args , [ 'format' = > $value ] ) ; 112 + 113 + return $this ; 114 + } 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + public function webOptimized ( $value ) 124 + { 125 + $this - > args = array_merge ( $this - > args , [ 'web-optimized' = > $value ] ) ; 126 + 127 + return $this ; 128 + } 129 + }
src/Traits/UrlResponse.php added +46 -0 Changes to src/Traits/UrlResponse.php @@ -0,0 +1,46 @@ 1 + < ? php 2 + 3 + namespace Meema \ MeemaClient \ Traits ; 4 + 5 + use GuzzleHttp \ Psr7 \ Utils ; 6 + 7 + trait UrlResponse 8 + { 9 + 10 + 11 + 12 + 13 + 14 + public function toUrl ( ) 15 + { 16 + $queryParams = '' ; 17 + 18 + $index = 0 ; 19 + 20 + foreach ( $this - > args as $key = > $param ) { 21 + $separator = '?' ; 22 + 23 + if ( $index ) { 24 + $separator = '&' ; 25 + } 26 + 27 + $queryParams . = "{$separator}{$key}={$param}" ; 28 + 29 + $index + + ; 30 + } 31 + 32 + return "https://dev-ops.mee.ma/glenn/1/5/people.jpg{$queryParams}" ; 33 + } 34 + 35 + 36 + 37 + 38 + 39 + 40 + public function toBuffer ( ) 41 + { 42 + $path = $this - > toUrl ( ) ; 43 + 44 + return Utils : : streamFor ( $path ) ; 45 + } 46 + }