Пример #1
0
    def __init__(self, conf_file):
        Thread.__init__(self)
        self.conf_file = conf_file
        self.conf = self.get_conf_dict()
        if 'log' in self.conf['deefuzzer'].keys():
            self.logger = Logger(self.conf['deefuzzer']['log'])
        else:
            self.logger = Logger('.' + os.sep + 'deefuzzer.log')
        if 'm3u' in self.conf['deefuzzer'].keys():
            self.m3u = self.conf['deefuzzer']['m3u']
        else:
            self.m3u = '.' + os.sep + 'deefuzzer.m3u'

        if isinstance(self.conf['deefuzzer']['station'], dict):
            # Fix wrong type data from xmltodict when one station (*)
            self.nb_stations = 1
        else:
            self.nb_stations = len(self.conf['deefuzzer']['station'])

        # Set the deefuzzer logger
        self.logger.write_info('Starting DeeFuzzer')
        self.logger.write_info('Using libshout version %s' % shout.version())

        # Init all Stations
        self.stations = []
        self.logger.write_info('Number of stations : ' + str(self.nb_stations))
Пример #2
0
    def stream(
        self,
        channel_mount,
        station_url,
        genre, name,
        description,
        hostname,
        port,
        password
    ):
        self.shout = shout.Shout()
        print "Using libshout version %s" % shout.version()

        self.shout.audio_info = {
            shout.SHOUT_AI_BITRATE: "128",
            shout.SHOUT_AI_SAMPLERATE: "44100",
            shout.SHOUT_AI_CHANNELS: "2"
        }
        self.shout.name = name
        self.shout.url = station_url
        self.shout.mount = channel_mount
        self.shout.port = port
        self.shout.user = "******"
        self.shout.password = password
        self.shout.genre = genre
        self.shout.description = description
        self.shout.host = hostname
        self.shout.ogv = 0
        self.shout.format = "mp3"
        self.shout.open()

        songs_api = jukebox_core.api.songs()
        while 1:
            self.sendfile(songs_api.getNextSong())
Пример #3
0
    def __init__(self, host, port, password):
        self.shout = shout.Shout()
        logger.info("Creating new streamer (libshout version %s)...",
                    shout.version())

        # Set stream metadata
        self.shout.audio_info = {
            shout.SHOUT_AI_BITRATE: "128",
            shout.SHOUT_AI_SAMPLERATE: "44100",
            shout.SHOUT_AI_CHANNELS: "2"
        }
        self.shout.ogv = 0
        self.shout.format = "mp3"

        # Set connection information
        self.shout.host = host
        self.shout.port = int(port)
        self.shout.mount = "/stream"
        self.shout.user = "******"
        self.shout.password = password

        # Set stream information
        self.shout.name = "NitroDJ"
        self.shout.genre = "Various"
        self.shout.description = "NitroDJ instance"
        self.shout.url = "http://{}:{}/stream".format(host, port)

        self.shout.open()
        self.shout.close()
Пример #4
0
    def __init__(self):
        threading.Thread.__init__(self)

        self.nextFile = None
        self.needsStop = False
        self.needsAbort = False

        self.controlLock = threading.Lock()

        self._currentlyPlaying = False
        self.playLock = threading.Lock()

        self._shoutcaster = shout.Shout()
        print "Initializing new shoutcast interface, using libshout version %s" % shout.version(
        )

        self._shoutcaster.password = open(
            os.path.join(os.path.dirname(__file__), "password.txt"),
            "r").read()
        self._shoutcaster.mount = '/partybot'
        self._shoutcaster.format = 'mp3'

        self._shoutcaster.name = 'PartyBot Jukebox'

        self._inputStream = None
        self._silenceStream = None
Пример #5
0
    def __init__(self, conf_file):
        Thread.__init__(self)
        self.conf_file = conf_file
        self.conf = get_conf_dict(self.conf_file)

        # print(self.conf)

        if 'deefuzzer' not in self.conf:
            raise ('This is not a standard deefuzzer config file')

        # Get the log setting first (if possible)
        log_file = str(self.conf['deefuzzer'].pop('log', ''))
        self.log_dir = os.sep.join(log_file.split(os.sep)[:-1])
        if not os.path.exists(self.log_dir) and self.log_dir:
            os.makedirs(self.log_dir)
        self.logger = QueueLogger(log_file, self.log_queue)
        self.logger.start()

        for key in list(self.conf['deefuzzer'].keys()):
            if key == 'm3u':
                self.m3u = str(self.conf['deefuzzer'][key])

            elif key == 'ignoreerrors':
                # Ignore errors and continue as long as possible
                self.ignore_errors = bool(self.conf['deefuzzer'][key])

            elif key == 'max_retry':
                # Maximum number of attempts to restart the stations on crash.
                self.max_retry = int(self.conf['deefuzzer'][key])

            elif key == 'station':
                # Load station definitions from the main config file
                if not isinstance(self.conf['deefuzzer'][key], list):
                    self.add_station(self.conf['deefuzzer'][key])
                else:
                    for s in self.conf['deefuzzer'][key]:
                        self.add_station(s)

            elif key == 'stationconfig':
                # Load additional station definitions from the requested folder
                self.load_stations_fromconfig(self.conf['deefuzzer'][key])

            elif key == 'stationfolder':
                # Create stations automagically from a folder structure
                if isinstance(self.conf['deefuzzer'][key], dict):
                    self.watch_folder = self.conf['deefuzzer'][key]
            else:
                setattr(self, key, self.conf['deefuzzer'][key])

        # Set the deefuzzer logger
        self._info('Starting DeeFuzzer')
        self._info('Using Python version %s' % platform.python_version())
        self._info('Using libshout version %s' % shout.version())
        self._info('Number of stations : ' + str(len(self.station_settings)))
Пример #6
0
    def __init__(self, conf_file):
        Thread.__init__(self)
        self.conf_file = conf_file
        self.conf = get_conf_dict(self.conf_file)

        if 'deefuzzer' not in self.conf:
            return

        # Get the log setting first (if possible)
        log_file = str(self.conf['deefuzzer'].pop('log', ''))
        self.log_dir = os.sep.join(log_file.split(os.sep)[:-1])
        if not os.path.exists(self.log_dir) and self.log_dir:
            os.makedirs(self.log_dir)
        self.logger = QueueLogger(log_file, self.logqueue)
        self.logger.start()

        for key in self.conf['deefuzzer'].keys():
            if key == 'm3u':
                self.m3u = str(self.conf['deefuzzer'][key])

            elif key == 'ignoreerrors':
                # Ignore errors and continue as long as possible
                self.ignoreErrors = bool(self.conf['deefuzzer'][key])

            elif key == 'maxretry':
                # Maximum number of attempts to restart the stations on crash.
                self.maxretry = int(self.conf['deefuzzer'][key])

            elif key == 'station':
                # Load station definitions from the main config file
                if not isinstance(self.conf['deefuzzer'][key], list):
                    self.add_station(self.conf['deefuzzer'][key])
                else:
                    for s in self.conf['deefuzzer'][key]:
                        self.add_station(s)

            elif key == 'stationconfig':
                # Load additional station definitions from the requested folder
                self.load_stations_fromconfig(self.conf['deefuzzer'][key])

            elif key == 'stationfolder':
                # Create stations automagically from a folder structure
                if isinstance(self.conf['deefuzzer'][key], dict):
                    self.watchfolder = self.conf['deefuzzer'][key]
            else:
                setattr(self, key, self.conf['deefuzzer'][key])

        # Set the deefuzzer logger
        self._info('Starting DeeFuzzer')
        self._info('Using libshout version %s' % shout.version())
        self._info('Number of stations : ' + str(len(self.station_settings)))
Пример #7
0
 def __init__(self):
     threading.Thread.__init__(self)
     
     self.nextFile = None
     self.needsStop = False
     self.needsAbort = False
     
     self.controlLock = threading.Lock()
     
     self._currentlyPlaying = False
     self.playLock = threading.Lock()
     
     self._shoutcaster = shout.Shout()
     print "Initializing new shoutcast interface, using libshout version %s" % shout.version()
     
     self._shoutcaster.password = open(os.path.join(os.path.dirname(__file__), "password.txt"), "r").read()
     self._shoutcaster.mount = '/partybot'
     self._shoutcaster.format = 'mp3'
     
     self._shoutcaster.name = 'PartyBot Jukebox'
     
     self._inputStream = None
     self._silenceStream = None
Пример #8
0
def main(argv=None):
	if argv==None:
		argv = sys.argv
	if len(argv) < 2 or len(argv) > 3:
		print "Usage: %s songGraph.pkl [vertexDendrogram.pickle]"% argv[0]
		return
	if len(argv) == 3:
		vertClustPkl = argv[2]
	else:
		vertClustPkl = None
	
	s = shout.Shout()
	print "Using libshout version %s" % shout.version()
	
	s.host = 'doc.gold.ac.uk'
	s.port = 8000
	s.user = '******'
	s.password = '******'
	s.mount = "/vRad.mp3"
	s.name = "Steerable Optimized Self-Organizing Radio"
	s.genre = "CompNets"
	s.url = "http://radio.benfields.net"
	s.format = 'mp3' # | 'vorbis'
	#s.protocol = 'icy' | 'xaudiocast' | 'http'
	# s.public = 0 | 1
	# s.audio_info = { 'key': 'val', ... }
	#  (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE,
	#	shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY)
	currentTracklist = []
	try:
		graphLocation = argv[1]
		loadedGraph = igraph.load(graphLocation, format="pickle")
		ms = copy.deepcopy(loadedGraph)
	except Exception, err:
		print "trouble loading the graph at {0} should point to the graph (as pickle).  Sort it out and try again.".format(argv[1])
		return
Пример #9
0
    def handle(self, *args, **options):
        pidFile = os.path.dirname(
            os.path.abspath(__file__)
        ) + "/../../daemon.pid"

        if options["start"] or options["fg"]:
            if (options["host"] is None or
                options["port"] is None or
                options["password"] is None
            ):
                print "Required arguments: host, port, password"
                self.print_help("jukebox_shout", "help")
                return

            if os.path.exists(pidFile):
                print "Daemon already running, pid file exists"
                return

            pid = daemon.pidfile.TimeoutPIDLockFile(
                pidFile,
                10
            )

            self.shout = shout.Shout()
            print "Using libshout version %s" % shout.version()

            self.shout.audio_info = {
                shout.SHOUT_AI_BITRATE: "128",
                shout.SHOUT_AI_SAMPLERATE: "44100",
                shout.SHOUT_AI_CHANNELS: "2"
            }
            self.shout.name = "Democratic Jukebox"
            self.shout.url = "http://" + options["host"] + ":" + \
                 options["port"] + "/stream"
            self.shout.mount = "/stream"
            self.shout.port = int(options["port"])
            self.shout.user = "******"
            self.shout.password = options["password"]
            self.shout.genre = "Mixed"
            self.shout.description = "Your democratic music player"
            self.shout.host = options["host"]
            self.shout.ogv = 0
            self.shout.format = "mp3"
            try:
                self.shout.open()
                self.shout.close()
            except shout.ShoutException as exception:
                print "Error: " + str(exception)
                return

            if options["start"]:
                print "Starting jukebox_shout daemon..."
                self.daemon = daemon.DaemonContext(
                    uid=os.getuid(),
                    gid=os.getgid(),
                    pidfile=pid,
                    working_directory=os.getcwd(),
                    detach_process=True,
                    signal_map={
                        SIGTSTP: self.shutdown,
                        SIGABRT: self.skipSong
                    }
                )

                with self.daemon:
                    self.shout.open()

                    print "Register player"
                    pid = int(open(pidFile).read())
                    players_api = api.players()
                    players_api.add(pid)

                    songs_api = api.songs()
                    while 1:
                        self.sendfile(songs_api.getNextSong())

            elif options["fg"]:
               self.shout.open()

               print "Register player"
               pid = os.getpid()
               players_api = api.players()
               players_api.add(pid)

               songs_api = api.songs()
               while 1:
                   song = songs_api.getNextSong()
                   self.sendfile(song)

        elif options["stop"]:
            if not os.path.exists(pidFile):
                print "Daemon not running"
                return

            print "Stopping daemon..."
            pid = int(open(pidFile).read())
            os.kill(pid, SIGTSTP)

            print "Unregister player " + str(pid)
            players_api = api.players()
            players_api.remove(pid)
        else:
            self.print_help("jukebox_shout", "help")
Пример #10
0
	"""
	Shout Child -
	  This part streams the mp3's to the icecast server.
	"""
	import shout
	import time, string
	import HaloRadio
	import HaloRadio.PlayLogic as PlayLogic
	import HaloRadio.Config as Config

	cpid = os.getpid()
	logger("%d:shout child starting..."%(cpid))
	arc_root=HaloRadio.conf['path.root']
	mount=HaloRadio.conf['shout.mount']

	logger("Using libshout version %s" % shout.version())

	piper = os.open(fifopath, os.O_NONBLOCK)
	flags = fcntl.fcntl (piper, fcntl.F_GETFL, 0)
	flags = flags | os.O_NONBLOCK
	fcntl.fcntl (piper, fcntl.F_SETFL, flags)
	pollchild = select.poll()
	pollchild.register(piper, select.POLLIN)

	clonerates=string.split(HaloRadio.conf['shout.bitrate'],",")
	streams = {}
	for br in clonerates:
	    streams[br]={}
	    s = shout.Shout()

	    s.host = HaloRadio.conf['shout.host']
Пример #11
0
#!/usr/bin/env python

# usage: ./example.py /path/to/file1 /path/to/file2 ...
import shout
import sys
import string
import time

s = shout.Shout()
print "Using libshout version %s" % shout.version()

# s.host = 'localhost'
# s.port = 8000
# s.user = '******'
s.password = '******'
s.mount = "/pyshout"
# s.format = 'vorbis' | 'mp3'
# s.protocol = 'http' | 'xaudiocast' | 'icy'
# s.name = ''
# s.genre = ''
# s.url = ''
# s.public = 0 | 1
# s.audio_info = { 'key': 'val', ... }
#  (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE,
#   shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY)

s.open()

total = 0
st = time.time()
for fa in sys.argv[1:]:
Пример #12
0
    def handle(self, *args, **options):
        pidFile = os.path.dirname(
            os.path.abspath(__file__)) + "/../../daemon.pid"

        if options["start"] or options["fg"]:
            if (options["host"] is None or options["port"] is None
                    or options["password"] is None):
                print "Required arguments: host, port, password"
                self.print_help("jukebox_shout", "help")
                return

            if os.path.exists(pidFile):
                print "Daemon already running, pid file exists"
                return

            pid = daemon.pidfile.TimeoutPIDLockFile(pidFile, 10)

            self.shout = shout.Shout()
            print "Using libshout version %s" % shout.version()

            self.shout.audio_info = {
                shout.SHOUT_AI_BITRATE: "128",
                shout.SHOUT_AI_SAMPLERATE: "44100",
                shout.SHOUT_AI_CHANNELS: "2"
            }
            self.shout.name = "Democratic Jukebox"
            self.shout.url = "http://" + options["host"] + ":" + \
                 options["port"] + "/stream"
            self.shout.mount = "/stream"
            self.shout.port = int(options["port"])
            self.shout.user = "******"
            self.shout.password = options["password"]
            self.shout.genre = "Mixed"
            self.shout.description = "Your democratic music player"
            self.shout.host = options["host"]
            self.shout.ogv = 0
            self.shout.format = "mp3"
            try:
                self.shout.open()
                self.shout.close()
            except shout.ShoutException as exception:
                print "Error: " + str(exception)
                return

            if options["start"]:
                print "Starting jukebox_shout daemon..."
                self.daemon = daemon.DaemonContext(
                    uid=os.getuid(),
                    gid=os.getgid(),
                    pidfile=pid,
                    working_directory=os.getcwd(),
                    detach_process=True,
                    signal_map={
                        SIGTSTP: self.shutdown,
                        SIGABRT: self.skipSong
                    })

                with self.daemon:
                    self.shout.open()

                    print "Register player"
                    pid = int(open(pidFile).read())
                    players_api = api.players()
                    players_api.add(pid)

                    songs_api = api.songs()
                    while 1:
                        self.sendfile(songs_api.getNextSong())

            elif options["fg"]:
                self.shout.open()

                print "Register player"
                pid = os.getpid()
                players_api = api.players()
                players_api.add(pid)

                songs_api = api.songs()
                while 1:
                    song = songs_api.getNextSong()
                    self.sendfile(song)

        elif options["stop"]:
            if not os.path.exists(pidFile):
                print "Daemon not running"
                return

            print "Stopping daemon..."
            pid = int(open(pidFile).read())
            os.kill(pid, SIGTSTP)

            print "Unregister player " + str(pid)
            players_api = api.players()
            players_api.remove(pid)
        else:
            self.print_help("jukebox_shout", "help")
Пример #13
0
from urllib.request import urlopen
import json
import unicodedata
import re
import shout
import io
import time
import random
import datetime
import os 

api = SoundcloudAPI()

playlist = api.resolve(os.environ.get('SOUNDCLOUD_PLAYLIST'))
s = shout.Shout()
print("Using libshout version %s" % shout.version())
s.host = os.environ.get('ICECAST_HOST')
s.password = os.environ.get('ICECAST_PASSWORD')
s.mount = os.environ.get('ICECAST_MOUNTPOINT','/stream')
s.format = 'mp3'
s.url = os.environ.get('ICECAST_URL', "unknown")
s.genre = os.environ.get('ICECAST_GENRE', "unknown")
s.public = os.environ.get('ICECAST_PUBLIC', 0) 
s.name = os.environ.get('ICECAST_STREAM_NAME', "unknown")
s.description = os.environ.get('ICECAST_STREAM_DESCRIPTION', "No Description")
s.open()

def get_url(url):
    return urlopen(url).read()

def get_page(url):
Пример #14
0
	"""
	Shout Child -
	  This part streams the mp3's to the icecast server.
	"""
	import shout
	import time, string
	import HaloRadio
	import HaloRadio.PlayLogic as PlayLogic
	import HaloRadio.Config as Config

	cpid = os.getpid()
	logger("%d:shout child starting..."%(cpid))
	arc_root=HaloRadio.conf['path.root']
	mount=HaloRadio.conf['shout.mount']

	logger("Using libshout version %s" % shout.version())

	piper = os.open(fifopath, os.O_NONBLOCK)
	flags = fcntl.fcntl (piper, fcntl.F_GETFL, 0)
	flags = flags | os.O_NONBLOCK
	fcntl.fcntl (piper, fcntl.F_SETFL, flags)
	pollchild = select.poll()
	pollchild.register(piper, select.POLLIN)

	clonerates=string.split(HaloRadio.conf['shout.bitrate'],",")
	streams = {}
	for br in clonerates:
	    streams[br]={}
	    s = shout.Shout()

	    s.host = HaloRadio.conf['shout.host']