Moved all file-related functions from BasicStor into StoredFile class.

Got rid of all the stuff related to GUNID hex-to-int conversion.
Commented out lots of functions that are either not in use or will
no longer work.

Pypo: made things more generic and pluggable, added documentation.
Added the PHP scripts to serve the right info back to pypo.
This commit is contained in:
paul.baranowski 2010-11-12 17:07:01 -05:00
parent 35dc3fd01f
commit 8a58df3093
32 changed files with 2233 additions and 2000 deletions

View file

@ -8,8 +8,14 @@ Python part of radio playout (pypo)
The main functions are "fetch" (./pypo_cli.py -f) and "push" (./pypo_cli.py -p)
Also check out the php counterpart that handles the api requests:
https://lab.digris.ch/svn/elgg/trunk/unstable/mod/medialibrary/application/controllers/api/pypo.php
There are two layers: scheduler & daypart (fallback)
The daypart is a fallback-layer generated by the playlists daypart-settings
(eg a playlist creator can say that the list is good for Monday and Tues,
between 14:00 and 16:00). So if there is nothing in the schedule, pypo will
still play something (instead of silence..) This layer is optional.
It is there so that you dont have a fallback player which plays the same 100
tracks over and over again.
Attention & ToDos
- liquidsoap does not like mono files! So we have to make sure that only files with
@ -290,7 +296,6 @@ class Playout:
# TODO: maybe a bit more modular..
silence_file = self.file_dir + 'basic/silence.mp3'
if int(playlist['played']) == 1:
logger.info("playlist %s already played / sent to liquidsoap, so will ignore it", pkey)
@ -311,14 +316,14 @@ class Playout:
else:
print 'Could not find silence file!'
print 'file is excpected to be at: ' + silence_file
logger.critical('file is excpected to be at: %s', silence_file)
print 'File is expected to be at: ' + silence_file
logger.critical('File is expected to be at: %s', silence_file)
sys.exit()
elif int(playlist['subtype']) == 6:
"""
This is a live-cast session
create a silence list. (could eg also be a falback list..)
Create a silence list. (could eg also be a fallback list..)
"""
logger.debug("found %s seconds of live-cast session at %s", pkey, playlist['duration'])
@ -330,8 +335,8 @@ class Playout:
else:
print 'Could not find silence file!'
print 'file is excpected to be at: ' + silence_file
logger.critical('file is excpected to be at: %s', silence_file)
print 'File is expected to be at: ' + silence_file
logger.critical('File is expected to be at: %s', silence_file)
sys.exit()
@ -361,18 +366,16 @@ class Playout:
else:
logger.debug("try to download %s", src)
try:
print '** urllib auth with: ',
print self.api_auth
urllib.urlretrieve (src, dst, False, self.api_auth)
logger.info("downloaded %s to %s", src, dst)
except Exception, e:
logger.error("%s", e)
api_client.get_media(src, dst)
#try:
# print '** urllib auth with: ',
# print self.api_auth
# urllib.urlretrieve (src, dst, False, self.api_auth)
# logger.info("downloaded %s to %s", src, dst)
#except Exception, e:
# logger.error("%s", e)
elif src[0:4] == 'http' and do_cue == True:
if os.path.isfile(dst):
logger.debug("file already in cache: %s", dst)
print 'cached'
@ -384,15 +387,15 @@ class Playout:
dst_tmp = self.tmp_dir + "".join([random.choice(string.letters) for i in xrange(10)]) + '.mp3'
print dst_tmp
print '***'
try:
print '** urllib auth with: ',
print self.api_auth
urllib.urlretrieve (src, dst_tmp, False, self.api_auth)
logger.info("downloaded %s to %s", src, dst_tmp)
except Exception, e:
logger.error("%s", e)
api_client.get_media(src, dst_tmp)
#try:
# print '** urllib auth with: ',
# print self.api_auth
# urllib.urlretrieve (src, dst_tmp, False, self.api_auth)
# logger.info("downloaded %s to %s", src, dst_tmp)
#except Exception, e:
# logger.error("%s", e)
#
# cue
print "STARTIONG CUE"
@ -447,9 +450,6 @@ class Playout:
except Exception, e:
logger.error("%s", e)
if do_cue == True:
if os.path.isfile(dst):
@ -494,9 +494,6 @@ class Playout:
except Exception, e:
logger.error("%s", e)
if True == os.access(dst, os.R_OK):
# check filesize (avoid zero-byte files)
#print 'waiting: ' + dst
@ -513,7 +510,6 @@ class Playout:
print pl_entry
"""
Tracks are only added to the playlist if they are accessible
on the file system and larger than 0 bytes.
@ -523,7 +519,6 @@ class Playout:
ls_playlist += pl_entry + "\n"
logger.debug("everything ok, adding %s to playlist", pl_entry)
else:
print 'zero-file: ' + dst + ' from ' + src
logger.warning("zero-size file - skiping %s. will not add it to playlist", dst)
@ -531,8 +526,6 @@ class Playout:
else:
logger.warning("something went wrong. file %s not available. will not add it to playlist", dst)
except Exception, e: logger.info("%s", e)