Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
ba85842fcd
|
@ -12,6 +12,7 @@ import logging
|
|||
import logging.config
|
||||
import shutil
|
||||
import string
|
||||
import platform
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
|
||||
if os.geteuid() != 0:
|
||||
|
@ -68,6 +69,17 @@ try:
|
|||
print "Copying pypo files"
|
||||
shutil.copy("../scripts/silence-playlist.lsp", BASE_PATH+"files/basic")
|
||||
shutil.copy("../scripts/silence.mp3", BASE_PATH+"files/basic")
|
||||
|
||||
if platform.architecture()[0] == '64bit':
|
||||
print "Installing 64-bit liquidsoap binary"
|
||||
shutil.copy("../liquidsoap/liquidsoap64", "../liquidsoap/liquidsoap")
|
||||
elif platform.architecture()[0] == '32bit':
|
||||
print "Installing 32-bit liquidsoap binary"
|
||||
shutil.copy("../liquidsoap/liquidsoap32", "../liquidsoap/liquidsoap")
|
||||
else:
|
||||
print "Unknown system architecture."
|
||||
sys.exit(1)
|
||||
|
||||
#shutil.copy("../pypo-cli.py", BASE_PATH+"bin")
|
||||
#shutil.copy("../pypo-notify.py", BASE_PATH+"bin")
|
||||
#shutil.copy("../logging.cfg", BASE_PATH+"bin")
|
||||
|
|
Binary file not shown.
|
@ -463,7 +463,7 @@ class Playout:
|
|||
"""
|
||||
Handle files on NAS. Pre-cueing not implemented at the moment.
|
||||
(not needed by openbroadcast, feel free to add this)
|
||||
Here an implementation for localy stored files.
|
||||
Here's an implementation for locally stored files.
|
||||
Works the same as with remote files, just replaced API-download with
|
||||
file copy.
|
||||
"""
|
||||
|
@ -687,7 +687,6 @@ class Playout:
|
|||
logger.debug(line.strip())
|
||||
tn.write(self.export_source + '.push %s' % (line.strip()))
|
||||
tn.write("\n")
|
||||
#time.sleep(0.1)
|
||||
|
||||
tn.write("exit\n")
|
||||
logger.debug(tn.read_all())
|
||||
|
@ -702,10 +701,6 @@ class Playout:
|
|||
logger.debug("Sending additional data to liquidsoap: "+liquidsoap_data)
|
||||
tn.write("vars.pypo_data "+liquidsoap_data+"\n")
|
||||
|
||||
# if(int(ptype) < 5):
|
||||
# tn.write(self.export_source + '.flip')
|
||||
# tn.write("\n")
|
||||
|
||||
tn.write(self.export_source + '.flip')
|
||||
tn.write("\n")
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import unittest
|
||||
|
||||
from util.cue_file import CueFile
|
||||
|
||||
from mutagen.mp3 import MP3
|
||||
from mutagen.oggvorbis import OggVorbis
|
||||
import random
|
||||
import string
|
||||
|
||||
class test(unittest.TestCase):
|
||||
|
||||
"""
|
||||
|
||||
A test class for the cue_in module.
|
||||
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.cue_file = CueFile()
|
||||
|
||||
def test_cue_mp3(self):
|
||||
src = '../audio_samples/OpSound/Peter_Rudenko_-_Opening.mp3'
|
||||
dst = '/tmp/' + "".join([random.choice(string.letters) for i in xrange(10)]) + '.mp3'
|
||||
self.cue_file.cue(src, dst, 5, 5)
|
||||
src_length = MP3(src).info.length
|
||||
dst_length = MP3(dst).info.length
|
||||
print src + " " + str(src_length)
|
||||
print dst + " " + str(dst_length)
|
||||
self.assertTrue(dst_length < src_length)
|
||||
|
||||
def test_cue_ogg(self):
|
||||
src = '../audio_samples/OpSound/ACDC_-_Back_In_Black-sample.ogg'
|
||||
dst = '/tmp/' + "".join([random.choice(string.letters) for i in xrange(10)]) + '.ogg'
|
||||
self.cue_file.cue(src, dst, 5, 5)
|
||||
src_length = OggVorbis(src).info.length
|
||||
dst_length = OggVorbis(dst).info.length
|
||||
print src + " " + str(src_length)
|
||||
print dst + " " + str(dst_length)
|
||||
self.assertTrue(dst_length < src_length)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -79,7 +79,7 @@ dst = TEMP_DIR + 'lstf_' + "".join( [random.choice(string.letters) for i in xran
|
|||
# get length of track using mutagen.
|
||||
#audio
|
||||
#command
|
||||
if src.endswith('.mp3'):
|
||||
if src.lower().endswith('.mp3'):
|
||||
audio = MP3(src)
|
||||
dur = round(audio.info.length, 3)
|
||||
|
||||
|
@ -115,7 +115,7 @@ if src.endswith('.mp3'):
|
|||
sys.stderr.write('abs: ' + str(str_cue_out) + '\n\n')
|
||||
|
||||
command = 'mp3cut -o %s -t %s-%s %s' % (dst, str_cue_in, str_cue_out, src)
|
||||
elif src.endswith('.ogg'):
|
||||
elif src.lower().endswith('.ogg'):
|
||||
audio = OggVorbis(src)
|
||||
dur = audio.info.length
|
||||
sys.stderr.write('duration: ' + str(dur) + '\n')
|
||||
|
|
|
@ -11,7 +11,7 @@ import os
|
|||
import logging
|
||||
|
||||
from mutagen.mp3 import MP3
|
||||
|
||||
from mutagen.oggvorbis import OggVorbis
|
||||
|
||||
class CueFile():
|
||||
|
||||
|
@ -24,56 +24,67 @@ class CueFile():
|
|||
logger = logging.getLogger("cue_file.cue")
|
||||
logger.debug("cue file: %s %s %s %s", src, dst, cue_in, cue_out)
|
||||
|
||||
# mutagen
|
||||
audio = MP3(src)
|
||||
dur = round(audio.info.length, 3)
|
||||
if src.lower().endswith('.mp3'):
|
||||
# mutagen
|
||||
audio = MP3(src)
|
||||
dur = round(audio.info.length, 3)
|
||||
|
||||
logger.debug("duration by mutagen: %s", dur)
|
||||
|
||||
cue_out = round(float(dur) - cue_out, 3)
|
||||
|
||||
str_cue_in = str(timedelta(seconds=cue_in)).replace(".", "+") # hh:mm:ss+mss, eg 00:00:20+000
|
||||
str_cue_out = str(timedelta(seconds=cue_out)).replace(".", "+") #
|
||||
|
||||
"""
|
||||
now a bit a hackish part, don't know how to do this better...
|
||||
need to cut the digits after the "+"
|
||||
"""
|
||||
ts = str_cue_in.split("+")
|
||||
try:
|
||||
if len(ts[1]) == 6:
|
||||
ts[1] = ts[1][0:3]
|
||||
str_cue_in = "%s+%s" % (ts[0], ts[1])
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
ts = str_cue_out.split("+")
|
||||
try:
|
||||
if len(ts[1]) == 6:
|
||||
ts[1] = ts[1][0:3]
|
||||
str_cue_out = "%s+%s" % (ts[0], ts[1])
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
#sys.stderr.write(str(timedelta(seconds=cue_in)).replace(".", "+") + '\n\n')
|
||||
logger.debug("in: %s", str_cue_in)
|
||||
logger.debug("out: %s", str(str_cue_out) )
|
||||
logger.debug("duration by mutagen: %s", dur)
|
||||
|
||||
cue_out = round(float(dur) - cue_out, 3)
|
||||
|
||||
str_cue_in = str(timedelta(seconds=cue_in)).replace(".", "+") # hh:mm:ss+mss, eg 00:00:20+000
|
||||
str_cue_out = str(timedelta(seconds=cue_out)).replace(".", "+") #
|
||||
|
||||
"""
|
||||
now a bit a hackish part, don't know how to do this better...
|
||||
need to cut the digits after the "+"
|
||||
"""
|
||||
ts = str_cue_in.split("+")
|
||||
try:
|
||||
if len(ts[1]) == 6:
|
||||
ts[1] = ts[1][0:3]
|
||||
str_cue_in = "%s+%s" % (ts[0], ts[1])
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
ts = str_cue_out.split("+")
|
||||
try:
|
||||
if len(ts[1]) == 6:
|
||||
ts[1] = ts[1][0:3]
|
||||
str_cue_out = "%s+%s" % (ts[0], ts[1])
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
logger.debug("in: %s", str_cue_in)
|
||||
logger.debug("out: %s", str(str_cue_out) )
|
||||
|
||||
# command = 'mp3cut -o %s -t %s-%s %s' % (dst, str_cue_in, str_cue_out, src);
|
||||
# logger.info("command: %s", command)
|
||||
# os.system(command + ' >/dev/null')
|
||||
#
|
||||
# command = 'mp3val -f %s' % (dst);
|
||||
# logger.info("command: %s", command)
|
||||
# os.system(command + ' >/dev/null')
|
||||
command = 'mp3cut -o %s -t %s-%s %s' % (dst + '.tmp.mp3', str_cue_in, str_cue_out, src);
|
||||
logger.info("command: %s", command)
|
||||
print command
|
||||
os.system(command + ' > /dev/null 2>&1')
|
||||
|
||||
command = 'mp3cut -o %s -t %s-%s %s' % (dst + '.tmp.mp3', str_cue_in, str_cue_out, src);
|
||||
logger.info("command: %s", command)
|
||||
os.system(command + ' >/dev/null')
|
||||
|
||||
command = 'lame -b 32 %s %s' % (dst + '.tmp.mp3', dst);
|
||||
logger.info("command: %s", command)
|
||||
os.system(command + ' >/dev/null')
|
||||
|
||||
|
||||
command = 'lame -b 32 %s %s' % (dst + '.tmp.mp3', dst);
|
||||
logger.info("command: %s", command)
|
||||
print command
|
||||
os.system(command + ' > /dev/null 2>&1')
|
||||
elif src.lower().endswith('.ogg'):
|
||||
audio = OggVorbis(src)
|
||||
dur = audio.info.length
|
||||
sys.stderr.write('duration: ' + str(dur) + '\n')
|
||||
|
||||
cue_out = float(dur) - cue_out
|
||||
|
||||
#convert input format of ss.mmm to milliseconds and to string<
|
||||
str_cue_in = str(int(round(cue_in*1000)))
|
||||
|
||||
#convert input format of ss.mmm to milliseconds and to string
|
||||
str_cue_out = str(int(round(cue_out*1000)))
|
||||
|
||||
command = 'oggCut -s %s -e %s %s %s' % (str_cue_in, str_cue_out, src, dst)
|
||||
logger.info("command: %s", command)
|
||||
os.system(command + ' > /dev/null 2>&1')
|
||||
else:
|
||||
logger.debug("in: %s", 'File name with invalid extension. File will not be cut\n')
|
||||
|
||||
return dst
|
||||
|
|
Loading…
Reference in New Issue