Refactor channel url handling, in preparation for adding --channel

It is now possible to get at the individual parts of the logic individually.