more commandline component options

commandline options that existed before the redesign are now back
This commit is contained in:
tassaron 2017-06-22 22:23:04 -04:00
parent 49cda1bf3a
commit 3c903794e3
7 changed files with 74 additions and 35 deletions

View File

@ -2,6 +2,7 @@ from PyQt4 import QtCore
from PyQt4.QtCore import QSettings
import argparse
import os
import sys
import core
import video_thread
@ -22,14 +23,14 @@ class Command(QtCore.QObject):
description='Create a visualization for an audio file',
epilog='EXAMPLE COMMAND: main.py myvideotemplate.avp '
'-i ~/Music/song.mp3 -o ~/video.mp4 '
'-c 0 image ~/Pictures/thisWeeksPicture.jpg '
'-c 1 video "preset=My Logo" -c 2 vis classic')
'-c 0 image path=~/Pictures/thisWeeksPicture.jpg '
'-c 1 video "preset=My Logo" -c 2 vis layout=classic')
self.parser.add_argument(
'-i', '--input', metavar='SOUND',
help='input audio file', required=True)
help='input audio file')
self.parser.add_argument(
'-o', '--output', metavar='OUTPUT',
help='output video file', required=True)
help='output video file')
# optional arguments
self.parser.add_argument(
@ -71,7 +72,11 @@ class Command(QtCore.QObject):
for arg in args:
self.core.selectedComponents[i].command(arg)
self.createAudioVisualisation()
if self.args.input and self.args.output:
self.createAudioVisualisation()
elif 'help' not in sys.argv:
self.parser.print_help()
quit(1)
def createAudioVisualisation(self):
self.videoThread = QtCore.QThread(self)

View File

@ -73,7 +73,7 @@ class Component(QtCore.QObject):
print(
self.__doc__, 'Usage:\n'
'Open a preset for this component:\n'
' "preset=Preset Name"\n')
' "preset=Preset Name"')
self.commandHelp()
quit(0)

View File

@ -233,3 +233,14 @@ class Component(__base__.Component):
else:
self.page.lineEdit_color2.setText(RGBstring)
self.page.pushButton_color2.setStyleSheet(btnStyle)
def commandHelp(self):
print('Specify a color:\n color=255,255,255')
def command(self, arg):
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
if key == 'color':
self.page.lineEdit_color1.setText(arg)
return
super().command(arg)

View File

@ -94,18 +94,18 @@ class Component(__base__.Component):
self.update()
def command(self, arg):
if not arg.startswith('preset='):
if os.path.exists(arg):
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
if key == 'path' and os.path.exists(arg):
try:
Image.open(arg)
self.imagePath = arg
self.stretched = True
return True
self.page.lineEdit_image.setText(arg)
self.page.checkBox_stretch.setChecked(True)
return
except OSError as e:
print("Not a supported image format")
quit(1)
super().command(arg)
def commandHelp(self):
print('Give a complete filepath to an image to load that '
'image with default settings.')
print('Load an image:\n path=/filepath/to/image.png')

View File

@ -184,14 +184,21 @@ class Component(__base__.Component):
return im
def command(self, arg):
if not arg.startswith('preset='):
if arg == 'classic':
self.layout = 0; return
elif arg == 'split':
self.layout = 1; return
elif arg == 'bottom':
self.layout = 2; return
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
if key == 'color':
self.page.lineEdit_visColor.setText(arg)
return
elif key == 'layout':
if arg == 'classic':
self.page.comboBox_visLayout.setCurrentIndex(0)
elif arg == 'split':
self.page.comboBox_visLayout.setCurrentIndex(1)
elif arg == 'bottom':
self.page.comboBox_visLayout.setCurrentIndex(2)
return
super().command(arg)
def commandHelp(self):
print('Give a layout name: classic, split, or bottom')
print('Give a layout name:\n layout=[classic/split/bottom]')
print('Specify a color:\n color=255,255,255')

View File

@ -149,12 +149,28 @@ class Component(__base__.Component):
self.page.lineEdit_textColor.setText(RGBstring)
self.page.pushButton_textColor.setStyleSheet(btnStyle)
def commandHelp(self, arg):
print('Enter a string to use as centred white text. '
'Use quotes around the string to escape spaces.')
def commandHelp(self):
print('Enter a string to use as centred white text:')
print(' "title=User Error"')
print('Specify a text color:\n color=255,255,255')
print('Set custom x, y position:\n x=500 y=500')
def command(self, arg):
if not arg.startswith('preset='):
self.title = arg
return True
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
if key == 'color':
self.page.lineEdit_textColor.setText(arg)
return
elif key == 'size':
self.page.spinBox_fontSize.setValue(int(arg))
return
elif key == 'x':
self.page.spinBox_xTextAlign.setValue(int(arg))
return
elif key == 'y':
self.page.spinBox_yTextAlign.setValue(int(arg))
return
elif key == 'title':
self.page.lineEdit_title.setText(arg)
return
super().command(arg)

View File

@ -222,21 +222,21 @@ class Component(__base__.Component):
self.chunkSize = 4*width*height
def command(self, arg):
if not arg.startswith('preset='):
if os.path.exists(arg):
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
if key == 'path' and os.path.exists(arg):
if os.path.splitext(arg)[1] in self.core.videoFormats:
self.videoPath = arg
self.scale = 100
self.loopVideo = True
return True
self.page.lineEdit_video.setText(arg)
self.page.spinBox_scale.setValue(100)
self.page.checkBox_loop.setChecked(True)
return
else:
print("Not a supported video format")
quit(1)
super().command(arg)
def commandHelp(self):
print('Give a complete filepath to a video to load that '
'video with default settings.')
print('Load a video:\n path=/filepath/to/video.mp4')
def scale(scale, width, height, returntype=None):
width = (float(width) / 100.0) * float(scale)