make media_id an optional argument
This commit is contained in:
parent
11a99d787f
commit
842ba30529
@ -32,37 +32,38 @@ def reprocess_parser_setup(subparser):
|
|||||||
'--type', '-t',
|
'--type', '-t',
|
||||||
help="The type of media to be reprocessed such as 'video' or 'image'")
|
help="The type of media to be reprocessed such as 'video' or 'image'")
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'media_id',
|
'--media_id',
|
||||||
nargs='*',
|
nargs='*',
|
||||||
help="The media_entry id(s) you wish to reprocess.")
|
help="The media_entry id(s) you wish to reprocess.")
|
||||||
|
|
||||||
|
|
||||||
def _set_media_type(args):
|
def _set_media_type(args):
|
||||||
if len(args[0].media_id) == 1:
|
if args[0].media_id:
|
||||||
media_type = MediaEntry.query.filter_by(id=args[0].media_id[0])\
|
if len(args[0].media_id) == 1:
|
||||||
.first().media_type.split('.')[-1]
|
media_type = MediaEntry.query.filter_by(id=args[0].media_id[0])\
|
||||||
|
.first().media_type.split('.')[-1]
|
||||||
|
|
||||||
if not args[0].type:
|
if not args[0].type:
|
||||||
args[0].type = media_type
|
args[0].type = media_type
|
||||||
elif args[0].type != media_type:
|
elif args[0].type != media_type:
|
||||||
raise Exception(_('The --type that you set does not match the type'
|
raise Exception(_('The --type that you set does not match the type'
|
||||||
' of the given media_id.'))
|
' of the given media_id.'))
|
||||||
elif len(args[0].media_id) > 1:
|
elif len(args[0].media_id) > 1:
|
||||||
media_types = []
|
media_types = []
|
||||||
|
|
||||||
for id in args[0].media_id:
|
for id in args[0].media_id:
|
||||||
media_types.append(MediaEntry.query.filter_by(id=id).first()
|
media_types.append(MediaEntry.query.filter_by(id=id).first()
|
||||||
.media_type.split('.')[-1])
|
.media_type.split('.')[-1])
|
||||||
for type in media_types:
|
for type in media_types:
|
||||||
if media_types[0] != type:
|
if media_types[0] != type:
|
||||||
raise Exception((u'You cannot reprocess different media_types'
|
raise Exception((u'You cannot reprocess different media_types'
|
||||||
' at the same time.'))
|
' at the same time.'))
|
||||||
|
|
||||||
if not args[0].type:
|
if not args[0].type:
|
||||||
args[0].type = media_types[0]
|
args[0].type = media_types[0]
|
||||||
elif args[0].type != media_types[0]:
|
elif args[0].type != media_types[0]:
|
||||||
raise Exception(_('The --type that you set does not match the type'
|
raise Exception(_('The --type that you set does not match the type'
|
||||||
' of the given media_ids.'))
|
' of the given media_ids.'))
|
||||||
|
|
||||||
|
|
||||||
def _reprocess_all(args):
|
def _reprocess_all(args):
|
||||||
@ -99,24 +100,25 @@ def _run_reprocessing(args):
|
|||||||
|
|
||||||
|
|
||||||
def _set_media_state(args):
|
def _set_media_state(args):
|
||||||
if len(args[0].media_id) == 1:
|
if args[0].media_id:
|
||||||
args[0].state = MediaEntry.query.filter_by(id=args[0].media_id[0])\
|
if len(args[0].media_id) == 1:
|
||||||
.first().state
|
args[0].state = MediaEntry.query.filter_by(id=args[0].media_id[0])\
|
||||||
|
.first().state
|
||||||
|
|
||||||
elif len(args[0].media_id) > 1:
|
elif len(args[0].media_id) > 1:
|
||||||
media_states = []
|
media_states = []
|
||||||
|
|
||||||
for id in args[0].media_id:
|
for id in args[0].media_id:
|
||||||
media_states.append(MediaEntry.query.filter_by(id=id).first()
|
media_states.append(MediaEntry.query.filter_by(id=id).first()
|
||||||
.state)
|
.state)
|
||||||
for state in media_states:
|
for state in media_states:
|
||||||
if state != media_states[0]:
|
if state != media_states[0]:
|
||||||
raise Exception(_('You can only reprocess media that is in the'
|
raise Exception(_('You can only reprocess media that is in the'
|
||||||
' same state.'))
|
' same state.'))
|
||||||
|
|
||||||
args[0].state = media_states[0]
|
args[0].state = media_states[0]
|
||||||
|
|
||||||
elif not args[0].state:
|
if not args[0].state:
|
||||||
args[0].state = 'processed'
|
args[0].state = 'processed'
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user