示例#1
0
def import_screenshot(production_id, janeway_id, url, suffix):
    blob = fetch_origin_url(url)
    sha1 = blob.sha1
    img = PILConvertibleImage(blob.as_io_buffer(), name_hint=blob.filename)
    basename = sha1[0:2] + '/' + sha1[2:4] + '/' + sha1[4:8] + '.jw' + str(
        janeway_id) + suffix + '.'

    screenshot = Screenshot(production_id=production_id,
                            data_source='janeway',
                            janeway_id=janeway_id,
                            janeway_suffix=suffix)
    upload_original(img, screenshot, basename, reduced_redundancy=False)
    upload_standard(img, screenshot, basename)
    upload_thumb(img, screenshot, basename)
    screenshot.save()
示例#2
0
def import_screenshot(production_id, janeway_id, url, suffix):
    blob = fetch_origin_url(url)
    sha1 = blob.sha1
    img = PILConvertibleImage(blob.as_io_buffer(), name_hint=blob.filename)
    basename = sha1[0:2] + '/' + sha1[2:4] + '/' + sha1[4:8] + '.jw' + str(
        janeway_id) + suffix + '.'

    screenshot = Screenshot(production_id=production_id,
                            data_source='janeway',
                            janeway_id=janeway_id,
                            janeway_suffix=suffix)
    upload_standard(img, screenshot, basename)
    upload_thumb(img, screenshot, basename)
    # leave upload_original until last to prevent things screwing up if the storage
    # closes the original file handle
    upload_original(img, screenshot, basename)
    screenshot.save()
示例#3
0
    def handle_noargs(self, **options):
        filetype_filter = Q(parameter__iendswith='.sap') | Q(
            parameter__iendswith='.sid') | Q(parameter__iendswith='.mod') | Q(
                parameter__iendswith='.s3m') | Q(
                    parameter__iendswith='.xm') | Q(parameter__iendswith='.it')
        links = ProductionLink.objects.filter(
            is_download_link=True,
            link_class__in=[
                'BaseUrl', 'AmigascneFile', 'SceneOrgFile', 'FujiologyFile',
                'UntergrundFile', 'PaduaOrgFile'
            ],
            production__supertype='music',
        ).filter(filetype_filter).exclude(
            parameter__istartswith='https://media.demozoo.org/'
        ).select_related('production')

        for prod_link in links:
            # see if this prod already has a playable link
            tracks, media = get_playable_track_data(prod_link.production)
            if tracks:
                # already playable
                continue

            print("prod %s: downloading from %s" %
                  (prod_link.production_id, prod_link.url))
            try:
                download = fetch_origin_url(prod_link.download_url)
                sha1 = download.sha1
                (basename, file_ext) = splitext(download.filename)

                filename = 'music/' + sha1[0:2] + '/' + sha1[
                    2:4] + '/' + slugify(basename) + file_ext
                new_url = upload_to_s3(download.as_io_buffer(),
                                       filename,
                                       file_ext,
                                       reduced_redundancy=True)
                ProductionLink.objects.create(production=prod_link.production,
                                              link_class='BaseUrl',
                                              parameter=new_url,
                                              is_download_link=True)
            except (urllib2.URLError, FileTooBig, timeout) as ex:
                pass

            time.sleep(5)
示例#4
0
	def handle_noargs(self, **options):
		filetype_filter = Q(parameter__iendswith='.sap') | Q(parameter__iendswith='.sid') | Q(parameter__iendswith='.mod') | Q(parameter__iendswith='.s3m') | Q(parameter__iendswith='.xm') | Q(parameter__iendswith='.it')
		links = ProductionLink.objects.filter(
			is_download_link=True,
			link_class__in=['BaseUrl', 'AmigascneFile', 'SceneOrgFile', 'FujiologyFile', 'UntergrundFile', 'PaduaOrgFile'],
			production__supertype='music',
		).filter(
			filetype_filter
		).exclude(
			parameter__istartswith='https://media.demozoo.org/'
		).select_related('production')

		for prod_link in links:
			# see if this prod already has a playable link
			tracks, media = get_playable_track_data(prod_link.production)
			if tracks:
				# already playable
				continue

			print("prod %s: downloading from %s" % (prod_link.production_id, prod_link.url))
			try:
				download = fetch_origin_url(prod_link.download_url)
				sha1 = download.sha1
				(basename, file_ext) = splitext(download.filename)

				filename = 'music/' + sha1[0:2] + '/' + sha1[2:4] + '/' + slugify(basename) + file_ext
				new_url = upload_to_s3(download.as_io_buffer(), filename, file_ext, reduced_redundancy=True)
				ProductionLink.objects.create(
					production=prod_link.production,
					link_class='BaseUrl', parameter=new_url,
					is_download_link=True
				)
			except (urllib2.URLError, FileTooBig, timeout) as ex:
				pass

			time.sleep(5)