示例#1
0
    def update_metadata(self,table,mp):
        """Write data back to the mediapackage"""
        for child in table.get_children():
            name = child.get_name()
            if name in DCTERMS:
                if name in ["creator", "contributor", "subject"]:
                    if child.get_text() == "":
                        mp.metadata_episode[name] = None
                    else:
                        mp.metadata_episode[name] = unicode(child.get_text().strip(),encoding='utf-8')

                elif name in [ "ispartof", "isPartOf" ]:
                    if child.get_active_iter():
                        identifier = child.get_model()[child.get_active_iter()][1]
                    else:
                        identifier = None
                    series = utils_series.filterSeriesbyId(self.series_list, identifier)
                    if series:
                        mp.setSeries(series["list"])
                        if not mp.getCatalogs("dublincore/series") and mp.getURI():
                            new_series = mediapackage.Catalog(os.path.join(mp.getURI(),"series.xml"),mimetype="text/xml",flavor="dublincore/series")
                            mp.add(new_series)
                    else:
                        mp.setSeries(None)
                        catalog= mp.getCatalogs("dublincore/series")
                        if catalog:
                            mp.remove(catalog[0])
                else:
                    unicode_text = unicode(child.get_text(),encoding='utf-8')
                    mp.metadata_episode[name]=unicode_text
示例#2
0
    def fill_metadata(self, table, mp, button, blocked=set(), mandatory=set()):
        """
        Fill the table with available data, empty otherwise
        """
        row = 1

        for meta in DCTERMS:
            t = Gtk.Label(label=metadata[meta])
            t.set_justify(Gtk.Justification.LEFT)
            t.set_alignment(0, 0)
            t.set_width_chars(15)

            # Switch the INSENSITIVE state colour to red, so that we can mark the mandatory parameters
            t.modify_fg(Gtk.StateType.INSENSITIVE, Gdk.color_parse('red'))

            if meta in ["ispartof", "isPartOf"]:
                try:
                    default_series = utils_series.filterSeriesbyId(
                        self.series_list,
                        mp.metadata_series['identifier'])['id']
                except Exception:
                    default_series = None

                d = ComboBoxEntryExt(self.par,
                                     self.series_list,
                                     default=default_series,
                                     empty_label=self.empty_series_label)
                d.set_name(meta)
                cell = d.get_cells()[0]
                cell.props.ellipsize = Pango.EllipsizeMode.END
                cell.props.max_width_chars = 2
            else:
                d = Gtk.Entry()
                d.set_name(meta)
                try:
                    d.set_text(mp.metadata_episode[meta] or '')
                except KeyError:
                    d.set_text('')

            if meta in blocked:
                d.set_sensitive(False)

            if meta in mandatory:
                d.connect_after('changed', self.check_mandatory, button)
                self.mandatory[d] = t

            if meta == "created":  # currently Unused
                d.connect("button-press-event", self.edit_date)
            if meta == "title":
                d.set_tooltip_text(d.get_text())

            table.attach(t, 0, row - 1, 1, 1)
            table.attach(d, 1, row - 1, 2, 1)
            row = row + 1
示例#3
0
def on_rec(button):
    global dispatcher, recorder, recorder_ui, metadata
    dispatcher.emit("action-audio-disable-msg")
    mp = None

    if not recorder.current_mediapackage:
        mp = recorder.create_mp()

    if not mp:
        mp = recorder.current_mediapackage

    # Add default metadata to the MP
    mp.metadata_episode.update(metadata)

    ocservice = context.get_ocservice()
    series_list = []
    if ocservice:
        series_list = ocservice.series

    # Check the series
    try:
        del (mp.metadata_episode['isPartOf'])
        mp.metadata_series = utils_series.filterSeriesbyId(
            series_list, metadata['isPartOf'])['list']
    except (TypeError, KeyError):
        # There was no series specified, so no change was needed
        pass

    arguments = {
        'package': mp,
        #'series_list': series_list,
        'title': _("New Recording"),
        'subtitle': _("New Recording"),
        'ok_label': _("Start"),
    }

    if len(series_list) <= 1:
        arguments['empty_series_label'] = None

    popup = MetadataClass(**arguments)

    if popup.return_value == -8:
        recorder_ui.on_rec(button=None)
    dispatcher.emit("action-audio-enable-msg")
def on_rec(button):
    global dispatcher, recorder, recorder_ui, metadata
    dispatcher.emit("action-audio-disable-msg")
    mp = None

    if not recorder.current_mediapackage:
        mp = recorder.create_mp()

    if not mp:
        mp = recorder.current_mediapackage

    # Add default metadata to the MP
    mp.metadata_episode.update(metadata)

    ocservice = context.get_ocservice()
    series_list= []
    if ocservice:
        series_list = ocservice.series

    # Check the series
    try:
        del(mp.metadata_episode['isPartOf'])
        mp.metadata_series = utils_series.filterSeriesbyId(series_list, metadata['isPartOf'])['list']
    except (TypeError, KeyError):
        # There was no series specified, so no change was needed
        pass

    arguments = { 'package': mp,
                  #'series_list': series_list,
                  'title': _("New Recording"),
                  'subtitle': _("New Recording"),
                  'ok_label': _("Start"),
                  }

    if len(series_list) <= 1:
        arguments['empty_series_label'] = None

    popup = MetadataClass(**arguments)

    if popup.return_value == -8:
        recorder_ui.on_rec(button=None)
    dispatcher.emit("action-audio-enable-msg")