anilist_search_methods.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:tsubasa-reddit-bot 作者: ArmandSyah 项目源码 文件源码
def get_anilist_links(title):
    """Iterates through all search methods until link is constructed"""
    exclude = set(string.punctuation)
    title = ''.join(ch for ch in title if ch not in exclude)
    title = title.lower().split(' ')
    if 'season' in title:
        title.remove('season')
    title = ' '.join(title)
    anilist_regex = re.compile(r'http(s)?://anilist.co/anime/([0-9]){1,5}(/.*)?')
    link_dispatcher = {'api': _get_anilist_link_by_api}

    for _, v in link_dispatcher.items():
        anilist_url = v(title)
        if anilist_url is None:
            continue
        if re.match(anilist_regex, anilist_url) is not None:
            return anilist_url

    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号