소스 검색

Inclusion d'une librairie permettant la récupération de videos sur les sites type youtube.

bastien 12 년 전
부모
커밋
45483ccf05

+ 1 - 1
src/Muzich/CoreBundle/Controller/CoreController.php 파일 보기

@@ -95,7 +95,7 @@ class CoreController extends Controller
95 95
         $data = $form->getData();
96 96
         $element = new Element();
97 97
         
98
-        $factory = new ElementFactory($element, $em);
98
+        $factory = new ElementFactory($element, $em, $this->container);
99 99
         $factory->proceed($data, $user);
100 100
         
101 101
         $em->persist($element);

+ 33 - 9
src/Muzich/CoreBundle/ElementFactory/ElementFactory.php 파일 보기

@@ -5,6 +5,7 @@ namespace Muzich\CoreBundle\ElementFactory;
5 5
 use Muzich\CoreBundle\Entity\Element;
6 6
 use Muzich\CoreBundle\Entity\User;
7 7
 use Doctrine\ORM\EntityManager;
8
+use Symfony\Component\DependencyInjection\Container;
8 9
 
9 10
 use Muzich\CoreBundle\ElementFactory\Site\YoutubeFactory;
10 11
 
@@ -17,14 +18,15 @@ class ElementFactory
17 18
 {
18 19
   
19 20
   protected $types = array(
20
-    'youtube.com'    => 'YoutubeFactory', 
21
-    'soundcloud.com' => 'SoundCloudFactory', 
22
-    'son2teuf.org'   => 'Son2TeufFactory', 
23
-    'jamendo.com'    => 'JamendoFactory'
21
+    'youtube.com', 
22
+    'soundcloud.com', 
23
+    'son2teuf.org', 
24
+    'jamendo.com'
24 25
   );
25 26
   
26 27
   protected $em;
27 28
   protected $element;
29
+  protected $container;
28 30
   
29 31
   /**
30 32
    * Procédure chargé de retourner des information destiné au 
@@ -42,10 +44,11 @@ class ElementFactory
42 44
     );
43 45
   }
44 46
   
45
-  public function __construct(Element $element, EntityManager $em)
47
+  public function __construct(Element $element, EntityManager $em, Container $container)
46 48
   {
47 49
     $this->element = $element;
48 50
     $this->em = $em;
51
+    $this->container = $container;
49 52
     
50 53
     $evm = new \Doctrine\Common\EventManager();
51 54
     $timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
@@ -105,13 +108,34 @@ class ElementFactory
105 108
   
106 109
     if ($this->element->getType())
107 110
     {
108
-      $factory_name = $this->types[$this->element->getType()->getId()];
109
-      
110
-      $site_factory = new YoutubeFactory($this->element);
111
-      $this->element->getEmbed($site_factory->getEmbedCode());
111
+      $site_factory = $this->getFactory();
112
+      $this->element->setEmbed($site_factory->getEmbedCode());
112 113
     }
113 114
     
114 115
   }
116
+  
117
+  protected function getFactory()
118
+  { 
119
+    switch ($this->element->getType()->getId())
120
+    {
121
+      case 'youtube.com':
122
+        return new YoutubeFactory($this->element, $this->container);
123
+      break;
124
+      case 'soundcloud.com':
125
+        return new SoundCloudFactory($this->element, $this->container);
126
+      break;
127
+      case 'son2teuf.org':
128
+        return new Son2TeufFactory($this->element, $this->container);
129
+      break;
130
+      case 'jamendo.com':
131
+        return new JamendoFactory($this->element, $this->container);
132
+      break;
133
+    
134
+      default:
135
+        throw new Exception("La Factory n'est pas connu pour ce type.");
136
+      break;
137
+    }
138
+  }
115 139
     
116 140
 }
117 141
 

+ 0 - 16
src/Muzich/CoreBundle/ElementFactory/Site/FactoryInterface.php 파일 보기

@@ -1,16 +0,0 @@
1
-<?php
2
-
3
-namespace Muzich\CoreBundle\ElementFactory\Site;
4
-
5
-use Muzich\CoreBundle\Entity\Element;
6
-
7
-interface FactoryInterface
8
-{
9
-  
10
-  public function __construct(Element $element);
11
-  
12
-  public function getEmbedCode();
13
-  
14
-}
15
-
16
-?>

+ 3 - 1
src/Muzich/CoreBundle/ElementFactory/Site/YoutubeFactory.php 파일 보기

@@ -2,12 +2,14 @@
2 2
 
3 3
 namespace Muzich\CoreBundle\ElementFactory\Site;
4 4
 
5
+use Muzich\CoreBundle\ElementFactory\Site\base\VideoSiteFactory;
6
+
5 7
 /**
6 8
  * 
7 9
  *
8 10
  * @author bux
9 11
  */
10
-class YoutubeFactory extends BaseFactory
12
+class YoutubeFactory extends VideoSiteFactory
11 13
 {
12 14
   
13 15
 }

src/Muzich/CoreBundle/ElementFactory/Site/BaseFactory.php → src/Muzich/CoreBundle/ElementFactory/Site/base/BaseFactory.php 파일 보기

@@ -1,8 +1,10 @@
1 1
 <?php
2 2
 
3
-namespace Muzich\CoreBundle\ElementFactory\Site;
3
+namespace Muzich\CoreBundle\ElementFactory\Site\base;
4 4
 
5 5
 use Muzich\CoreBundle\Entity\Element;
6
+use Symfony\Component\DependencyInjection\Container;
7
+use \Exception;
6 8
 
7 9
 /**
8 10
  *
@@ -13,7 +15,7 @@ class BaseFactory implements FactoryInterface
13 15
   
14 16
   protected $element;
15 17
   
16
-  public function __construct(Element $element)
18
+  public function __construct(Element $element, Container $container)
17 19
   {
18 20
     $this->element = $element;
19 21
   }

+ 17 - 0
src/Muzich/CoreBundle/ElementFactory/Site/base/FactoryInterface.php 파일 보기

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\ElementFactory\Site\base;
4
+
5
+use Muzich\CoreBundle\Entity\Element;
6
+use Symfony\Component\DependencyInjection\Container;
7
+
8
+interface FactoryInterface
9
+{
10
+  
11
+  public function __construct(Element $element, Container $container);
12
+  
13
+  public function getEmbedCode();
14
+  
15
+}
16
+
17
+?>

+ 50 - 0
src/Muzich/CoreBundle/ElementFactory/Site/base/VideoSiteFactory.php 파일 보기

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\ElementFactory\Site\base;
4
+
5
+use Muzich\CoreBundle\Entity\Element;
6
+use Symfony\Component\DependencyInjection\Container;
7
+use Muzich\CoreBundle\ElementFactory\Site\base\BaseFactory;
8
+use Muzich\CoreBundle\ElementFactory\lib\VideoEmbed;
9
+
10
+/**
11
+ * 
12
+ *
13
+ * @author bux
14
+ */
15
+class VideoSiteFactory extends BaseFactory
16
+{
17
+  
18
+  protected $video_engine = null;
19
+  
20
+  public function __construct(Element $element, Container $container)
21
+  {
22
+    parent::__construct($element, $container);
23
+    
24
+    // Configuration de VideoEmbed
25
+    define('SITEBASE', $container->getParameter('sitebase'));
26
+    define('VIDEO_EMBED_CONFIG_FILE', SITEBASE.$container->getParameter('video_embed_config_file'));
27
+    //to activate debug mode and false for production usage. it will write 
28
+    //to a log file when something goes wrong but should not produce 
29
+    //exceptions in production enviroment
30
+    define('DEBUG', $container->getParameter('video_embed_debug')); 
31
+    
32
+    try {
33
+      $this->video_engine =  new VideoEmbed($this->element->getUrl());
34
+    } catch (Exception $exc) {
35
+      
36
+    }
37
+  }
38
+  
39
+  public function getEmbedCode()
40
+  {
41
+    if ($this->video_engine)
42
+    {
43
+      return $this->video_engine->embed;
44
+    }
45
+    return null;
46
+  }
47
+  
48
+}
49
+
50
+?>

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1049 - 0
src/Muzich/CoreBundle/ElementFactory/lib/Spyc.php


+ 362 - 0
src/Muzich/CoreBundle/ElementFactory/lib/VideoEmbed.php 파일 보기

@@ -0,0 +1,362 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\ElementFactory\lib;
4
+
5
+//require_once (SITEBASE . '/src/Muzich/CoreBundle/ElementFactory/lib/spyc.php');
6
+use Muzich\CoreBundle\ElementFactory\lib\Spyc;
7
+use \Exception;
8
+
9
+/**
10
+* Copyright (c) 2008, AF83
11
+*   All rights reserved.
12
+*
13
+*   Redistribution and use in source and binary forms, with or without modification,
14
+*   are permitted provided that the following conditions are met:
15
+*
16
+*   1° Redistributions of source code must retain the above copyright notice,
17
+*   this list of conditions and the following disclaimer.
18
+*
19
+*   2° Redistributions in binary form must reproduce the above copyright notice,
20
+*   this list of conditions and the following disclaimer in the documentation
21
+*   and/or other materials provided with the distribution.
22
+*
23
+*   3° Neither the name of AF83 nor the names of its contributors may be used
24
+*   to endorse or promote products derived from this software without specific
25
+*   prior written permission.
26
+*
27
+*   THIS SOFTWARE IS PROVIDED BY THE COMPANY AF83 AND CONTRIBUTORS "AS IS"
28
+*   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
29
+*   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30
+*   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
31
+*   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32
+*   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33
+*   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34
+*   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
35
+*   OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36
+*   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37
+*   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
+*
39
+* @copyright 2008 AF83 http://dev.af83.com
40
+* @author Ori Pekelman
41
+* @license BSD License (3 Clause) http://www.opensource.org/licenses/bsd-license.php
42
+* @package Video
43
+* @version $Id$
44
+* @access public
45
+* @todo thumbnails should be cached locally
46
+*
47
+* VideoEmbed class  can be used to safely and cleanly embed videos from different sources
48
+*
49
+* The different sources are configured in the video_embed.yaml file
50
+*
51
+* NB: The embed code may be also a url
52
+*
53
+* Usage: set the configuration variables (refer to readme for details):
54
+*  VIDEO_EMBED_CONFIG_FILE -- path of video embed config file
55
+*
56
+*                     $videoEmbed = new VideoEmbed($embed); optional width and height may be passed to the constructor
57
+*                      //print($videoEmbed->embed);
58
+*                      $videoEmbed->width = 240; // resize
59
+*                      $videoEmbed->height = 120;
60
+*                      //print($videoEmbed->embed);
61
+*                      //print($videoEmbed->thumb);
62
+
63
+*
64
+* This class requires the SpyC library to read the cobnfiguration file. please adjust the path of the include on the first line of this file
65
+* The video services are configured in the configuration file (video_embed.conf.inc), example for youtube google and daily motion:
66
+*/
67
+
68
+class VideoEmbed {
69
+    private $_video_embed_conf = array();
70
+    private $_embedSource;
71
+    private $_embed;
72
+    private $_id;
73
+    private $_type;
74
+    private $_thumb;
75
+    private $_url;
76
+    private $_width;
77
+    private $_height;
78
+    private $_readOnly = array ('thumb', 'url', 'id', 'type');
79
+    private $_readWrite = array ('width', 'height', 'embed');
80
+
81
+    /**
82
+    * VideoEmbed::__construct() Only embed is mandatory
83
+    *
84
+    * @param mixed $embed
85
+    * @param mixed $width
86
+    * @param mixed $height
87
+    */
88
+    function __construct($embed, $width = null, $height = null)
89
+    {
90
+        // load configuration
91
+//        if (!class_exists('Spyc')) {
92
+//            throw new exception ('Could not find SpyC library ');
93
+//        }
94
+            
95
+        $this->_video_embed_conf = Spyc::YAMLLoad(VIDEO_EMBED_CONFIG_FILE);
96
+        
97
+        if (!$this->_video_embed_conf) {
98
+            debug_log ("Could not read configruation file or config file empty  " . SITE_BASE . VIDEO_EMBED_CONFIG_FILE);
99
+            if (DEBUG) {
100
+                throw new exception ("Could not read configruation file or config file empty " . SITE_BASE . VIDEO_EMBED_CONFIG_FILE);
101
+            }
102
+        }
103
+
104
+        if (!$embed) {
105
+            debug_log ('This must be instantiated with a non empty embed code');
106
+            if (DEBUG) {
107
+                throw new exception ('This must be instantiated with a non empty embed code');
108
+            }
109
+        }
110
+        // load arguments
111
+        $this->_embedSource = $embed;
112
+        $this->_width = $width?$width: $this->_video_embed_conf['defaultWidth'];
113
+        $this->_height = $height?$height:$this->_video_embed_conf['defaultHeight'];
114
+
115
+        $this->setup();
116
+    }
117
+    /**
118
+    * VideoEmbed::__set() Make some variables read only
119
+    *
120
+    * @param mixed $n
121
+    * @param mixed $val
122
+    * @return
123
+    */
124
+    function __set($n, $val)
125
+    {
126
+        if (in_array($n, $this->_readOnly)) {
127
+            debug_log ("Trying to set a read only property $n $val");
128
+            if (DEBUG) {
129
+                throw new exception ("Trying to set  a read only property" . "$n $val");
130
+            }
131
+            return false;
132
+        } elseif (in_array($n, $this->_readWrite)) {
133
+            if ($n == "embed") {
134
+                $property = '_embedSource';
135
+            } else $property = "_" . $n;
136
+
137
+            $this->$property = $val;
138
+            $this->setup(); // recalculate stuff if we changed a RW  property
139
+            return true;
140
+        }
141
+        return false;
142
+    }
143
+
144
+    /**
145
+    * VideoEmbed::__get()
146
+    *
147
+    * @param mixed $n
148
+    * @return
149
+    */
150
+    function __get($n)
151
+    {
152
+        if (in_array($n, array_merge($this->_readOnly, $this->_readWrite))) {
153
+            $propertyName = "_$n";
154
+            return $this->$propertyName;
155
+        } else {
156
+            debug_log('Trying to get a non readble property ' . $n);
157
+            if (DEBUG) {
158
+                throw new exception ('Trying to get a non readble property ' . $n);
159
+            }
160
+            return false;
161
+        }
162
+    }
163
+
164
+    /**
165
+    * VideoEmbed::setup()
166
+    *
167
+    * @return
168
+    */
169
+    private function setup ()
170
+    {      
171
+        if (!$this->video_embed_type()) {
172
+            //debug_log ('Could not get embed type :' . $this->_embedSource);
173
+            if (DEBUG) {
174
+                throw new exception ('Could not get embed type :' . $this->_embedSource);
175
+            }
176
+        }
177
+        if (!$this->video_embed_id()) {
178
+            //debug_log ('Could not get embed id :' . $this->_embedSource);
179
+            if (DEBUG) {
180
+                throw new exception ('Could not get embed id :' . $this->_embedSource);
181
+            }
182
+        }
183
+        if (!$this->video_embed_url()) {
184
+            //debug_log ('Problem generating embed url :' . $this->_embedSource);
185
+            if (DEBUG) {
186
+                throw new exception ('Problem generating embed url :' . $this->_embedSource);
187
+            }
188
+        }
189
+        if (!$this->video_embed_thumb()) {
190
+            //debug_log ('Problem generating thumb code :' . $this->_embedSource);
191
+            if (DEBUG) {
192
+                throw new exception ('Problem generatingembed code :' . $this->_embed);
193
+            }
194
+        }
195
+        if (!$this->video_embed_embed()) {
196
+            //debug_log ('Problem generating embed code :' . $this->_embedSource);
197
+            if (DEBUG) {
198
+                throw new exception ('Problem generatingembed code :' . $this->_embedSource);
199
+            }
200
+        }
201
+    }
202
+
203
+    /**
204
+    * VideoEmbed::video_emebd_type()
205
+    *
206
+    * @param mixed $embed
207
+    * @return
208
+    */
209
+    private function video_embed_type()
210
+    {
211
+        $type = null;
212
+        $this->_type = "";
213
+        foreach($this->_video_embed_conf['services'] as $serviceName => $config) {
214
+            if (strpos(strtolower($this->_embedSource), strtolower($config['urlPattern']))) {
215
+                $type = $serviceName;
216
+            }
217
+        }
218
+        if ($type) {
219
+            $this->_type = $type;
220
+            return $this->_type;
221
+        }
222
+        return false;
223
+    }
224
+
225
+    /**
226
+    * VideoEmbed::video_embed_id()
227
+    *
228
+    * @return
229
+    */
230
+    private function video_embed_id()
231
+    {
232
+        $this->_id = "";
233
+
234
+        if (($this->_type)) {
235
+            $regexp = $this->_video_embed_conf['services'][$this->_type]['extractPattern'];
236
+            preg_match($regexp, $this->_embedSource , $match);
237
+
238
+            if ($match[count($match)-1]) $this->_id = $match[count($match)-1];
239
+            return $this->_id;
240
+        }
241
+        return false;
242
+    }
243
+
244
+    /**
245
+    * VideoEmbed::video_embed_url()
246
+    *
247
+    * @return
248
+    */
249
+    private function video_embed_url()
250
+    {
251
+        $this->_url = "";
252
+        if ($this->_type) {
253
+            if ($this->_id) $url = sprintf($this->_video_embed_conf['services'][$this->_type]['embedUrlTemplate'], $this->_id);
254
+            if ($url) $this->_url = $url;
255
+            return $this->_url;
256
+        }
257
+        return false;
258
+    }
259
+
260
+    /**
261
+    * VideoEmbed::video_embed_thumb()
262
+    *
263
+    * @return
264
+    */
265
+    private function video_embed_thumb()
266
+    {
267
+        $conf = $this->_video_embed_conf['services'][$this->_type]; // just here for readability
268
+        $this->_thumb = "";
269
+        if ($this->_type && $this->_id) {
270
+            if (isset($conf['thumbnailUrlExtractPattern'])) { // if we need to parse the response:
271
+                $thumburl = $this->extractThumbUrl($conf['thumbnailUrlTemplate'], $conf['thumbnailUrlExtractPattern']);
272
+            } else $thumburl = sprintf($conf['thumbnailUrlTemplate'], $this->_id);
273
+
274
+            if ($thumburl) $this->_thumb = $thumburl;
275
+            return $this->_thumb;
276
+        }
277
+        return false;
278
+    }
279
+
280
+    /**
281
+    * VideoEmbed::video_embed_embed()
282
+    *
283
+    * @param mixed $width
284
+    * @param mixed $height
285
+    * @return
286
+    */
287
+    private function video_embed_embed()
288
+    {
289
+        if ($this->_type) {
290
+            $template = isset($this->_video_embed_conf['services'][$this->_type]['embedTemplate']) ? $this->_video_embed_conf['services'][$this->_type]['embedTemplate']:$this->_video_embed_conf['embedTemplate'];
291
+            if ($template && $this->_url) {
292
+                $width = $this->_width?$this->_width:$this->_video_embed_conf['services'][$video_type]['defaultWidth'];
293
+                $height = $this->_height?$this->_height:$this->_video_embed_conf['services'][$video_type]['defaultHeight'];
294
+                $embed = sprintf($template, $this->_url, $width, $height);
295
+                if ($embed) $this->_embed = $embed;
296
+                return $this->_embed;
297
+            }
298
+        }
299
+
300
+        return false;
301
+    }
302
+    /**
303
+    * extractThumbUrl()
304
+    *
305
+    * @param mixed $url
306
+    * @param mixed $videoid
307
+    * @param mixed $extractPattern
308
+    * @return
309
+    */
310
+    private function extractThumbUrl($url, $extractPattern)
311
+    {
312
+        $vrss = file_get_contents(sprintf($url, $this->_id));
313
+        if (!empty($vrss)) {
314
+            preg_match($extractPattern, $vrss, $thumbnail_array);
315
+            $thumbnail = $thumbnail_array[1];
316
+            // Remove amp;
317
+            $thumbnail = str_replace('amp;', '', $thumbnail);
318
+        }
319
+
320
+        return $thumbnail;
321
+    }
322
+}
323
+
324
+/**
325
+* test_VideoEmbed() test all is well
326
+*
327
+* @return
328
+*/
329
+function test_VideoEmbed()
330
+{
331
+    $embeds[] = '<div><object width="420" height="365"><param name="movie" value="http://www.dailymotion.com/swf/x3wq9a&v3=1&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3wq9a&v3=1&related=0" type="application/x-shockwave-flash" width="420" height="365" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3wq9a_defi-decorer-les-camions-de-pq_fun">Defi: décorer les camions de PQ</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/gonzaguetv">gonzaguetv</a></i></div>';
332
+    $embeds[] = '<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/1mXh_tyLlAY&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/1mXh_tyLlAY&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
333
+    $embeds[] = '<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-1182786924290841590&hl=fr" flashvars=""> </embed>';
334
+    foreach($embeds as $embed) {
335
+        $videoEmbed = new VideoEmbed($embed, 420, 365);
336
+        
337
+        // Mise en commentaire pour opasser le pre-commit:
338
+        
339
+//        echo "<h2> Type:</h2>\n";
340
+//        print ($videoEmbed->type);
341
+//        echo "<h2> ID:</h2>\n";
342
+//        print($videoEmbed->id);
343
+//        echo "<h2> Video Url:</h2>\n";
344
+//        print($videoEmbed->url);
345
+//        echo "<h2> Embed:</h2>\n";
346
+//        print($videoEmbed->embed);
347
+//        echo "<h2> Embed resized:</h2>\n";
348
+//        $videoEmbed->width = 240;
349
+//        $videoEmbed->height = 120;
350
+//        print($videoEmbed->embed);
351
+//        echo "<h2> thumb url:</h2>\n";
352
+//        print($videoEmbed->thumb);
353
+//        echo "<h2> thumb image:</h2>\n";
354
+//        print('<img src="' . $videoEmbed->thumb . '" />');
355
+        
356
+        
357
+        // this should fail
358
+        // $videoEmbed->thumb = "qsdqsdsq";
359
+        // this should fail
360
+        // print('<img src="' . $videoEmbed->image . '" />');
361
+    }
362
+}

+ 28 - 0
src/Muzich/CoreBundle/Resources/config/video_embed.yaml 파일 보기

@@ -0,0 +1,28 @@
1
+---
2
+embedTemplate: <object width="%2$s" height="%3$s" ><param name="movie" value="%1$s"></param><param name="wmode" value="transparent"></param><embed src="%1$s" type="application/x-shockwave-flash" wmode="transparent" width="%2$s" height="%3$s"></embed></object>
3
+defaultWidth: 425
4
+defaultHeight: 350
5
+services:
6
+    youtube:
7
+        urlPattern: youtube.com
8
+        embedUrlTemplate: http://www.youtube.com/v/%1$s&rel=1
9
+        thumbnailUrlTemplate: http://i.ytimg.com/vi/%1$s/default.jpg
10
+        extractPattern: /youtube\.com\/(v\/|watch\?v=)([\w\-]+)/
11
+        apiUrl: http://www.youtube.com/api2_rest
12
+        defaultWidth: 425
13
+        defaultHeight: 350
14
+    google:
15
+        urlPattern: video.google
16
+        extractPattern: /docid=([^&]*)/i
17
+        embedUrlTemplate: http://video.google.com/googleplayer.swf?docId=%1$s
18
+        thumbnailUrlTemplate: http://video.google.com/videofeed?docid=%s
19
+        thumbnailUrlExtractPattern: '/<media:thumbnail url="([^"]+)/'
20
+        defaultWidth: 400
21
+        defaultHeight: 326
22
+    dailymotion:
23
+        urlPattern: dailymotion.com
24
+        embedUrlTemplate: http://www.dailymotion.com/swf/%1$s/
25
+        thumbnailUrlTemplate: http://www.dailymotion.com/thumbnail/160x120/video/%1$s/
26
+        extractPattern: '#/(video|swf)/([a-zA-Z0-9]+)[^a-zA-Z0-9]#'
27
+        defaultWidth: 425
28
+        defaultHeight: 350

+ 6 - 0
src/Muzich/CoreBundle/Resources/views/SearchElement/default.html.twig 파일 보기

@@ -14,6 +14,12 @@
14 14
           {% endfor %} 
15 15
         </ul>
16 16
         
17
+        {% if element.embed %}
18
+          {% autoescape false %}
19
+            {{ element.embed }}
20
+          {% endautoescape %}
21
+        {% endif %}
22
+        
17 23
     </li>
18 24
   {% endfor %} 
19 25
 </ul>