2021-12-09 Fred Gleason <fredg@paravelsystems.com>

* Added a 'SavePodcast()' method to the 'rivwebpyapi' API.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-12-09 11:59:48 -05:00
parent cf0f9d9de8
commit dc3915b601
5 changed files with 117 additions and 1 deletions

View File

@ -22717,3 +22717,5 @@
* Added a 'Rehash()' method to the 'rivwebpyapi' API.
2021-12-08 Fred Gleason <fredg@paravelsystems.com>
* Added a 'TrimAudio()' method to the 'rivwebpyapi' API.
2021-12-09 Fred Gleason <fredg@paravelsystems.com>
* Added a 'SavePodcast()' method to the 'rivwebpyapi' API.

View File

@ -1854,6 +1854,40 @@ class rivwebpyapi(object):
return handler.output()[0]
def SavePodcast(self,cast_id,filename):
"""
Save posted podcast audio to the Rivendell audio store.
Takes the following arguments:
filename - Name of the file containing audio to be stored (string).
cast_id - ID of the owning podcast item (integer).
"""
if(not filename):
raise ValueError('missing filename')
if(cast_id<0):
raise ValueError('invalid podcast id')
#
# Build the WebAPI arguments
#
postdata={
'COMMAND': '38',
'LOGIN_NAME': self.__connection_username,
'PASSWORD': self.__connection_password,
'ID': str(cast_id)
}
files={'FILENAME': open(filename,'rb')}
#
# Execute
#
r=requests.post(self.__connection_url,data=postdata,files=files)
if(r.status_code!=requests.codes.ok):
self.__throwError(response=r)
def UnassignSchedCode(self,cart_number,sched_code):
"""
Unassign a schedule code from a cart.

View File

@ -47,6 +47,7 @@ EXTRA_DIST = add_cart.py\
rehash.py\
remove_cart.py\
remove_cut.py\
save_podcast.py\
trim_audio.py\
unassign_sched_code.py

View File

@ -0,0 +1,79 @@
#!%PYTHON_BANGPATH%
# save_podcast.py
#
# RivWebPyApi test script for Rivendell
#
# Test the SavePodcast 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
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
url='';
username=''
password=''
filename=''
cast_id=-1
#
# Get login parameters
#
usage='save_podcast --url=<rd-url> --username=<rd-username> --filename=<str> --cast-id=<id>'
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]=='--cast-id'):
cast_id=int(f0[1])
if(not password):
password=getpass.getpass()
if((not url)or(not username)):
print(usage)
sys.exit(1)
if(cast_id<0):
eprint('you must supply "--cast-id"')
sys.exit(1)
if(not filename):
eprint('you must supply "--filename"')
sys.exit(1)
#
# Execute
#
webapi=rivwebpyapi.rivwebpyapi(url=url,username=username,password=password)
try:
webapi.SavePodcast(cast_id=cast_id,filename=filename)
except rivwebpyapi.RivWebPyError as err:
eprint('*** ERROR ***')
eprint('Response Code: '+str(err.responseCode))
eprint('ErrorString: '+str(err.errorString))
eprint('*************')
eprint('')
sys.exit(1)

View File

@ -4020,7 +4020,7 @@
<sect1>
<title>SavePodcast</title>
<subtitle>Save posted podcast audio</subtitle>
<subtitle>Save posted podcast audio to the Rivendell audio store</subtitle>
<para>
Command Code: <code>RDXPORT_COMMAND_SAVE_PODCAST</code>
</para>