ContextMenus.py 文件源码

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

项目:script.reddit.reader 作者: gedisony 项目源码 文件源码
def build_reddit_search_context_menu_entries(hasmultiplesubreddit,subreddit,link_url ):
    cxm_list=[]
    colored_subreddit_full=colored_subreddit( subreddit )
    label_search=translation(32520)
    parts_of_link_url=urlparse.urlparse(link_url)

    if cxm_show_search:
        if GCXM_hasmultiplesubreddit:
            cxm_list.append( (label_search        , build_script("search", '', '')  ) )
        else:
            label_search+=' {0}'.format(colored_subreddit_full)
            cxm_list.append( (label_search        , build_script("search", '', subreddit)  ) )
        #NOTE: can't use the entire link_url because it will work for www.reddit.com but not for oauth.reddit.com
        part_to_search="{0} {1}".format(parts_of_link_url.path,parts_of_link_url.query)
        if part_to_search.startswith('/'): part_to_search=part_to_search[1:]  #remove starting '/'

        remove_these_words=['.mp4','.webm','/v/','.jpg','.png'] #mainly to match imgur links where we want to catch the imageID not "imageID.mp4"
        part_to_search=re.sub('|'.join(re.escape(word) for word in remove_these_words), '', part_to_search)

        #log('parts to search='+part_to_search)
        cxm_list.append( (translation(32531)    , build_script("listSubReddit", assemble_reddit_filter_string(part_to_search,'','',''), name=translation(32531))  ) ) #"Other posts with this link"
    return cxm_list
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号