Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
2
Indexable
    async def save_playlists(self, response):
        play_list = response['data']
        sort_idx = 1
        channel_list = []

        for item in play_list:
            uuid = str(item['id'])
            name = item['name']
            sort_idx += 1
            description = item['description']
            channel = await self.add(Channel(uuid=uuid, name=name, sort_idx=sort_idx, description=description))
            channel_list.append(channel)

            for channel in channel_list:
                channel_item_list = []
                response = await self.get_movies(channel.uuid)
                movies = response['data']
                for item in movies:
                    channel_item = ChannelItem(channel_id=channel.id,
                                               item_id=item['id'],
                                               duration=item['duration'] * 1000,
                                               position=item['position'],
                                               name=item['title']
                                               )
                    channel_item_list.append(channel_item)

                await self.add_items(channel.id, channel_item_list)
            await self.update_channel_items()
Leave a Comment