The YouTube algorithm is often seen as a mysterious black box, determining which videos rise to fame and which languish in obscurity.