Пример #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
 def irc_command_enqueue(self, client, source, target, args):
     print "%r.irc_command_enqueue(%r, %r, %r, %r)" % (self, client, source, target, args)
     try:
         track_id = int(args)
     except (TypeError, ValueError) as e:
         client.send(message.msg(target, "enqueue argument must parse as integral"))
     try:
         track = self._sess.query(m.TrackOriginal).filter_by(id=track_id).one()
     except sqlao_e.NoResultFound:
         client.send(message.msg(target, "track number not found"))
     client.send(message.msg(target, "track ``%s'' enqueued." % track.get_name()))
     self._queue.enqueue(track)
Пример #3
0
 def irc_command_badtrack(self, client, source, target, args):
     print "%r.irc_command_np(%r, %r, %r, %r)" % (self, client, source, target, args)
     track, pos = self._getter()
     
     self._out_file.write("%s\t%d\n" % (source, track.original._id))
     self._out_file.flush()
     self._queue.put(SkipTrackEvent())
     client.send(message.msg(target, "track logged and skipped"))
Пример #4
0
 def irc_command_unfave(self, client, source, target, args):
     session = self._sessf()
     username = u"%s@%s" % (source.nick, client.host)
     track, pos = self._getter()
     try:
         track = session.merge(track)
         try:
             user = session.query(m.User).\
                     filter(m.User.username==username).one()
             fave_rec = session.query(m.Fave).\
                     filter(m.Fave.user == user).\
                     filter(m.Fave.track == track.original).one()
             session.delete(fave_rec)
             session.commit()
             client.send(message.msg(target, u"%s: done" % source.nick))
         except sqlao_e.NoResultFound:
             client.send(message.msg(target,
                 u"%s: you don't seem to have this track faved" % source.nick))
         except sqlao_e.NoResultFound:
             client.send(message.msg(target, u"%s: an error occured: %r" % (
                     source.nick, e)))    
     finally:
         session.close()
Пример #5
0
 def irc_command_fave(self, client, source, target, args):
     session = self._sessf()
     username = u"%s@%s" % (source.nick, client.host)
     track, pos = self._getter()
     try:
         track = session.merge(track)
         try:
             user = session.query(m.User).\
                     filter(m.User.username==username).one()
         except sqlao_e.NoResultFound:
             user = m.User(username=username)
             session.add(user)
         try:
             fave = m.Fave(user=user, track=track.original)
             session.add(fave)
             client.send(message.msg(target, u"%s: marked %s as fave" % (
                     source.nick, track.original.get_name())))
             session.commit()
         except Exception as e:
             client.send(message.msg(target, u"%s: an error occured: %r" % (
                     source.nick, e)))
     finally:
         session.close()
Пример #6
0
 def irc_command_np(self, client, source, target, args):
     print "%r.irc_command_np(%r, %r, %r, %r)" % (self, client, source, target, args)
     track, pos = self._getter()
     session = self._sessf()
     try:
         track = session.merge(track)
         try:
             lp_rec = track.original.plays.order_by(m.TrackPlay.played_at.desc()).limit(1).one()
             lp = "%s ago" % (datetime.datetime.now() - lp_rec.played_at)
         except sqlao_e.NoResultFound:
             lp = "never"
         line = u"[Track#%d] \00313%s\017 [%d samples] [faves \0033+%d\017] [lp %s]" % (
             track.original._id,
             track.original.get_name(),
             pos,
             track.original.faves.count(),
             lp 
         )
         client.send(message.msg(target, line))
     finally:
         session.close()
Пример #7
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."))
Пример #8
0
 def irc_command_next(self, client, source, target, args):
     print "%r.irc_command_next(%r, %r, %r, %r)" % (self, client, source, target, args)
     self._queue.put(SkipTrackEvent())
     client.send(message.msg(target, "Okay, skipping."))
Пример #9
0
 def irc_command_show_queue(self, client, source, target, args):
     print "%r.irc_command_show_queue(%r, %r, %r, %r)" % (self, client, source, target, args)
     for track in self._queue:
         client.send(message.msg(target, track.get_name()))