mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-07 16:07:45 +02:00
2021-12-07 Fred Gleason <fredg@paravelsystems.com>
* Added an 'Import()' method to the 'rivwebpyapi' API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
09c880fefa
commit
61d3b9a19b
@ -22686,3 +22686,5 @@
|
|||||||
* Added an 'Export()' method to the 'rivwebpyapi' API.
|
* Added an 'Export()' method to the 'rivwebpyapi' API.
|
||||||
2021-12-07 Fred Gleason <fredg@paravelsystems.com>
|
2021-12-07 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Added an 'ExportPeaks()' method to the 'rivwebpyapi' API.
|
* Added an 'ExportPeaks()' method to the 'rivwebpyapi' API.
|
||||||
|
2021-12-07 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added an 'Import()' method to the 'rivwebpyapi' API.
|
||||||
|
@ -747,6 +747,84 @@ class rivwebpyapi(object):
|
|||||||
ret=ret+block
|
ret=ret+block
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def Import(self,filename,use_metadata,cart_number=0,cut_number=0,
|
||||||
|
channels=2,normalization_level=0,autotrim_level=0,
|
||||||
|
group_name='',title=''):
|
||||||
|
"""
|
||||||
|
Import audio into the audio store
|
||||||
|
|
||||||
|
Takes the following arguments:
|
||||||
|
|
||||||
|
filename - Name of the file containing audio to be imported
|
||||||
|
(string).
|
||||||
|
|
||||||
|
cart_number - The number of the desired cart, in the range
|
||||||
|
0 - 999999 (integer)
|
||||||
|
|
||||||
|
cut_number - The number of the desired cut, in the range
|
||||||
|
0 - 999 (integer)
|
||||||
|
|
||||||
|
use_metadata - Apply file embedded metadata to the destination
|
||||||
|
cart/cut (boolean).
|
||||||
|
|
||||||
|
channels - Use specified number of channels in the destination
|
||||||
|
cut. Valid values are 1 or 2 (integer).
|
||||||
|
|
||||||
|
normalization_level - Normalization level, 0 = no normalization
|
||||||
|
(integer, dBFS)
|
||||||
|
|
||||||
|
autotrim_level - Autotrim level, 0 = no autotrim (integer, dBFS)
|
||||||
|
|
||||||
|
group_name - If both the 'cart-number' and 'cut-number' parameters
|
||||||
|
are set to 0 and a valid 'group_name' parameter passed,
|
||||||
|
the system will attempt to create a new cart/cut in
|
||||||
|
the specified group.
|
||||||
|
|
||||||
|
title - The value to set as the title of the target cart. This
|
||||||
|
will override any value found in in-file metadata
|
||||||
|
(string).
|
||||||
|
"""
|
||||||
|
|
||||||
|
if(not filename):
|
||||||
|
raise ValueError('missing filename')
|
||||||
|
if(group_name):
|
||||||
|
if((cart_number!=0) or (cut_number!=0)):
|
||||||
|
raise RuntimeError('cart/cut numbers cannot be specified when using the "group_name" parameter')
|
||||||
|
else:
|
||||||
|
if((cart_number<1)or(cart_number>999999)):
|
||||||
|
raise ValueError('invalid cart number')
|
||||||
|
if((cut_number<1)or(cut_number>999)):
|
||||||
|
raise ValueError('invalid cut number')
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build the WebAPI arguments
|
||||||
|
#
|
||||||
|
postdata={
|
||||||
|
'COMMAND': '2',
|
||||||
|
'LOGIN_NAME': self.__connection_username,
|
||||||
|
'PASSWORD': self.__connection_password,
|
||||||
|
'CART_NUMBER': str(cart_number),
|
||||||
|
'CUT_NUMBER': str(cut_number),
|
||||||
|
'CHANNELS': str(channels),
|
||||||
|
'NORMALIZATION_LEVEL': str(normalization_level),
|
||||||
|
'AUTOTRIM_LEVEL': str(autotrim_level),
|
||||||
|
'TITLE': str(title),
|
||||||
|
'USE_METADATA': '0'
|
||||||
|
}
|
||||||
|
if(use_metadata):
|
||||||
|
postdata['USE_METADATA']='1'
|
||||||
|
if(group_name):
|
||||||
|
postdata['CREATE']='1'
|
||||||
|
postdata['GROUP_NAME']=group_name
|
||||||
|
files={'FILENAME': open(filename,'rb')}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Execute
|
||||||
|
#
|
||||||
|
r=requests.post(self.__connection_url,data=postdata,files=files)
|
||||||
|
if(r.status_code!=requests.codes.ok):
|
||||||
|
r.raise_for_status()
|
||||||
|
|
||||||
def ListCart(self,cart_number,include_cuts=False):
|
def ListCart(self,cart_number,include_cuts=False):
|
||||||
"""
|
"""
|
||||||
Returns the metadata associated with a Rivendell cart
|
Returns the metadata associated with a Rivendell cart
|
||||||
|
@ -30,6 +30,7 @@ EXTRA_DIST = add_cart.py\
|
|||||||
delete_log.py\
|
delete_log.py\
|
||||||
export.py\
|
export.py\
|
||||||
export_peaks.py\
|
export_peaks.py\
|
||||||
|
import.py\
|
||||||
list_cart.py\
|
list_cart.py\
|
||||||
list_cart_sched_codes.py\
|
list_cart_sched_codes.py\
|
||||||
list_carts.py\
|
list_carts.py\
|
||||||
|
88
apis/rivwebpyapi/tests/import.py
Executable file
88
apis/rivwebpyapi/tests/import.py
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!%PYTHON_BANGPATH%
|
||||||
|
|
||||||
|
# import.py
|
||||||
|
#
|
||||||
|
# RivWebPyApi test script for Rivendell
|
||||||
|
#
|
||||||
|
# Test the Import Web API call
|
||||||
|
#
|
||||||
|
# (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public
|
||||||
|
# License along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
import getpass
|
||||||
|
import rivwebpyapi
|
||||||
|
import sys
|
||||||
|
|
||||||
|
url='';
|
||||||
|
username=''
|
||||||
|
password=''
|
||||||
|
filename=''
|
||||||
|
cart_number=0
|
||||||
|
cut_number=0
|
||||||
|
channels=2
|
||||||
|
normalization_level=0
|
||||||
|
autotrim_level=0
|
||||||
|
use_metadata=False
|
||||||
|
group_name=''
|
||||||
|
title=''
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get login parameters
|
||||||
|
#
|
||||||
|
usage='import --url=<rd-url> --username=<rd-username> --filename=<str> --channels=1|2 --normalization-level=<dbfs> --autotrim-level=<dbfs> --use-metadata [--cart-number=<num>] [--cut-number=<num>] [--group-name=<str>] [--title=<str>] [--password=<passwd>]'
|
||||||
|
for arg in sys.argv:
|
||||||
|
f0=arg.split('=')
|
||||||
|
if(len(f0)==2):
|
||||||
|
if(f0[0]=='--url'):
|
||||||
|
url=f0[1]
|
||||||
|
if(f0[0]=='--username'):
|
||||||
|
username=f0[1]
|
||||||
|
if(f0[0]=='--password'):
|
||||||
|
password=f0[1]
|
||||||
|
if(f0[0]=='--filename'):
|
||||||
|
filename=f0[1]
|
||||||
|
if(f0[0]=='--group-name'):
|
||||||
|
group_name=f0[1]
|
||||||
|
if(f0[0]=='--title'):
|
||||||
|
title=f0[1]
|
||||||
|
if(f0[0]=='--cart-number'):
|
||||||
|
cart_number=int(f0[1])
|
||||||
|
if(f0[0]=='--cut-number'):
|
||||||
|
cut_number=int(f0[1])
|
||||||
|
if(f0[0]=='--channels'):
|
||||||
|
channels=int(f0[1])
|
||||||
|
if(f0[0]=='--normalization-level'):
|
||||||
|
normalization_level=int(f0[1])
|
||||||
|
if(f0[0]=='--autotrim-level'):
|
||||||
|
autotrim_level=int(f0[1])
|
||||||
|
if(len(f0)==1):
|
||||||
|
if(f0[0]=='--use-metadata'):
|
||||||
|
use_metadata=True
|
||||||
|
|
||||||
|
if(not password):
|
||||||
|
password=getpass.getpass()
|
||||||
|
if((not url)or(not username)):
|
||||||
|
print(usage)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the code list
|
||||||
|
#
|
||||||
|
webapi=rivwebpyapi.rivwebpyapi(url=url,username=username,password=password)
|
||||||
|
webapi.Import(filename=filename,cart_number=cart_number,cut_number=cut_number,
|
||||||
|
channels=channels,normalization_level=normalization_level,
|
||||||
|
autotrim_level=autotrim_level,use_metadata=use_metadata,
|
||||||
|
group_name=group_name,title=title)
|
Loading…
x
Reference in New Issue
Block a user