Esempio n. 1
0
def start_play(item, channel=None, user=None):
    log.debug('item: %s - channel: %s - user: %s' % (item, channel, user))

    # Set current values to cache
    cache.set('abcast_on_air_%s' % channel.pk, item, 30)

    # Broadcast to pushy clients
    pushy_custom('%son-air/' % channel.get_api_url())


    if item.release and not 'jingle' in item.release.name.lower():

        try:
            text = '%s by %s - %s' % (item.name, item.artist.name, item.release.name)
            set_stream_metadata(channel, text)
        except Exception as e:
            log.warning('unable to set stream metadata: {}'.format(e))

        try:
            set_tunein_metadata(channel, item)
        except Exception as e:
            log.warning('unable to set tunein metadata: {}'.format(e))

        try:
            set_radioplayer_metadata(item)
        except Exception as e:
            log.warning('unable to set radioplayer metadata: {}'.format(e))


    try:
        from atracker.util import create_event
        create_event(user, item, channel, 'playout')
    except Exception as e:
        log.warning('exception: %s' % e)
Esempio n. 2
0
def start_play(item, channel=None, user=None):
    log = logging.getLogger('abcast.util.notify.start_play')

    log.debug('item: %s' % item)
    log.debug('channel: %s' % channel)
    log.debug('user: %s' % user)

    """
    Set current values to cache
    """
    cache.set('abcast_on_air_%s' % channel.pk, item, 30)


    """
    Broadcast to pushy clients
    """
    from pushy.util import pushy_custom
    pushy_custom('%son-air/' % channel.get_api_url())

    """
    Update stream metadata
    """
    text = u'%s by %s - %s' % (item.name, item.artist.name, item.release.name)
    api = IcecastAPI()
    api.set_metadata(channel, text)

    try:
        from atracker.util import create_event
        user = None
        create_event(user, item, channel, 'playout')
    except Exception, e:
        log.warning('exception: %s' % e)
Esempio n. 3
0
def on_comment_posted(sender, comment, request, **kwargs):

    """
    rs = redis.StrictRedis()
    opt = dict(size=(70, 70), crop=True, bw=True, quality=80)
    try:
        image = get_thumbnailer(request.user.profile_set.all()[0].image).get_thumbnail(opt).url
    except:
        image = None
    message = {
               'user': request.user.username,
               'image': image,
               'comment': comment.comment,
               'comment_html': re.sub('<[^<]+?>', '', comment.comment).replace('\n','<br>\n'),
               'route': comment.content_object.get_api_url(),
               'type': 'message'
               #'timestamp': comment.submit_date
               }
    
    rs.publish('push_chat', json.dumps(message))
    """
    
    from actstream import action
    action.send(request.user, verb='commented on', target=comment.content_object)

    from pushy.util import pushy_custom
    body = {
            'comment': comment.comment,
            'user': request.user.username
            }
    pushy_custom(comment.content_object.uuid, body=body, type='update')
    
    
    """
    Send email notification of a new comment to site staff when email notifications have been requested.
    """
    # This code is copied from django.contrib.comments.moderation.
    # That code doesn't offer a RequestContext, which makes it really
    # hard to generate proper URL's with FQDN in the email
    #
    # Instead of implementing this feature in the moderator class, the signal is used instead
    # so the notification feature works regardless of a manual moderator.register() call in the project.
    if not appsettings.FLUENT_COMMENTS_USE_EMAIL_NOTIFICATION:
        return
    
    return

    recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
    site = get_current_site(request)
    content_object = comment.content_object

    subject = '[{0}] New comment posted on "{1}"'.format(site.name, content_object)
    context = {
        'site': site,
        'comment': comment,
        'content_object': content_object
    }

    message = render(request, "comments/comment_notification_email.txt", context)
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
Esempio n. 4
0
def post_save_vote(sender, **kwargs):
    obj = kwargs['instance']
    try:
        from pushy.util import pushy_custom
        pushy_custom(obj.content_object.get_api_url(), type='update')
    except Exception as e:
        pass
Esempio n. 5
0
def post_save_vote(sender, **kwargs):
    obj = kwargs['instance']
    try:
        from pushy.util import pushy_custom
        pushy_custom(obj.content_object.get_api_url(), type='update')
    except Exception as e:
        pass
Esempio n. 6
0
def post_save_export(sender, **kwargs):
    obj = kwargs['instance']

    # if status is 'ready' > run exporter
    if obj.status == 2:
        obj.process()

    # emmit update message via pushy
    if kwargs['created']:
        if obj.user and obj.user.profile:
            pushy_custom(obj.user.profile.uuid)

    obj.export_items.update(status=1)
Esempio n. 7
0
def post_save_export(sender, **kwargs):
    obj = kwargs['instance']

    # if status is 'ready' > run exporter
    if obj.status == 2:
        obj.process()

    # emmit update message via pushy
    if kwargs['created']:
        if obj.user and obj.user.profile:
            from pushy.util import pushy_custom
            pushy_custom(str(obj.user.profile.uuid))

    obj.export_items.update(status=1)
Esempio n. 8
0
 def on_modified(self, event):
     print '************** MOD **********'
     from pushy.util import pushy_custom
     pushy_custom('pushy_asset/refresh/', None, 'update')
    def on_modified(self, event):
        print "************** MOD **********"
        from pushy.util import pushy_custom

        pushy_custom("pushy_asset/refresh/", None, "update")