def sync(self, info=None):
        if info == None:
            info = utils.ffmpeg_get_info(self.url)
        
        self.duration = info.get("duration")

        self.video_info_raw = info.get("video", "")
        self.video_codec = info.get("video_codec", "")
        self.width = info.get("width")
        self.height = info.get("height")
        self.framerate = info.get("fps")

        self.audio_info_raw = info.get("audio", "")
        self.audio_codec = info.get("audio_codec", "")
        self.audio_bits = info.get("audio_bits")
        self.audio_sampling_rate = info.get("audio_sampling_rate")
        self.audio_bitrate = info.get("audio_bitrate")
        self.audio_channels = info.get("audio_channels")
        
        meta = info.get("meta", {})
        self.artist = meta.get("artist", "")
        self.title = meta.get("title", "")
        self.date = meta.get("date", "")
        self.location = meta.get("location", "")
        self.copyright = meta.get("copyright", "")
        self.license = meta.get("license", "")
        self.contact = meta.get("contact", "")

        self.save()
        # request reindex (via signal)
        reindex_request.send(sender=self.__class__, instance=self)
 def get_or_create_from_url(cls, url, request=None, reload=False):
     try:
         ret = cls.objects.get(url=url)
         if reload: ret.sync()
         return ret, False
     except cls.DoesNotExist:
         info = utils.ffmpeg_get_info(url)
         if info:
             ret = Media.objects.create(url=url)
             ret.sync(info=info)
             return ret, True
         return None, False