コード例 #1
0
ファイル: models.py プロジェクト: Gargaj/demozoo
	def save(self, *args, **kwargs):
		# certain link types are marked as always download links, or always external links,
		# regardless of where they are entered -
		# if this is one of those types, ensure that is_download_link is set appropriately
		if self.link_class in groklinks.PRODUCTION_DOWNLOAD_LINK_TYPES:
			self.is_download_link = True
		elif self.link_class in groklinks.PRODUCTION_EXTERNAL_LINK_TYPES:
			self.is_download_link = False

		should_fetch_embed_data = False

		if self._original_link_class != self.link_class or self._original_parameter != self.parameter:
			# link has changed - remove old embed data
			self.thumbnail_url = ''
			self.thumbnail_width = None
			self.thumbnail_height = None
			self.video_width = None
			self.video_height = None
			self.embed_data_last_fetch_time = None
			self.embed_data_last_error_time = None

			if self.link.supports_embed_data:
				should_fetch_embed_data = True

			self._original_link_class = self.link_class
			self._original_parameter = self.parameter

		super(ProductionLink, self).save(*args, **kwargs)

		if should_fetch_embed_data:
			from productions.tasks import fetch_production_link_embed_data
			fetch_production_link_embed_data.delay(self.pk)
コード例 #2
0
ファイル: models.py プロジェクト: rdavydov/demozoo
    def save(self, *args, **kwargs):
        # certain link types are marked as always download links, or always external links,
        # regardless of where they are entered -
        # if this is one of those types, ensure that is_download_link is set appropriately
        if self.link_class in groklinks.PRODUCTION_DOWNLOAD_LINK_TYPES:
            self.is_download_link = True
        elif self.link_class in groklinks.PRODUCTION_EXTERNAL_LINK_TYPES:
            self.is_download_link = False

        should_fetch_embed_data = False

        if self._original_link_class != self.link_class or self._original_parameter != self.parameter:
            # link has changed - remove old embed data
            self.thumbnail_url = ''
            self.thumbnail_width = None
            self.thumbnail_height = None
            self.video_width = None
            self.video_height = None
            self.embed_data_last_fetch_time = None
            self.embed_data_last_error_time = None

            if self.link.supports_embed_data:
                should_fetch_embed_data = True

            self._original_link_class = self.link_class
            self._original_parameter = self.parameter

        super(ProductionLink, self).save(*args, **kwargs)

        if should_fetch_embed_data:
            from productions.tasks import fetch_production_link_embed_data
            fetch_production_link_embed_data.delay(self.pk)
コード例 #3
0
    def handle(self, *args, **kwargs):
        link_types = [cls.__name__ for cls in EMBEDDABLE_PRODUCTION_LINK_TYPES]

        # order by embed_data_last_fetch_time desc to fetch null ones (never fetched) first
        prod_links = ProductionLink.objects.filter(
            link_class__in=link_types).filter(
                embed_data_last_fetch_time__isnull=True)

        for prod_link in prod_links:
            print("fetching embed data for %s" % prod_link.link)
            fetch_production_link_embed_data.delay(prod_link.id)
コード例 #4
0
    def handle(self, *args, **kwargs):
        link_types = [cls.__name__ for cls in EMBEDDABLE_PRODUCTION_LINK_TYPES]
        last_month = datetime.date.today() - datetime.timedelta(days=30)

        # order by embed_data_last_fetch_time desc to fetch null ones (never fetched) first
        prod_links = ProductionLink.objects.filter(
            link_class__in=link_types).exclude(
                embed_data_last_fetch_time__gt=last_month).exclude(
                    embed_data_last_error_time__gt=last_month).order_by(
                        '-embed_data_last_fetch_time')

        for prod_link in prod_links:
            print("fetching embed data for %s" % prod_link.link)
            fetch_production_link_embed_data.delay(prod_link.id)
コード例 #5
0
ファイル: fetch_embed_data.py プロジェクト: DannyCork/demozoo
	def handle_noargs(self, **options):
		link_types = [cls.__name__ for cls in EMBEDDABLE_PRODUCTION_LINK_TYPES]
		last_month = datetime.date.today() - datetime.timedelta(days=30)

		# order by embed_data_last_fetch_time desc to fetch null ones (never fetched) first
		prod_links = ProductionLink.objects.filter(
			link_class__in=link_types
		).exclude(
			embed_data_last_fetch_time__gt=last_month
		).exclude(
			embed_data_last_error_time__gt=last_month
		).order_by('-embed_data_last_fetch_time')

		for prod_link in prod_links:
			print "fetching embed data for %s" % prod_link.link
			fetch_production_link_embed_data.delay(prod_link.id)