mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 07:21:50 +08:00
allow ogg to be used for previews
This commit is contained in:
parent
4d27499108
commit
78fe7062dc
3
app.py
3
app.py
@ -121,7 +121,8 @@ def get_config(credentials=False):
|
|||||||
'assets_baseurl': config.ASSETS_BASEURL,
|
'assets_baseurl': config.ASSETS_BASEURL,
|
||||||
'email': config.EMAIL,
|
'email': config.EMAIL,
|
||||||
'accounts': config.ACCOUNTS,
|
'accounts': config.ACCOUNTS,
|
||||||
'custom_js': config.CUSTOM_JS
|
'custom_js': config.CUSTOM_JS,
|
||||||
|
'preview_type': config.PREVIEW_TYPE or 'mp3'
|
||||||
}
|
}
|
||||||
if credentials:
|
if credentials:
|
||||||
min_level = config.GOOGLE_CREDENTIALS['min_level'] or 0
|
min_level = config.GOOGLE_CREDENTIALS['min_level'] or 0
|
||||||
|
@ -13,6 +13,9 @@ ACCOUNTS = True
|
|||||||
# Custom JavaScript file to load with the simulator.
|
# Custom JavaScript file to load with the simulator.
|
||||||
CUSTOM_JS = ''
|
CUSTOM_JS = ''
|
||||||
|
|
||||||
|
# Filetype to use for song previews. (mp3/ogg)
|
||||||
|
PREVIEW_TYPE = 'mp3'
|
||||||
|
|
||||||
# MongoDB server settings.
|
# MongoDB server settings.
|
||||||
MONGO = {
|
MONGO = {
|
||||||
'host': ['127.0.0.1:27017'],
|
'host': ['127.0.0.1:27017'],
|
||||||
|
@ -167,7 +167,7 @@ class Loader{
|
|||||||
song.lyricsFile = new RemoteFile(directory + "main.vtt")
|
song.lyricsFile = new RemoteFile(directory + "main.vtt")
|
||||||
}
|
}
|
||||||
if(song.preview > 0){
|
if(song.preview > 0){
|
||||||
song.previewMusic = new RemoteFile(directory + "preview.mp3")
|
song.previewMusic = new RemoteFile(directory + "preview." + gameConfig.preview_type)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
assets.songsDefault = songs
|
assets.songsDefault = songs
|
||||||
|
38
tools/generate_previews.py
Executable file
38
tools/generate_previews.py
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# .ogg preview generator for use when app and songs are on two different machines
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import requests
|
||||||
|
import os.path
|
||||||
|
from ffmpy import FFmpeg
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Generate song previews.')
|
||||||
|
parser.add_argument('site', help='Instance URL, eg. https://taiko.bui.pm')
|
||||||
|
parser.add_argument('song_dir', help='Path to songs directory, eg. /srv/taiko/public/taiko/songs')
|
||||||
|
parser.add_argument('--overwrite', action='store_true', help='Overwrite existing previews')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
songs = requests.get('{}/api/songs'.format(args.site)).json()
|
||||||
|
for i, song in enumerate(songs):
|
||||||
|
print('{}/{} {} (id: {})'.format(i + 1, len(songs), song['title'], song['id']))
|
||||||
|
|
||||||
|
song_path = '{}/{}/main.{}'.format(args.song_dir, song['id'], song['music_type'] if 'music_type' in song else 'mp3')
|
||||||
|
prev_path = '{}/{}/preview.ogg'.format(args.song_dir, song['id'])
|
||||||
|
|
||||||
|
if os.path.isfile(song_path):
|
||||||
|
if not os.path.isfile(prev_path) or args.overwrite:
|
||||||
|
if not song['preview'] or song['preview'] <= 0:
|
||||||
|
print('Skipping due to no preview')
|
||||||
|
continue
|
||||||
|
|
||||||
|
print('Making preview.ogg')
|
||||||
|
ff = FFmpeg(inputs={song_path: '-ss %s' % song['preview']},
|
||||||
|
outputs={prev_path: '-codec:a libvorbis -b:a 64k -ar 32000 -y -loglevel panic'})
|
||||||
|
ff.run()
|
||||||
|
else:
|
||||||
|
print('Preview already exists')
|
||||||
|
else:
|
||||||
|
print('song file not found')
|
Loading…
Reference in New Issue
Block a user