def downloadable_size(claims, local=False):
    """Calculate the total size of input claims.

    Parameters
    ----------
    claims: list of dict
        List of claims obtained from `claim_search`,
        or if using `local=True`, from `file_list`.
    local: bool, optional
        It defaults to `False` in which case it assumes the claims
        were resolved online from `claim_search`.
        If it is `True` it assumes the claims come from `file_list`,
        that is, from the claims locally downloaded.
        This is necessary because the information is in different fields
        depending on where it comes from.

    Returns
    -------
    dict
        A dictionary with two keys:
        - 'size': total size of the claims in bytes.
          It can be divided by 1024 to obtain kibibytes, by another 1024
          to obtain mebibytes, and by another 1024 to obtain gibibytes.
        - 'duration': total duration of the claims in seconds.
          It will count only stream types which have a duration
          such as audio and video.
          The duration can be divided by 3600 to obtain hours,
          then by 24 to obtain days.
    """
    if local:
        print("Calculate size of fully downloaded claims")
    else:
        print("Calculate size of downloadable claims")

    n_claims = len(claims)
    total_size = 0
    total_duration = 0

    for num, claim in enumerate(claims, start=1):
        if local:
            vtype = claim["mime_type"]
            source_info = claim["metadata"]
            alt_name = claim["stream_name"]
        else:
            vtype = claim["value_type"]
            source_info = claim["value"]
            alt_name = claim["name"]

        if "source" in source_info:
            file_name = source_info["source"].get("name", "None")
            size = int(source_info["source"].get("size", 0))
        else:
            file_name = alt_name
            size = 0
            print(f"{num:4d}/{n_claims:4d}; type: {vtype}; "
                  f'no source: "{file_name}"')

        seconds = 0
        if "video" in source_info:
            seconds = source_info["video"].get("duration", 0)
        elif "audio" in source_info:
            seconds = source_info["audio"].get("duration", 0)

        total_size += size
        total_duration += seconds

    return {"size": total_size,
            "duration": total_duration}