Ejemplo n.º 1
0
def get_series_xml():
    """
    This function returns an XML structure that contains all the series
    that are currently in airs, with all properties needed for XSLT -> HTML
    """

    dom = libxml2.newDoc("1.0")

    root = libxml2.newNode("airs")
    dom.addChild(root)

    options = _createOptionsNode()
    root.addChild(options)

    items = libxml2.newNode("series")
    root.addChild(items)

    todaystr = series_list.date_to_str(datetime.datetime.now())

    wdelta = series_list.idx_to_weekdelta(appcfg.options[appcfg.CFG_EPISODE_DELTA])
    bottomstr = series_list.date_to_str(datetime.date.today() - datetime.timedelta(weeks = wdelta))

    c = db.store.execute("select count(*) from episode where aired != '' and aired <= '%s'"
                         "and aired > '%s' and new != 0" % (todaystr, bottomstr) )
    items.setProp("airedcount", str(c.get_one()[0]))

    result = db.store.find(series_list.Series).order_by(series_list.Series.name)
    series = [serie for serie in result]

    for item in series:
        serie = libxml2.newNode("item")

        serie.setProp("name", item.name)
        serie.setProp("id", str(item.id))
        serie.setProp("cancelled", str(item.postponed))
        serie.setProp("folder", item.folder)

        seriespath = series_list.get_series_path(item)
        serie.setProp("mediacount", str(_getMediaCount(seriespath)))

        # report total number of episodes and the
        # episodes already seen
        c = db.store.execute("select count(*) from episode where series_id = %i and aired != '' and aired < '%s'" % \
                             (item.id, todaystr) )
        totalcount = str(c.get_one()[0])

        c = db.store.execute("select count(*) from episode where series_id = %i and status = %i" % \
                             (item.id, series_list.EP_SEEN))
        seencount = str(c.get_one()[0])

        #c = db.store.execute("select count(*) from episode where series_id = %i and status = 4" % item.id)
        #seencount = str(c.get_one()[0])

        serie.setProp("seencount", seencount)
        serie.setProp("count", totalcount)

        items.addChild(serie)

    return dom
Ejemplo n.º 2
0
    def __init__(self, parent, id = -1):

        pre = wx.PrePanel()

        # two count values displaying number of
        # episodes that are reported new / updated
        
        res = xmlres.loadGuiResource('MainPanel.xrc')
        res.LoadOnPanel(pre, parent, "ID_MAIN_PANEL")
        self.PostCreate(pre)

        self._update_all = xrc.XRCCTRL(self, "ID_UPDATE_ALL")
        self._update_one = xrc.XRCCTRL(self, "ID_UPDATE_ONE")

        self._show_unseen = xrc.XRCCTRL(self, "ID_SHOW_UNSEEN")

        self._queue = xrc.XRCCTRL(self, "ID_QUEUE")

        self._episodeFilter = xrc.XRCCTRL(self, "ID_EPISODE_FILTER")
        
        deltalist = [ "View episodes from last week",
                      "View episodes from last two weeks",
                      "View episodes from last month",
                      "View episodes from last two months" ]
        
        for delta in deltalist:        
            pos = self._episodeFilter.Append(delta)
            self._episodeFilter.SetClientData(pos, series_list.idx_to_weekdelta(pos))
        
        idx = appcfg.options[appcfg.CFG_EPISODE_DELTA]
        self._episodeFilter.SetSelection(idx)
        viewmgr._series_sel._weeks_delta = self._episodeFilter.GetClientData(idx)

        # put the mixin control in place and initialize the
        # columns and styles
        self._list_panel = xrc.XRCCTRL(self, "ID_EPISODE_VIEW")
        self._series_selection = xrc.XRCCTRL(self, "ID_SERIES_LIST")
        self._series_list = EpisodeListCtrl(self._list_panel)

        # create main view (for now)
        sizer = wx.BoxSizer()
        sizer.Add(self._series_list, 1, wx.EXPAND)
        self._list_panel.SetSizer(sizer)        
                
        self.tmr = wx.Timer(self)
        self.tmr.Start(300)
        
        self.Bind(wx.EVT_TIMER, self._onTimer, self.tmr)
        self.Bind(wx.EVT_BUTTON, self._onUpdateAll, self._update_all)
        self.Bind(wx.EVT_BUTTON, self._onUpdateOne, self._update_one)
        self.Bind(wx.EVT_CHOICE, self._onSelectSeries, self._series_selection)
        self.Bind(wx.EVT_CHOICE, self._onEpisodeFilter, self._episodeFilter)
        self.Bind(wx.EVT_CHECKBOX, self._onShowOnlyUnseen, self._show_unseen)
        self.Bind(wx.EVT_UPDATE_UI, self._onGuiUpdated)
        
        Publisher().subscribe(self._onSignalRestoreSeries, signals.DATA_SERIES_RESTORED)
        Publisher().subscribe(self._onAppInitialized, signals.APP_INITIALIZED)
        Publisher().subscribe(self._onDeleteSeries, signals.SERIES_DELETED)
        Publisher().subscribe(self._onAddSeries, signals.SERIES_ADDED)
        Publisher().subscribe(self._onSerieSelected, signals.SERIES_SELECT)
        Publisher().subscribe(self._onSerieUpdated, signals.SERIES_UPDATED)
        Publisher().subscribe(self._onViewChanged, signals.SET_VIEW)
        Publisher().subscribe(self._onEditEpisode, signals.EPISODE_EDIT)