Ejemplo n.º 1
0
    def getChannelInfo(self, showtime=True):
        '''Get program info for the current channel'''

        tuner_id = self.getChannel()
        chan_name = config.TV_CHANNELS[self.chan_index][1]
        chan_id = config.TV_CHANNELS[self.chan_index][0]

        channels = epg_xmltv.get_guide().get_programs(time.time(), time.time(),
                                                      chan_id)

        if channels and channels[0] and channels[0].programs:
            if showtime:
                start_s = time.strftime(
                    config.TV_TIME_FORMAT,
                    time.localtime(channels[0].programs[0].start))
                stop_s = time.strftime(
                    config.TV_TIME_FORMAT,
                    time.localtime(channels[0].programs[0].stop))
                ts = '(%s-%s)' % (start_s, stop_s)
                prog_info = '%s %s' % (ts, channels[0].programs[0].title)
            else:
                prog_info = channels[0].programs[0].title
        else:
            prog_info = 'No info'

        return tuner_id, chan_name, prog_info
Ejemplo n.º 2
0
    def getChannelInfoRaw(self):
        '''Get program info for the current channel'''

        tuner_id = self.getChannel()
        chan_name = config.TV_CHANNELS[self.chan_index][1]
        chan_id = config.TV_CHANNELS[self.chan_index][0]

        channels = epg_xmltv.get_guide().get_programs(time.time(), time.time(),
                                                      chan_id)

        if channels and channels[0] and channels[0].programs:
            start_t = channels[0].programs[0].start
            stop_t = channels[0].programs[0].stop
            prog_s = channels[0].programs[0].title
        else:
            start_t = 0
            stop_t = 0
            prog_s = 'No info'

        return tuner_id, chan_id, chan_name, start_t, stop_t, prog_s
Ejemplo n.º 3
0
    def __init__(self, start_time, player, menuw):
        Item.__init__(self)

        self.n_items, hours_per_page = skin.items_per_page(('tv', self))
        stop_time = start_time + hours_per_page * 60 * 60

        msgtext = _('Preparing the program guide')
        guide = epg_xmltv.get_guide(PopupBox(text=msgtext))
        channels = guide.GetPrograms(start=start_time + 1, stop=stop_time - 1)
        if not channels:
            AlertBox(text=_('TV Guide is corrupt!')).show()
            return

        selected = None
        for chan in channels:
            if chan.programs:
                selected = chan.programs[0]
                break

        self.col_time = 30  # each col represents 30 minutes
        self.n_cols = (stop_time - start_time) / 60 / self.col_time
        self.player = player

        self.type = 'tv'
        self.menuw = menuw
        self.visible = True
        self.select_time = start_time
        self.last_update = 0

        self.lastinput_value = None
        self.lastinput_time = None

        self.update_schedules(force=True)
        self.fc = FreevoChannels()

        self.rebuild(start_time, stop_time, guide.chan_list[0].id, selected)
        self.event_context = 'tvmenu'
        menuw.pushmenu(self)
Ejemplo n.º 4
0
    def __init__(self,
                 parent=None,
                 subject=None,
                 left=None,
                 top=None,
                 width=500,
                 height=350,
                 context=None):

        self.oldname = None
        if context:
            self.context = context
        else:
            context = 'guide'

        if isinstance(subject, TvProgram):
            (result, favs) = record_client.getFavorites()
            if result:
                num_favorites = len(favs)
                self.priority = num_favorites + 1
            else:
                self.priority = 1

            self.fav = Favorite(subject.title, subject, TRUE, TRUE, TRUE,
                                self.priority, TRUE, FALSE)

        else:
            self.fav = subject
            self.oldname = self.fav.name

        PopupBox.__init__(self,
                          text=_('Edit Favorite'),
                          x=left,
                          y=top,
                          width=width,
                          height=height)

        self.v_spacing = 15
        self.h_margin = 20
        self.v_margin = 20

        self.internal_h_align = Align.LEFT

        if not self.left: self.left = self.osd.width / 2 - self.width / 2
        if not self.top: self.top = self.osd.height / 2 - self.height / 2

        guide = epg_xmltv.get_guide()

        name = Label(_('Name') + ':', self, Align.LEFT)
        self.name_input = LetterBoxGroup(text=self.fav.name)
        self.name_input.h_align = Align.NONE
        self.add_child(self.name_input)

        title = Label(_('Title') + ': %s' % self.fav.title, self, Align.LEFT)

        chan = Label(_('Channel') + ':', self, Align.LEFT)

        self.chan_box = OptionBox('ANY')
        self.chan_box.h_align = Align.NONE
        self.chan_box.add_item(text=_('ANY'), value='ANY')

        i = 1
        chan_index = 0
        for ch in guide.chan_list:
            #if ch.id == self.fav.channel_id:
            if ch.displayname == self.fav.channel:
                chan_index = i
            i += 1
            self.chan_box.add_item(text=ch.displayname, value=ch.displayname)

        self.chan_box.toggle_selected_index(chan_index)
        # This is a hack for setting the OptionBox's label to the current
        # value. It should be done by OptionBox when drawing, but it doesn't
        # work :(
        self.chan_box.change_item(None)
        self.add_child(self.chan_box)

        dow = Label(_('Day of Week') + ':', self, Align.LEFT)
        self.dow_box = OptionBox('ANY DAY')
        self.dow_box.h_align = Align.NONE

        self.dow_box.add_item(text=_('ANY DAY'), value='ANY')

        i = 1
        dow_index = 0
        for dow in (_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'),
                    _('Sun')):
            val = "%d" % (i - 1)
            self.dow_box.add_item(text=_(dow), value=val)
            if val == self.fav.dow:
                dow_index = i
            i += 1
        self.dow_box.toggle_selected_index(dow_index)
        # This is a hack for setting the OptionBox's label to the current
        # value. It should be done by OptionBox when drawing, but it doesn't
        # work :(
        self.dow_box.change_item(None)
        self.add_child(self.dow_box)

        tod = Label(_('Time of Day') + ':', self, Align.LEFT)
        self.tod_box = OptionBox('ANY')
        self.tod_box.h_align = Align.NONE
        self.tod_box.add_item(text=_('ANY TIME'), value='ANY')

        i = 0
        tod_index = 0

        for h in range(0, 24):
            for m in (00, 30):
                val = i * 30
                # Little hack: we calculate the hours from Jan 1st, 1970 GMT,
                # and then use strftime to get the string representation
                text = strftime(config.TV_TIMEFORMAT,
                                gmtime(h * 3600 + 60 * m))
                self.tod_box.add_item(text=text, value=val)
                if val == self.fav.mod:
                    tod_index = i + 1
                i += 1
        self.tod_box.toggle_selected_index(tod_index)
        # This is a hack for setting the OptionBox's label to the current
        # value. It should be done by OptionBox when drawing, but it doesn't
        # work :(
        self.tod_box.change_item(None)
        self.add_child(self.tod_box)

        self.save = Button(_('Save'))
        self.add_child(self.save)
        if self.oldname:
            self.remove = Button(_('Remove'))
            self.add_child(self.remove)
        else:
            self.remove = None
        self.cancel = Button(_('CANCEL'))
        self.add_child(self.cancel)
Ejemplo n.º 5
0
    def rebuild(self, start_time, stop_time, start_channel, selected):
        """ rebuild the guide

        This is neccessary we change the set of programs that have to be
        displayed, this is the case when the user moves around in the menu.
        """
        _debug_('Reload', 2)
        self.guide = epg_xmltv.get_guide()
        channels = self.guide.GetPrograms(start=start_time + 1,
                                          stop=stop_time - 1)

        table = []

        self.start_time = start_time
        self.stop_time = stop_time
        self.start_channel = start_channel
        self.selected = selected

        self.display_up_arrow = FALSE
        self.display_down_arrow = FALSE

        # table header
        table += [['Chan']]
        for i in range(int(self.n_cols)):
            table[0] += [start_time + self.col_time * i * 60]

        table += [self.selected]  # the selected program

        found_1stchannel = 0
        if stop_time == None:
            found_1stchannel = 1

        flag_selected = 0

        n = 0
        for chan in channels:
            if n >= self.n_items:
                self.display_down_arrow = TRUE
                break

            if start_channel != None and chan.id == start_channel:
                found_1stchannel = 1

            if not found_1stchannel:
                self.display_up_arrow = TRUE

            if found_1stchannel:
                if not chan.programs:
                    prg = epg_types.TvProgram()
                    prg.channel_id = chan.id
                    prg.start = 0
                    prg.stop = 2147483647  # Year 2038
                    prg.title = CHAN_NO_DATA
                    prg.desc = ''
                    chan.programs = [prg]

                for i in range(len(chan.programs)):
                    if selected:
                        if chan.programs[i] == selected:
                            flag_selected = 1

                table += [chan]
                n += 1

        if flag_selected == 0:
            for i in range(2, len(table)):
                if flag_selected == 1:
                    break
                else:
                    if table[i].programs:
                        for j in range(len(table[i].programs)):
                            if table[i].programs[j].stop > start_time:
                                self.selected = table[i].programs[j]
                                table[1] = table[i].programs[j]
                                flag_selected = 1
                                break

        self.table = table
        # then we can refresh the display with this programs
        self.update()