def save(self, *args, **kwargs):
        """
        Save and check if we can recognize what type of iframe it is (from what service)
        so we can for example add thumbnail automaticly
        """

        # TODO: make it nice easy to extend and so on...
        if not self.thumbnail:
            t = self.iframe_type
            if t == IFRAME_VIMEO:
                vimeo = VimeoBackend(self.code)
                thumbnail = vimeo.get_thumbnail_url()
                file_name = thumbnail.split('/')[-1]
                self.thumbnail = self.download_thumbnail(thumbnail, file_name, 'vimeo_thumbnails')
            elif t == IFRAME_DAILYMOTION:
                thumbnail = self.iframe_src.replace('embed', 'thumbnail')
                file_name = thumbnail.split('/')[-1] + '.jpg'
                self.thumbnail = self.download_thumbnail(thumbnail, file_name, 'dailymontion_thumbnails')


        super(IFrame, self).save(*args, **kwargs)
Ejemplo n.º 2
0
 def test_get_thumbnail_url(self):
     backend = VimeoBackend('http://vimeo.com/72304002')
     self.assertEqual(backend.get_thumbnail_url(),
                      'http://i.vimeocdn.com/video/446150690_640.jpg')
Ejemplo n.º 3
0
 def test_get_thumbnail_url(self):
     backend = VimeoBackend("https://vimeo.com/72304002")
     self.assertEqual(
         backend.get_thumbnail_url(),
         "https://i.vimeocdn.com/video/446150690-9621b882540b53788eaa36ef8e303d4e06fc40af3d27918b7f561bb44ed971dc-d_640",
     )