예제 #1
0
    def initialize(self):
        self.dispersy = self.session.get_dispersy_instance()

        # get all channels owned by me
        from Tribler.community.channel.community import ChannelCommunity
        for community in self.session.lm.dispersy.get_communities():
            if isinstance(community, ChannelCommunity) and community.master_member and community.master_member.private_key:
                channel_obj = ChannelObject(self.session, community, is_created=True)
                channel_obj.initialize()
                self._channel_list.append(channel_obj)

                self._logger.debug(u"loaded channel '%s', %s", channel_obj.name, hexlify(community.cid))
예제 #2
0
    def create_channel(self, name, description, mode, rss_url=None):
        """
        Creates a new Channel.
        :param name: Name of the Channel.
        :param description: Description of the Channel.
        :param mode: Mode of the Channel ('open', 'semi-open', or 'closed').
        :param rss_url: RSS URL for the Channel.
        :return: Channel ID
        :raises DuplicateChannelNameError if name already exists
        """
        assert isinstance(
            name, basestring), u"name is not a basestring: %s" % type(name)
        assert isinstance(
            description, basestring
        ), u"description is not a basestring: %s" % type(description)
        assert mode in self._channel_mode_map, u"invalid mode: %s" % mode
        assert isinstance(
            rss_url, basestring
        ) or rss_url is None, u"rss_url is not a basestring or None: %s" % type(
            rss_url)

        # if two channels have the same name, this will not work
        for channel_object in self._channel_list:
            if name == channel_object.name:
                raise DuplicateChannelNameError(
                    u"Channel name already exists: %s" % name)

        channel_mode = self._channel_mode_map[mode]
        community = ChannelCommunity.create_community(
            self.dispersy,
            self.session.dispersy_member,
            tribler_session=self.session)

        channel_obj = ChannelObject(self.session, community)
        channel_obj.initialize()

        community.set_channel_mode(channel_mode)
        community.create_channel(name, description)

        # create channel object
        self._channel_list.append(channel_obj)

        if rss_url is not None:
            channel_obj.create_rss_feed(rss_url)

        self._logger.debug(u"creating channel '%s', %s", channel_obj.name,
                           hexlify(community.cid))
        return channel_obj.channel_id
예제 #3
0
    def initialize(self):
        self.dispersy = self.session.get_dispersy_instance()

        # get all channels owned by me
        from Tribler.community.channel.community import ChannelCommunity
        for community in self.session.lm.dispersy.get_communities():
            if isinstance(
                    community, ChannelCommunity
            ) and community.master_member and community.master_member.private_key:
                channel_obj = ChannelObject(self.session,
                                            community,
                                            is_created=True)
                channel_obj.initialize()
                self._channel_list.append(channel_obj)

                self._logger.debug(u"loaded channel '%s', %s",
                                   channel_obj.name, hexlify(community.cid))
예제 #4
0
    def create_channel(self, name, description, mode, rss_url=None):
        """
        Creates a new Channel.
        :param name: Name of the Channel.
        :param description: Description of the Channel.
        :param mode: Mode of the Channel ('open', 'semi-open', or 'closed').
        :param rss_url: RSS URL for the Channel.
        :return: Channel ID
        :raises DuplicateChannelNameError if name already exists
        """
        assert isinstance(name, basestring), u"name is not a basestring: %s" % type(name)
        assert isinstance(description, basestring), u"description is not a basestring: %s" % type(description)
        assert mode in self._channel_mode_map, u"invalid mode: %s" % mode
        assert isinstance(rss_url, basestring) or rss_url is None, u"rss_url is not a basestring or None: %s" % type(rss_url)

        # if two channels have the same name, this will not work
        for channel_object in self._channel_list:
            if name == channel_object.name:
                raise DuplicateChannelNameError(u"Channel name already exists: %s" % name)

        channel_mode = self._channel_mode_map[mode]
        community = ChannelCommunity.create_community(self.dispersy, self.session.dispersy_member,
                                                      tribler_session=self.session)

        channel_obj = ChannelObject(self.session, community)
        channel_obj.initialize()

        community.set_channel_mode(channel_mode)
        community.create_channel(name, description)

        # create channel object
        self._channel_list.append(channel_obj)

        if rss_url is not None:
            channel_obj.create_rss_feed(rss_url)

        self._logger.debug(u"creating channel '%s', %s", channel_obj.name, hexlify(community.cid))
        return channel_obj.channel_id