示例#1
0
def send_stream_greenlet():
    while True:
        try:
            send_stream(settings.STREAM_URL,
                    track_getter(track_queue, 5, selection_strategy),
                    pre_transforms=[
                        ogg_trans.make_seq_monotonic,
                        stream_event.OggPageEvent.pre_transform,
                        ogg_trans.page_buffer(64),
                    ],
                    post_transforms=[
                        ogg_trans.apply_timing,
                        ogg_trans.make_pos_monotonic,
                        ogg_trans.last_played_monitor(DBSession),
                        stream_event.SkipTrackEvent.post_transform,
                        inject_events(command_queue),
                        now_playing_transform,
                    ],
                )
        except socket.error as e:
            cli.send(message.msg(JOIN_CHANNEL,
                "send_stream_greenlet: [NOTICE] suppressed: %r" % e))
        except Exception as e:
            cli.send(message.msg(JOIN_CHANNEL,
                "send_stream_greenlet: [WARNING] suppressed: %r" % e))
示例#2
0
#!/usr/bin/env python
import gevent

from flyrc import message

from ireul.irc_bot import cli, JOIN_CHANNEL
from ireul.metainfo_readers.icy import get_metadata as get_icy_metadata
from ireul.metainfo_readers.ogg_vorbis import get_metadata as get_ogg_metadata

channels = {
    'everfree': 'http://208.67.225.10:5800/stream/1/',
    'r/a/dio': 'http://stream.r-a-dio.com:1130/main.mp3',
    'ogg-test': 'http://anka.org:8080/fresh.ogg',
}

cli.start()

gevent.sleep(3)

while True:
    for res in get_icy_metadata(channels['r/a/dio']):
        print u"Got TrackInfo: %r" % res.raw
        cli.send(message.msg(JOIN_CHANNEL, u"Now Playing: %s" % unicode(res)))
    cli.send(message.msg(JOIN_CHANNEL, "Lost connection to server."))