コード例 #1
0
    def handle(self, *args, **options):

        soundtracks = (
            'Legend of Zelda: Skyward Sword',
            'Legend of Zelda: Twilight Princess',
            'Legend of Zelda: Wind Waker',
            'Legend of Zelda: Majora\'s Mask',
            'Legend of Zelda: Majora\'s Mask Orchestrated',
            'Legend of Zelda: Ocarina of Time',
            'Legend of Zelda: Ocarina of Time Orchestrated',
            'Legend of Zelda: Ocarina of Time Rearranged',
            'Super Mario Galaxy',
            'Super Mario 64',
            'Earthbound',
            'Grim Fandango',
            'Katamari Damacy',
        )

        Soundtrack.objects.all().delete()

        for title in soundtracks:

            filename = title_to_filename(title)
            soundtrack_path = path.join(settings.STATIC_ROOT, 'soundtracks', filename)
            soundtrack = Soundtrack(title=title, filename=filename)
            soundtrack.save()
            for song in glob(path.join(soundtrack_path, '*.mp3')):
                song_url = path.join(settings.STATIC_URL, 'soundtracks', soundtrack.filename, path.basename(song))
                title = EasyID3(song)['title'][0]
                Song(url=song_url, title=title, soundtrack=soundtrack).save()
            zip_filename = path.join(soundtrack_path, 'all.zip')
            zip_files = glob(path.join(soundtrack_path, '*.mp3'))
            zip(zip_filename, zip_files)
コード例 #2
0
    def handle(self, *args, **options):

        WallpaperGroup.objects.all().delete()

        group_paths = glob(
            path.join(settings.STATIC_ROOT, 'images', 'wallpapers', '*'))
        for group_path in group_paths:
            group = WallpaperGroup(filename=path.basename(group_path),
                                   title=open(
                                       path.join(group_path, 'title.txt'),
                                       'r').read())
            group.save()
            wallpapers = glob(path.join(group_path, '*.jpg'))
            for wallpaper in wallpapers:
                Wallpaper(filename=path.basename(wallpaper),
                          group=group).save()
            create_thumbnails(path.join('wallpapers', group.filename), 150,
                              100)
            zip(path.join(group_path, 'all.zip'), wallpapers)
コード例 #3
0
    def handle(self, *args, **options):

        WallpaperGroup.objects.all().delete()

        group_paths = glob(path.join(settings.STATIC_ROOT, 'images', 'wallpapers', '*'))
        for group_path in group_paths:
            group = WallpaperGroup(
                filename = path.basename(group_path),
                title = open(path.join(group_path, 'title.txt'), 'r').read()
            )
            group.save()
            wallpapers = glob(path.join(group_path, '*.jpg'))
            for wallpaper in wallpapers:
                Wallpaper(
                    filename = path.basename(wallpaper),
                    group = group
                ).save()
            create_thumbnails(path.join('wallpapers', group.filename), 150, 100)
            zip(path.join(group_path, 'all.zip'), wallpapers)
コード例 #4
0
    def handle(self, *args, **options):

        SheetGroup.objects.all().delete()

        groups = open(
            path.join(settings.TEMPLATE_DIRS[0], 'lists', 'sheets.txt'),
            'r').read().split('\n\n\n')
        for group in groups:
            sheets = group.split('\n')
            group = SheetGroup(title=sheets[0],
                               filename=title_to_filename(sheets[0]))
            group.save()
            group_path = path.join(settings.STATIC_ROOT, 'sheets',
                                   group.filename)
            sheets = sheets[2:]
            zips = {
                'sheets-classic': ([], '.pdf'),
                'sheets-labeled': ([], '-labels.pdf'),
                'midis': ([], '.mid'),
                'mp3s': ([], '.mp3'),
            }
            for sheet in sheets:
                title = sheet[:-4]
                filename = title_to_filename(title)
                Sheet(title=title,
                      url=path.join(group.url, filename),
                      group=group,
                      rating=sheet[-1:]).save()
                filepath = path.join(group_path, filename)
                for zip_group in zips:
                    zips[zip_group][0].append('%s%s' %
                                              (filepath, zips[zip_group][1]))

            if len(sheets) > 1:
                for zip_group in zips:
                    zip_filename = '%s.zip' % path.join(group_path, zip_group)
                    zip(zip_filename, zips[zip_group][0])
コード例 #5
0
ファイル: update-sheets.py プロジェクト: racheltwu/herbalcell
    def handle(self, *args, **options):

        SheetGroup.objects.all().delete()

        groups = open(path.join(settings.TEMPLATE_DIRS[0], 'lists', 'sheets.txt'), 'r').read().split('\n\n\n')
        for group in groups:
            sheets = group.split('\n')
            group = SheetGroup(
                title = sheets[0],
                filename = title_to_filename(sheets[0])
            )
            group.save()
            group_path = path.join(settings.STATIC_ROOT, 'sheets', group.filename)
            sheets = sheets[2:]
            zips = {
                'sheets-classic': ([], '.pdf'),
                'sheets-labeled': ([], '-labels.pdf'),
                'midis': ([], '.mid'),
                'mp3s': ([], '.mp3'),
            }
            for sheet in sheets:
                title = sheet[:-4]
                filename = title_to_filename(title)
                Sheet(
                    title = title,
                    url = path.join(group.url, filename),
                    group = group,
                    rating = sheet[-1:]
                ).save()
                filepath = path.join(group_path, filename)
                for zip_group in zips:
                    zips[zip_group][0].append('%s%s' % (filepath, zips[zip_group][1]))

            if len(sheets) > 1:
                for zip_group in zips:
                    zip_filename = '%s.zip' % path.join(group_path, zip_group)
                    zip(zip_filename, zips[zip_group][0])