function p-xhamster-list
    set -l url $argv[1]
    set -l page 1
    set -l links
    set -l count 1

    if test -z "$url"
        echo "ERROR: no URL given"
        return 3
    end

    while test $count -gt 0
        echo -n "Getting page $page: " >&2
        set -l pagelinks (wget -O - "$url/$page" 2>/dev/null \
        | sed "s:>:>\n:g" \
        | grep "<a" \
        | sed -n 's|.*\(https://xhamster.com/videos/[^"]\+\).*|\1|p' \
        | uniq | string split ' ')

        set count (count $pagelinks)
        echo "$count links found" >&2
        set -a links $pagelinks
        set page (math $page + 1)
    end

    echo -e (string join "\n" $links)

end
