def guess_type(url, supported):
    """Guess the mime type of the file link.
    If the mimetype is not recognized, default to the first supported value.


    Parameters
    ----------
    url : str
      Path or URL to file.
    supported : list, tuple
      Supported mimetypes.

    Returns
    -------
    mimetype, encoding
    """
    import mimetypes
    try:
        mime, enc = mimetypes.guess_type(url, strict=False)
    except TypeError:
        mime, enc = None, None
    if (mime == 'application/x-netcdf' and 'dodsC' in url and 
        'application/x-ogc-dods' in supported):
        mime = 'application/x-ogc-dods'
    zips = ['application/zip', 'application/x-zipped-shp']
    if mime not in supported:
        if mime in zips and set(zips).intersection(supported):
            mime = set(zips).intersection(supported).pop()
    if mime is None:
        mime = supported[0]
    elif mime not in supported:
        raise ValueError(
            f'mimetype {mime} not in supported mimetypes {supported}.')
    return mime, enc
