Beispiel #1
0
    def adapt_to_news(self, params):
        news = News()
        offline = 1
        if params.get("online"):
            offline = 0
        news.url = params.get("publish_url", "")
        news.unique_id = params.get("unique_id", "")
        news.title = params.get("title", "")
        news.author = params.get("author", "")
        news.publish_time = params.get("publish_time", get_default_time())
        news.publish_name = params.get("publish_site", "")
        news.publish_url = params.get("publish_url", "")
        news.style = VideoStyle
        news.offline = offline
        news.insert_time = params.get("insert_time", get_default_time())
        news.channel_id = params.get("chanel_id", 0)
        news.second_channel_id = params.get("second_channel_id", 0)
        news.source_id = params.get("source_id", 0)
        news.source_state = 0
        news.icon = params.get("site_icon")
        news.video_url = params.get("video_url", "")
        news.thumbnail = params.get("video_thumbnail", "")
        news.duration = params.get("video_duration", 0)
        news.return_type = VideoType
        news.content = "[]"
        news.click_times = params.get("play_times", 0)
        news.tags = params.get("tags", [])
        news.concern = params.get("like", 0)
        news.unconcern = params.get("dislike", 0)
        news.comment = params.get("comment", 0)
        news.spider_source_id = params.get("spider_source_id", "")

        return news
Beispiel #2
0
    def adapt_to_news(self, params):
        news = News()
        offline = 1
        if params.get("online"):
            offline = 0
        news.url = params.get("unique_id", "")
        news.unique_id = params.get("unique_id", "")
        news.title = params.get("title", "")
        news.author = params.get("author", "")
        news.publish_time = params.get("publish_time", get_default_time())
        news.publish_name = params.get("publish_site", "")
        news.style = params.get("style", ThreeStyle)
        news.offline = offline
        news.insert_time = params.get("insert_time", get_default_time())
        news.channel_id = JokeChannel
        news.source_id = params.get("source_id", 0)
        news.source_state = 0
        news.icon = params.get("site_icon", "")
        news.return_type = JokeType
        news.content = "[]"
        news.concern = params.get("like", 0)
        news.unconcern = params.get("dislike", 0)
        news.image_number = params.get("image_number", 0)
        news.images = params.get("images", [])
        news.spider_source_id = params.get("spider_source_id", "")

        return news
Beispiel #3
0
    def adapt_to_news(self, params):
        news = News()
        style = 0
        imgs_num = len(params.get("images", []))
        if 1 == imgs_num or 2 == imgs_num:
            style = OneStyle
        elif 3 == imgs_num:
            style = ThreeStyle
        else:
            style = ZeroStyle
        offline = 1
        if params.get("online"):
            offline = 0
        source = Source()
        source.id = params.get("source_id", 0)
        source.channel_id = params.get("channel_id", 0)
        source.second_channel_id = params.get("second_channel_id", 0)
        if 0 == source.channel_id:
            select_result = self.select_source(source)
            if isinstance(select_result, Exception):
                offline = 1
            else:
                source = select_result
        news.url = params.get("publish_url", "")
        news.unique_id = params.get("unique_id", "")
        news.title = params.get("title", "")
        news.content = params.get("content", "[]")
        news.author = params.get("author", "")
        news.publish_time = params.get("publish_time", get_default_time())
        news.publish_name = params.get("publish_site", "")
        news.publish_url = params.get("publish_url", "")
        news.tags = params.get("tags", [])
        news.province = params.get("province", "")
        news.city = params.get("city", "")
        news.district = params.get("district")
        news.image_number = params.get("image_num", 0)
        news.style = style
        news.images = params.get("images", [])
        news.insert_time = params.get("insert_time", get_default_time())
        news.channel_id = int(source.channel_id)
        news.second_channel_id = int(source.second_channel_id)
        news.source_id = int(source.id)
        news.source_state = 1
        news.icon = params.get("site_icon", "")
        news.offline = offline
        news.concern = params.get("like", 0)
        news.unconcern = params.get("dislike", 0)
        news.click_times = params.get("read", 0)
        news.spider_source_id = params.get("spider_source_id", 0)

        return news
Beispiel #4
0
 def __init__(self):
     self.nid = 0
     self.unique_id = ""
     self.content = None  # json
     self.author = ""
     self.avatar = ""
     self.publish_time = get_default_time()
     self.publish_name = ""
     self.style = JokeType
     self.images = []
     self.insert_time = get_default_time()
     self.channel_id = 0
     self.source_id = 0
     self.icon = ""
Beispiel #5
0
 def __init__(self):
     self.id = 0
     self.content = ""
     self.commend = 0
     self.insert_time = get_default_time()
     self.user_name = ""
     self.avatar = ""
     self.foreign_id = ""
     self.unique_id = ""
Beispiel #6
0
 def __init__(self):
     self.nid = 0
     self.url = ""
     self.unique_id = ""
     self.title = ""
     self.author = ""
     self.publish_time = get_default_time()
     self.publish_name = ""
     self.style = _VideoStyle
     self.images = []
     self.insert_time = get_default_time()
     self.channel_id = 0
     self.source_id = 0
     self.second_channel_id = 0
     self.icon = ""
     self.video_url = ""
     self.duration = 0
     self.tags = []
Beispiel #7
0
 def adapt_params(self, params):
     comment = Comment()
     comment.content = params.get("content", "")
     comment.commend = params.get("commend", 0)
     comment.insert_time = params.get("insert_time", get_default_time())
     comment.user_name = params.get("user_name", "")
     comment.avatar = params.get("avatar", "")
     comment.foreign_id = params.get("foreign_id", "")
     comment.unique_id = params.get("unique_id", "")
     return comment
Beispiel #8
0
 def adapt_to_video(self, params, nid):
     video = Video()
     video.nid = nid
     video.url = params.get("publish_url", "")
     video.unique_id = params.get("unique_id", "")
     video.title = params.get("title", "")
     video.author = params.get("author", "")
     video.publish_time = params.get("publish_time", get_default_time())
     video.publish_name = params.get("publish_site", "")
     video.images = params.get("video_thumbnail", "")
     video.insert_time = params.get("insert_time", get_default_time())
     video.channel_id = params.get("channel_id", 0)
     video.source_id = params.get("source_id", 0)
     video.second_channel_id = params.get("second_channel_id", 0)
     video.icon = params.get("site_icon", "")
     video.video_url = params.get("video_url", "")
     video.duration = params.get("video_duration", 0)
     video.tags = params.get("tags", [])
     return video
Beispiel #9
0
    def adapt_to_nnews(self, params, nid):
        nnews = NNews()
        nnews.nid = nid
        nnews.url = params.get("publish_url", "")
        nnews.unique_id = params.get("unique_id", "")
        nnews.title = params.get("title", "")
        nnews.content = params.get("content")
        nnews.author = params.get("author", "")
        nnews.publish_time = params.get("publish_time", get_default_time())
        nnews.publish_name = params.get("publish_site", "")
        nnews.publish_url = params.get("publish_url", "")
        nnews.tags = params.get("tags", [])
        nnews.province = params.get("province", "")
        nnews.city = params.get("city", "")
        nnews.district = params.get("district", "")
        nnews.image_number = params.get("image_numer", 0)
        nnews.images = params.get("images", [])
        nnews.insert_time = params.get("insert_time", get_default_time())
        nnews.source_id = params.get("source_id", 0)

        return nnews
Beispiel #10
0
 def __init__(self):
     self.nid = 0
     self.url = ""
     self.unique_id = ""
     self.title = ""
     self.content = None  # json
     self.author = ""
     self.publish_time = get_default_time()
     self.publish_name = ""
     self.publish_url = ""
     self.tags = []
     self.province = ""
     self.city = ""
     self.district = ""
     self.image_number = 0
     self.style = 0
     self.images = []
     self.insert_time = get_default_time()
     self.channel_id = 0
     self.second_channel_id = 0
     self.source_id = 0
     self.icon = ""
Beispiel #11
0
    def __init__(self):
        self.nid = 0
        self.url = ""
        self.unique_id = ""
        self.title = ""
        self.content = None  # json
        self.author = ""
        self.publish_time = get_default_time()
        self.publish_name = ""
        self.publish_url = ""
        self.tags = []
        self.province = ""
        self.city = ""
        self.district = ""
        self.image_number = 0
        self.style = 0
        self.images = []
        self.insert_time = get_default_time()
        self.channel_id = 0
        self.second_channel_id = 0
        self.source_id = 0
        self.icon = ""
        self.html = ""
        self.collect = 0
        self.concern = 0
        self.comment = 0
        self.offline = 0
        self.source_state = 0
        self.video_url = ""

        # self.video_type = 0
        self.thumbnail = ""
        self.duration = 0
        self.return_type = 0
        self.unconcern = 0
        self.click_times = 0

        # add for trace spider source info
        self.spider_source_id = ""
Beispiel #12
0
    def adapt_to_joke(self, params, nid):

        joke = Joke()

        joke.nid = nid
        joke.unique_id = params.get("unique_id", "")
        joke.content = params.get("content", "")
        joke.author = params.get("author", "")
        joke.avatar = params.get("author_icon", "")
        joke.publish_time = params.get("publish_time", get_default_time())
        joke.publish_name = params.get("publish_site", "")
        joke.style = params.get("style", ThreeStyle)
        joke.insert_time = params.get("insert_time")
        joke.channel_id = JokeChannel
        joke.source_id = params.get("source_id", 0)
        joke.icon = params.get("site_icon", "")
        joke.images = params.get("images", [])

        return joke
Beispiel #13
0
 def __init__(self):
     self.id = 0
     self.insert_time = get_default_time()
     self.name = ""
     self.icon = ""