def filter_pubs(pubs):
    """Remove publications without links, and merge
    datasets and publications data together. 
    Also deduplicates publications based on pids.
    
    Args:
        pubs (dict): Publication data from OpenAIRE.
    Returns:
        _pubs (list): Flattened list of input data.
    """
    _pubs, pids = [], set()
    for p in pubs['datasets'] + pubs['publications']:
        if 'pid' not in p:
            continue
        already_found = any(id in pids for id in p['pid'])
        pids = pids.union(p['pid'])
        if already_found or len(p['pid']) == 0:
            continue
        _pubs.append(dict(id=p['pid'][0], **p))
    return _pubs