def extract_spotify_id(raw_string):
    """
    Returns a Spotify ID of a playlist, album, etc. after extracting
    it from a given HTTP URL or Spotify URI.
    """
    if '/' in raw_string:
        if raw_string.endswith('/'):
            raw_string = raw_string[:-1]
        to_trim = raw_string.find('?')
        if not to_trim == -1:
            raw_string = raw_string[:to_trim]
        splits = raw_string.split('/')
    else:
        splits = raw_string.split(':')
    spotify_id = splits[-1]
    return spotify_id
