Ejemplo n.º 1
0
    def _do_image(self, request):
        if request.method == 'POST':
            try:
                action = request.POST.get('action')

                if action == 'Start Play':
                    uid        = request.POST.get('uid')
                    device_idx = request.POST.get('device_idx')
                    airplay.send_image(uid, int(device_idx))
                elif action == 'Refresh Device' and \
                     settings.get('airplay', 'enable') == 'True':
                    airplay.discovery()
            except:
                log.exception('Fail to airplay send_image')

        self.args['id'] = str(request.GET.get('id', content.IMAGE))
        self.args['devices'] = airplay.devices
        self._prepare_browse(request)
        if self.args['self'].get('child_container_count', 0) != 0:
            for row in self.args['rows']:
                self._pretty_format(request, row)
        else:
            self.args['view_mode'] = 'on'
            content.sort(self.args['rows'], 'ratio')
            for row in self.args['rows']:
                row['thumbnail_width'], row['thumbnail_height'] = \
                    get_resize(row.get('width', 0), row.get('height', 0), 180, 135)

        self.args['cur_menu'] = 'image'
        return ('image.html', self.args)
Ejemplo n.º 2
0
    def _do_audio(self, request):
        if request.method == 'POST':
            try:
                action = request.POST.get('action')

                if action == 'Start Play':
                    uid        = request.POST.get('uid')
                    device_idx = request.POST.get('device_idx')
                    host       = request.META.get('HTTP_HOST')
                    airplay.send_audio(host, uid, int(device_idx))
                elif action == 'Refresh Device' and \
                     settings.get('airplay', 'enable') == 'True':
                    airplay.discovery()
            except:
                log.exception('Fail to airplay send_audio')

        self.args['id'] = str(request.GET.get('id', content.AUDIO))
        self._prepare_browse(request)
        uid = self.args['id']
        if uid == 'audio_album' or uid == 'audio_artist':
            self.args['view_mode'] = 'on'
            for row in self.args['rows']:
                if uid == 'audio_album':
                    row['audiotitle'] = row.get('album', '')
                    row['audiodesc'] = row.get('artist', '')
                elif uid == 'audio_artist':
                    row['audiotitle'] = row.get('artist', '')
                    row['audiodesc'] = pretty_count([(row.get('child_count', '0'), " Song", " Songs")])
        else:
            for row in self.args['rows']:
                self._pretty_format(request, row)

        self.args['cur_menu'] = 'audio'
        return ('audio.html', self.args)