Ejemplo n.º 1
0
    def create_torrents(self, tor_values, _, channel_dict):
        """
        function to create torrents from channel. Adapted from
        ChannelManager in SearchGridManager
        """

        #adding new channel from the one that can't be detected from torrent values
        fetch_channels = set(hit[0] for hit in tor_values
                             if hit[0] not in channel_dict)
        if len(fetch_channels) > 0:
            channels_new_dict = self.channelcast_db.getChannels(fetch_channels)
            channels = []
            for hit in channels_new_dict:
                channel = Channel(*hit)
                channels.append(channel)

            for channel in channels:
                channel_dict[channel.id] = channel

        # creating torrents
        torrents = []
        for hit in tor_values:
            if hit:
                chan_torrent = ChannelTorrent(
                    *hit[1:] + [channel_dict.get(hit[0], None), None])
                chan_torrent.torrent_db = self.torrent_db
                chan_torrent.channelcast_db = self.channelcast_db

                if chan_torrent.name:
                    torrents.append(chan_torrent)

        return torrents
Ejemplo n.º 2
0
 def _createChannel(self, hit):
     """
     Create a Channel object from a remote search hit.
     :param hit: Remote search hit.
     :return: Channel object.
     """
     return Channel(*hit)
Ejemplo n.º 3
0
        def get_channel_id():
            """
            find channel id by looking at the network
            """
            if self.community and self.community._channel_id:
                self.channel_id = self.community._channel_id

                channel_dict = self.channelcast_db.getChannel(self.channel_id)
                self.channel = Channel(*channel_dict)

                task_call = self.check_and_register_task(
                    str(self.source) + "_update",
                    LoopingCall(self._update)).start(self.interval, now=True)
                if task_call:
                    self._logger.debug("Registering update call")

                self._logger.info("Got channel id %s", self.channel_id)

                self.ready = True
            else:
                self._logger.warning(
                    "Could not get channel id, retrying in 10 s")
                self.register_task(
                    str(self.source) + "_get_id",
                    reactor.callLater(10, get_channel_id))
Ejemplo n.º 4
0
    def _createChannels(self, hits):
        """
        Create a Channel objects from a list of remote search hits
        :param hits: List of remote search hits.
        :return: List of Channel objects.
        """
        channels = []
        for hit in hits:
            channel = Channel(*hit)
            channels.append(channel)

        return len(channels), channels
Ejemplo n.º 5
0
 def create_channel(a):
     return Channel(*a)