# Path: crawler/gather/items.py
# class ChannelItem(Item):
#     office_id = Field()
#     short = Field()
#     name = Field()
#     image = Field()
#     url = Field()
# 
# class RoomItem(Item):
#     office_id = Field()
#     name = Field()
#     image = Field()
#     url = Field()
#     online = Field()
#     host = Field()
#     channel = Field()
#     followers = Field()
#     description = Field()
#     announcement = Field()
#     start_time = Field()


from scrapy import Spider, Request
from ..items import ChannelItem, RoomItem
import json
                'name': name,
                'image': image,
                'url': response.urljoin(url),
                'sent': False
            }
        room_query = {
            'url': 'http://api.plu.cn/tga/streams?max-results=50&sort-by=top',
            'offset': 0, 'channels': channel_list
        }
        yield Request('{}&start-index=0'.format(room_query['url']), callback=self.parse_room_list, meta=room_query)

    def parse_room_list(self, response):
        channel_list = response.meta['channels']
        room_list = json.loads(response.text)['data']['items']
        if isinstance(room_list, list):
            for mixjson in room_list:
                cjson = mixjson['game'][0]
                if not cjson['tag']:
                    continue
                if cjson['tag'] in channel_list:
                    if not channel_list[cjson['tag']]['sent']:
                        channel_list[cjson['tag']]['sent'] = True
                        yield ChannelItem({
                            'office_id': str(cjson['id']),
                            'short': channel_list[cjson['tag']]['short'],
                            'name': channel_list[cjson['tag']]['name'],
                            'image': channel_list[cjson['tag']]['image'],
                            'url': channel_list[cjson['tag']]['url']
                        })
                else:

# Path: crawler/gather/items.py
# class ChannelItem(Item):
#     office_id = Field()
#     short = Field()
#     name = Field()
#     image = Field()
#     url = Field()
# 
# class RoomItem(Item):
#     office_id = Field()
#     name = Field()
#     image = Field()
#     url = Field()
#     online = Field()
#     host = Field()
#     channel = Field()
#     followers = Field()
#     description = Field()
#     announcement = Field()
#     start_time = Field()


# Path: crawler/gather/spiders/longzhu.py
from scrapy import Spider, Request
from ..items import ChannelItem, RoomItem
import json

                'name': name,
                'image': image,
                'url': response.urljoin(url),
                'sent': False
            }
        room_query = {
            'url': 'http://api.plu.cn/tga/streams?max-results=50&sort-by=top',
            'offset': 0, 'channels': channel_list
        }
        yield Request('{}&start-index=0'.format(room_query['url']), callback=self.parse_room_list, meta=room_query)

    def parse_room_list(self, response):
        channel_list = response.meta['channels']
        room_list = json.loads(response.text)['data']['items']
        if isinstance(room_list, list):
            for mixjson in room_list:
                cjson = mixjson['game'][0]
                if not cjson['tag']:
                    continue
                if cjson['tag'] in channel_list:
                    if not channel_list[cjson['tag']]['sent']:
                        channel_list[cjson['tag']]['sent'] = True
                        yield ChannelItem({
                            'office_id': str(cjson['id']),
                            'short': channel_list[cjson['tag']]['short'],
                            'name': channel_list[cjson['tag']]['name'],
                            'image': channel_list[cjson['tag']]['image'],
                            'url': channel_list[cjson['tag']]['url']
                        })
                else:

                    yield ChannelItem({