Esempio n. 1
0
def read_adj_mat():
    streets = set()
    transitions = set()
    with open('./dataset/adj_matrix.csv', encoding="utf-8") as f:
        for line in f:
            names = line.strip().split(' ')
            if names[0] == '':
                continue
            streets.add(filter_name(names[0]))
            for i in range(1, len(names)):
                transitions.add((
                    filter_name(names[0]),
                    filter_name(names[i]),
                ))
    streets = list(streets)
    nlen = len(streets)
    adj_mat = []
    for i in range(nlen):
        adj_mat.append([0] * nlen)
        adj_mat[-1][i] = 1
    for t in transitions:
        if t[0] in streets and t[1] in streets:
            i1 = streets.index(t[0])
            i2 = streets.index(t[1])
            adj_mat[i1][i2] = 1
            adj_mat[i2][i1] = 1
    return streets, adj_mat
Esempio n. 2
0
def categorize_by_street(info, all_data):
    columns = ['driverID', 'orderID', 'time', 'lat', 'long', 'street']
    for _, p in all_data.iterrows():
        # isnan(p['street'])
        if isinstance(p['street'], float):
            continue
        info[filter_name(p['street'])].append({k: p[k] for k in columns})
        for street in info:
            info[street] = sorted(info[street], key=lambda t: t['time'])
    return info
Esempio n. 3
0
def build_embed(user, item, channel, pubDate, image):
	try:	
		embed = discord.Embed(colour=0xEED000, url=item.link, description="[" + utils.filter_name(item.title) + "](" + item.link + ")\n```" + item.description + "```", timestamp=pubDate.astimezone(pytz.timezone("utc")))
		embed.set_thumbnail(url=image)
		embed.set_author(name=user + "'s MyAnimeList", url="https://myanimelist.net/profile/" + user, icon_url=iconMAL)
		embed.set_footer(text="MyAnimeBot", icon_url=iconBot)
		
		return embed
	except Exception as e:
		logger.error("Error when generating the message: " + str(e))
		return
Esempio n. 4
0
    def _doDynamicResponse(self, query):
        """
        Calculate the response to a query.
        """

        name = str(query.name)
        parts = filter_name(name)
        ip = query_ip(parts)

        answer = dns.RRHeader(name=name, payload=dns.Record_A(address=ip))
        answers = [answer]
        authority = []
        additional = []
        return answers, authority, additional
Esempio n. 5
0
# coding: utf-8

import xmlrpc.client
from consts import port
from utils import filter_name

s = xmlrpc.client.ServerProxy('http://0.0.0.0:{p}/'.format(p=port))


def update_ip(name):
    print('update ip....')
    print(s.update_ip(name))


def query_ip(name):
    print('query ip "{name}" ...'.format(name=name))
    ip, port = s.query_ip(name)
    if ip == "":
        ip = '127.0.0.1'
    print('query ip res: ', ip)
    return ip


if __name__ == '__main__':
    test_name = filter_name('server.test')

    # inter-query
    query_ip(test_name)
    update_ip(test_name)
    query_ip(test_name)
Esempio n. 6
0
def get(url, func=None) -> dict:
    print('获取参数和签名.....')
    params = getParams(url)
    if params == None:
        return {"msg": "未匹配到视频信息"}
    #print(params)

    max_cursor = 0
    headers["user-agent"] = params["agent"]
    results = []

    print('拉去视频列表.....')
    while (1):
        try:
            url = f'https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid={params["sec_uid"]}&count=50&max_cursor={max_cursor}&aid=1128&_signature={params["_signature"]}&dytk={params["dytk"]}'
            rep = requests.get(url, headers=headers)
            jsons = json.loads(rep.text)
            if jsons["has_more"] == True:
                _list = jsons["aweme_list"]
                if _list:
                    max_cursor = jsons["max_cursor"]
                    for item in _list:
                        results.append({
                            'author': {
                                'nickname':
                                item['author']['nickname'],
                                'custom_verify':
                                item['author']['custom_verify'],
                                'signature':
                                item['author']['signature'],
                                'uid':
                                item['author']['uid'],
                                'avatar':
                                item['author']['avatar_larger']['url_list']
                            },
                            'desc': item['desc'],
                            'statistics': item['statistics'],
                            'video': {
                                'duration': item['video']['duration'],
                                'url':
                                item['video']['download_addr']['url_list']
                            }
                        })
                    time.sleep(0.5)
                else:
                    time.sleep(1)
            else:
                break
        except BaseException:
            break

    videos = []
    for item in results:
        url = item["video"]["url"][0]

        videos.append({
            'url': url.replace('watermark=1', 'watermark=0'),
            'name': filter_name(item["desc"]),
            'headers': {
                'Accept': '*/*',
                'Accept-Encoding': 'gzip, deflate, br',
                'Connection': 'keep-alive',
                'User-Agent': 'PostmanRuntime/7.24.1'
            }
        })

    return {'videos': videos}