Ejemplo n.º 1
0
def getResult(url, card, channels):
    result = weibo_2_album.get(url, card['mblog'])
    if '全文</a>' not in str(card['mblog']):
        return result
    full_result = weibo_2_album.get(url)
    if full_result.cap_html_v2:
        result.cap_html_v2 = full_result.cap_html_v2
    return result
Ejemplo n.º 2
0
def process(key):
    channels = subscription.channels(tele.bot, key)
    search_result = weiboo.search(key, force_cache=True)
    if isInt(key):  # backfill, can remove this part after 7/17
        result = weiboo.searchUser(key)
        if result:
            weibo_name.update(result[0], result[1])
    if not search_result:
        print('no search result', key)
    for url, card in search_result:
        result = None
        for channel in channels:
            if not shouldProcess(channel, card, key):
                continue
            print(url, channel.id, channel.username)
            if not result:
                time.sleep(60)
                result = weibo_2_album.get(url, card['mblog'])
                removeSeeMore(result)
            try:
                album_sender.send_v2(channel, result)
            except Exception as e:
                debug_group.send_message(
                    getLogStr(channel.username, channel.id, url, e))
                raise e
def processCard(card):
    if not shouldSend(card):
        return
    url = clearUrl(card['scheme'])
    if url in db.existing.items:
        return

    r = weibo_2_album.get(url)
    print('hash', r.hash)
    if (str(r.wid) in db.existing.items or str(r.rwid) in db.existing.items
            or str(r.hash) in db.existing.items):
        return

    print('sending', url, r.wid, r.rwid)
    timer.wait(10)

    cache[r.hash] = cache.get(r.hash, 0) + 1
    if cache[r.hash] > 2:
        # for whatever reason, this url does not send to telegram, skip
        db.existing.add(r.hash)

    album_sender.send(channel, url, r)

    db.existing.add(url)
    db.existing.add(r.wid)
    db.existing.add(r.rwid)
    db.existing.add(r.hash)
Ejemplo n.º 4
0
def getContent(url, force_cache=False):
    if 'weibo.c' in url:
        wid = getWid(url)
        if matchKey(url, ['card', 'ttarticle']):
            new_url = 'https://card.weibo.com/article/m/aj/detail?id=' + wid + '&_t=' + str(
                int(time.time()))
            json = yaml.load(cached_url.get(new_url,
                                            headers={'referer': url},
                                            force_cache=force_cache),
                             Loader=yaml.FullLoader)
            return '<div><title>%s</title>%s</div>' % (json['data']['title'],
                                                       json['data']['content'])
        return getContentFromAlbum(weibo_2_album.get(url))
    if 'photos.google.com/share' in url:
        return getContentFromAlbum(gphoto_2_album.get(url), noText=True)
    return cached_url.get(url, force_cache=force_cache)
Ejemplo n.º 5
0
def test():
	result = weibo_2_album.get('https://m.weibo.cn/detail/4585474025325107#comment')
	print(pic_cut.getCutImages(result.imgs, limit=100))
Ejemplo n.º 6
0
def test(url, rotate=False):
    r = weibo_2_album.get(url)
    r.cap_html_v2 = ''
    print(r)
    album_sender.send_v2(chat, r, rotate=rotate)
Ejemplo n.º 7
0
def test(url):
    result = weibo_2_album.get(url)
    album_sender.send_v2(chat, result)